2 * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
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
8 package org.opendaylight.controller.cluster.databroker.actors.dds;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
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;
16 import com.google.common.util.concurrent.ListenableFuture;
17 import org.junit.Before;
18 import org.junit.Test;
19 import org.junit.runner.RunWith;
20 import org.mockito.Mock;
21 import org.mockito.junit.MockitoJUnitRunner;
23 @RunWith(MockitoJUnitRunner.StrictStubs.class)
24 public class EmptyTransactionCommitCohortTest {
26 private AbstractClientHistory history;
28 private EmptyTransactionCommitCohort cohort;
32 cohort = new EmptyTransactionCommitCohort(history, TRANSACTION_ID);
36 public void testCanCommit() throws Exception {
37 final ListenableFuture<Boolean> canCommit = cohort.canCommit();
38 assertEquals(Boolean.TRUE, getWithTimeout(canCommit));
42 public void testPreCommit() throws Exception {
43 assertNotNull(getWithTimeout(cohort.preCommit()));
47 public void testAbort() throws Exception {
48 final ListenableFuture<?> abort = cohort.abort();
49 verify(history).onTransactionComplete(TRANSACTION_ID);
50 assertNotNull(getWithTimeout(abort));
54 public void testCommit() throws Exception {
55 final ListenableFuture<?> commit = cohort.commit();
56 verify(history).onTransactionComplete(TRANSACTION_ID);
57 assertNotNull(getWithTimeout(commit));