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;
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;
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;
25 @RunWith(MockitoJUnitRunner.StrictStubs.class)
26 public class ClientBackedReadWriteTransactionTest
27 extends ClientBackedTransactionTest<ClientBackedReadWriteTransaction> {
28 private ClientBackedReadWriteTransaction object;
31 private ClientTransaction delegate;
33 private ContainerNode data;
36 ClientBackedReadWriteTransaction object() {
42 doReturn(TRANSACTION_ID).when(delegate).getIdentifier();
44 doReturn(immediateTrueFluentFuture()).when(delegate).exists(YangInstanceIdentifier.of());
45 doReturn(immediateFluentFuture(Optional.of(data))).when(delegate).read(YangInstanceIdentifier.of());
47 object = new ClientBackedReadWriteTransaction(delegate, null);
51 public void testRead() throws Exception {
52 assertEquals(Optional.of(data), object().read(YangInstanceIdentifier.of()).get());
56 public void testExists() throws Exception {
57 assertEquals(Boolean.TRUE, object().exists(YangInstanceIdentifier.of()).get());