Fixup checkstyle
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / databroker / ClientBackedReadWriteTransactionTest.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;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.mockito.Mockito.doReturn;
12 import static org.opendaylight.yangtools.util.concurrent.FluentFutures.immediateFluentFuture;
13 import static org.opendaylight.yangtools.util.concurrent.FluentFutures.immediateTrueFluentFuture;
14
15 import java.util.Optional;
16 import org.junit.Before;
17 import org.junit.Test;
18 import org.junit.runner.RunWith;
19 import org.mockito.Mock;
20 import org.mockito.junit.MockitoJUnitRunner;
21 import org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction;
22 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
23 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
24
25 @RunWith(MockitoJUnitRunner.StrictStubs.class)
26 public class ClientBackedReadWriteTransactionTest
27         extends ClientBackedTransactionTest<ClientBackedReadWriteTransaction> {
28     private ClientBackedReadWriteTransaction object;
29
30     @Mock
31     private ClientTransaction delegate;
32     @Mock
33     private ContainerNode data;
34
35     @Override
36     ClientBackedReadWriteTransaction object() {
37         return object;
38     }
39
40     @Before
41     public void setUp() {
42         doReturn(TRANSACTION_ID).when(delegate).getIdentifier();
43
44         doReturn(immediateTrueFluentFuture()).when(delegate).exists(YangInstanceIdentifier.of());
45         doReturn(immediateFluentFuture(Optional.of(data))).when(delegate).read(YangInstanceIdentifier.of());
46
47         object = new ClientBackedReadWriteTransaction(delegate, null);
48     }
49
50     @Test
51     public void testRead() throws Exception {
52         assertEquals(Optional.of(data), object().read(YangInstanceIdentifier.of()).get());
53     }
54
55     @Test
56     public void testExists() throws Exception {
57         assertEquals(Boolean.TRUE, object().exists(YangInstanceIdentifier.of()).get());
58     }
59 }