Remove unused exceptions
[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 com.google.common.util.concurrent.FluentFuture;
11 import com.google.common.util.concurrent.Futures;
12 import java.util.Optional;
13 import org.junit.Assert;
14 import org.junit.Before;
15 import org.junit.Test;
16 import org.mockito.Mock;
17 import org.mockito.Mockito;
18 import org.mockito.MockitoAnnotations;
19 import org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction;
20 import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
21 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
22 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
23
24 public class ClientBackedReadWriteTransactionTest
25         extends ClientBackedTransactionTest<ClientBackedReadWriteTransaction> {
26     private ClientBackedReadWriteTransaction object;
27
28     @Mock
29     private ClientTransaction delegate;
30     @Mock
31     private NormalizedNode<?, ?> data;
32     @Mock
33     private DOMStoreThreePhaseCommitCohort readyCohort;
34
35     @Override
36     ClientBackedReadWriteTransaction object() {
37         return object;
38     }
39
40     @Before
41     public void setUp() {
42         MockitoAnnotations.initMocks(this);
43
44         Mockito.doReturn(TRANSACTION_ID).when(delegate).getIdentifier();
45         Mockito.doReturn(readyCohort).when(delegate).ready();
46
47         Mockito.doReturn(Futures.immediateCheckedFuture(Boolean.TRUE)).when(delegate)
48                 .exists(YangInstanceIdentifier.EMPTY);
49         Mockito.doReturn(Futures.immediateCheckedFuture(Optional.of(data))).when(delegate)
50                 .read(YangInstanceIdentifier.EMPTY);
51
52         object = new ClientBackedReadWriteTransaction(delegate, null);
53     }
54
55     @Test
56     public void testRead() throws Exception {
57         final FluentFuture<Optional<NormalizedNode<?, ?>>> result = object().read(YangInstanceIdentifier.EMPTY);
58         final Optional<NormalizedNode<?, ?>> resultData = result.get();
59         Assert.assertTrue(resultData.isPresent());
60         Assert.assertEquals(data, resultData.get());
61     }
62
63     @Test
64     public void testExists() throws Exception {
65         Assert.assertTrue(object().exists(YangInstanceIdentifier.EMPTY).get());
66     }
67 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.