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