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.actors.dds;
10 import static org.mockito.Mockito.verify;
11 import static org.mockito.Mockito.when;
12 import static org.opendaylight.controller.cluster.databroker.actors.dds.TestUtils.getWithTimeout;
14 import com.google.common.util.concurrent.ListenableFuture;
15 import java.util.Optional;
16 import org.junit.Assert;
17 import org.junit.Before;
18 import org.junit.Test;
19 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
20 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
22 public class ClientSnapshotTest extends AbstractClientHandleTest<ClientSnapshot> {
24 private static final YangInstanceIdentifier PATH = YangInstanceIdentifier.EMPTY;
28 public void setUp() throws Exception {
30 when(getDataTreeSnapshot().readNode(PATH)).thenReturn(java.util.Optional.empty());
34 protected ClientSnapshot createHandle(final AbstractClientHistory parent) {
35 return parent.takeSnapshot();
39 protected void doHandleOperation(final ClientSnapshot snapshot) {
44 public void testExists() throws Exception {
45 final ListenableFuture<Boolean> exists = getHandle().exists(PATH);
46 verify(getDataTreeSnapshot()).readNode(PATH);
47 Assert.assertFalse(getWithTimeout(exists));
51 public void testRead() throws Exception {
52 final ListenableFuture<Optional<NormalizedNode<?, ?>>> exists = getHandle().read(PATH);
53 verify(getDataTreeSnapshot()).readNode(PATH);
54 Assert.assertFalse(getWithTimeout(exists).isPresent());