Align tested boolean/Boolean expectations
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / databroker / ClientBackedReadTransactionTest.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.junit.Assert.assertTrue;
12 import static org.mockito.Mockito.doReturn;
13
14 import com.google.common.util.concurrent.Futures;
15 import com.google.common.util.concurrent.ListenableFuture;
16 import java.util.Optional;
17 import org.junit.Before;
18 import org.junit.Test;
19 import org.mockito.Mock;
20 import org.mockito.MockitoAnnotations;
21 import org.opendaylight.controller.cluster.access.client.ClientActorContext;
22 import org.opendaylight.controller.cluster.databroker.actors.dds.ClientSnapshot;
23 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
24 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
25
26 public class ClientBackedReadTransactionTest extends ClientBackedTransactionTest<ClientBackedReadTransaction> {
27     private ClientBackedReadTransaction object;
28
29     @Mock
30     private NormalizedNode<?, ?> data;
31     @Mock
32     private ClientActorContext clientContext;
33     @Mock
34     private ClientSnapshot delegate;
35
36     @Override
37     ClientBackedReadTransaction object() {
38         return object;
39     }
40
41     @Before
42     public void setUp() {
43         MockitoAnnotations.initMocks(this);
44
45         doReturn(CLIENT_ID).when(clientContext).getIdentifier();
46         doReturn(TRANSACTION_ID).when(delegate).getIdentifier();
47
48         doReturn(Futures.immediateCheckedFuture(Boolean.TRUE)).when(delegate).exists(YangInstanceIdentifier.EMPTY);
49         doReturn(Futures.immediateCheckedFuture(Optional.of(data))).when(delegate).read(YangInstanceIdentifier.EMPTY);
50
51         object = new ClientBackedReadTransaction(delegate, null, null);
52     }
53
54     @Test
55     public void testRead() throws Exception {
56         final ListenableFuture<Optional<NormalizedNode<?, ?>>> result = object().read(YangInstanceIdentifier.EMPTY);
57         final Optional<NormalizedNode<?, ?>> resultData = result.get();
58         assertTrue(resultData.isPresent());
59         assertEquals(data, resultData.get());
60     }
61
62     @Test
63     public void testExists() throws Exception {
64         final ListenableFuture<Boolean> result = object().exists(YangInstanceIdentifier.EMPTY);
65         assertEquals(Boolean.TRUE, result.get());
66     }
67 }