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.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;
26 @RunWith(MockitoJUnitRunner.StrictStubs.class)
27 public class ClientBackedReadTransactionTest extends ClientBackedTransactionTest<ClientBackedReadTransaction> {
28 private ClientBackedReadTransaction object;
31 private NormalizedNode data;
33 private ClientActorContext clientContext;
35 private ClientSnapshot delegate;
38 ClientBackedReadTransaction object() {
44 doReturn(TRANSACTION_ID).when(delegate).getIdentifier();
46 doReturn(immediateTrueFluentFuture()).when(delegate).exists(YangInstanceIdentifier.empty());
47 doReturn(immediateFluentFuture(Optional.of(data))).when(delegate).read(YangInstanceIdentifier.empty());
49 object = new ClientBackedReadTransaction(delegate, null, null);
53 public void testRead() throws Exception {
54 assertEquals(Optional.of(data), object().read(YangInstanceIdentifier.empty()).get());
58 public void testExists() throws Exception {
59 assertEquals(Boolean.TRUE, object().exists(YangInstanceIdentifier.empty()).get());