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.assertNotNull;
12 import static org.mockito.Mockito.doNothing;
13 import static org.mockito.Mockito.doReturn;
14 import static org.mockito.Mockito.verify;
16 import java.util.HashMap;
18 import org.junit.After;
19 import org.junit.Assert;
20 import org.junit.Test;
21 import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor;
22 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
24 public class WriteableNodeWithSubshardTest {
27 public void basicTest() throws Exception {
28 doReturn("test").when(TestUtils.WRITEABLE_MODIFICATION_NODE).toString();
29 doNothing().when(TestUtils.WRITEABLE_MODIFICATION_NODE).markDeleted();
31 final Map<PathArgument, WriteableModificationNode> children = new HashMap<>();
32 children.put(TestUtils.NODE_IDENTIFIER, TestUtils.WRITEABLE_MODIFICATION_NODE);
34 final WriteableNodeWithSubshard writeableNodeWithSubshard = new WriteableNodeWithSubshardImpl(children);
36 assertEquals(writeableNodeWithSubshard.getChildrenWithSubshards(), children);
38 final WriteableModificationNode TestWriteableModificationNode =
39 writeableNodeWithSubshard.getChild(TestUtils.NODE_IDENTIFIER);
40 assertNotNull(TestWriteableModificationNode);
41 Assert.assertEquals(TestWriteableModificationNode, TestUtils.WRITEABLE_MODIFICATION_NODE);
43 writeableNodeWithSubshard.markDeleted();
44 verify(TestUtils.WRITEABLE_MODIFICATION_NODE).markDeleted();
49 TestUtils.resetMocks();
52 private static final class WriteableNodeWithSubshardImpl extends WriteableNodeWithSubshard {
54 WriteableNodeWithSubshardImpl(final Map<PathArgument, WriteableModificationNode> children) {
59 public WriteCursorStrategy createOperation(final DOMDataTreeWriteCursor parentCursor) {
64 public PathArgument getIdentifier() {
65 throw new UnsupportedOperationException();