2 * Copyright (c) 2016 Cisco Systems, Inc. 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.mdsal.dom.spi.shard;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertFalse;
12 import static org.mockito.Mockito.doNothing;
13 import static org.mockito.Mockito.doReturn;
14 import static org.mockito.Mockito.mock;
15 import static org.mockito.Mockito.verify;
17 import java.util.Optional;
18 import org.junit.After;
19 import org.junit.Test;
20 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
21 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshotCursor;
23 public class DelegatingReadableCursorOperationTest extends DelegatingReadableCursorOperation {
25 private static final DataTreeSnapshotCursor MOCK_CURSOR_SNAPSHOT = mock(DataTreeSnapshotCursor.class);
28 public void basicTest() throws Exception {
29 final Optional<NormalizedNode<?, ?>> nodeOptional = Optional.empty();
30 doReturn(nodeOptional).when(MOCK_CURSOR_SNAPSHOT).readNode(TestUtils.PATH_ARGUMENT);
31 doNothing().when(MOCK_CURSOR_SNAPSHOT).exit();
32 doNothing().when(MOCK_CURSOR_SNAPSHOT).enter(TestUtils.PATH_ARGUMENT);
33 doReturn("test").when(TestUtils.PATH_ARGUMENT).toString();
35 assertFalse(readNode(TestUtils.PATH_ARGUMENT).isPresent());
36 verify(MOCK_CURSOR_SNAPSHOT).readNode(TestUtils.PATH_ARGUMENT);
39 verify(MOCK_CURSOR_SNAPSHOT).exit();
41 assertEquals(this, enter(TestUtils.PATH_ARGUMENT));
42 verify(MOCK_CURSOR_SNAPSHOT).enter(TestUtils.PATH_ARGUMENT);
46 protected DataTreeSnapshotCursor delegate() {
47 return MOCK_CURSOR_SNAPSHOT;
52 TestUtils.resetMocks();