Align tested boolean/Boolean expectations
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / databroker / actors / dds / EmptyTransactionCommitCohortTest.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.cluster.databroker.actors.dds;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNull;
12 import static org.mockito.Mockito.verify;
13 import static org.opendaylight.controller.cluster.databroker.actors.dds.TestUtils.TRANSACTION_ID;
14 import static org.opendaylight.controller.cluster.databroker.actors.dds.TestUtils.getWithTimeout;
15
16 import com.google.common.util.concurrent.ListenableFuture;
17 import org.junit.Assert;
18 import org.junit.Before;
19 import org.junit.Test;
20 import org.mockito.Mock;
21 import org.mockito.MockitoAnnotations;
22
23 public class EmptyTransactionCommitCohortTest {
24
25     @Mock
26     private AbstractClientHistory history;
27
28     private EmptyTransactionCommitCohort cohort;
29
30     @Before
31     public void setUp() {
32         MockitoAnnotations.initMocks(this);
33         cohort = new EmptyTransactionCommitCohort(history, TRANSACTION_ID);
34     }
35
36     @Test
37     public void testCanCommit() throws Exception {
38         final ListenableFuture<Boolean> canCommit = cohort.canCommit();
39         assertEquals(Boolean.TRUE, getWithTimeout(canCommit));
40     }
41
42     @Test
43     public void testPreCommit() throws Exception {
44         final ListenableFuture<Void> preCommit = cohort.preCommit();
45         assertNull(getWithTimeout(preCommit));
46     }
47
48     @Test
49     public void testAbort() throws Exception {
50         final ListenableFuture<Void> abort = cohort.abort();
51         verify(history).onTransactionComplete(TRANSACTION_ID);
52         assertNull(getWithTimeout(abort));
53     }
54
55     @Test
56     public void testCommit() throws Exception {
57         final ListenableFuture<Void> commit = cohort.commit();
58         verify(history).onTransactionComplete(TRANSACTION_ID);
59         Assert.assertNull(getWithTimeout(commit));
60     }
61
62 }