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.store.inmemory;
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;
15 import static org.opendaylight.mdsal.dom.store.inmemory.TestUtils.NODE_IDENTIFIER;
16 import static org.opendaylight.mdsal.dom.store.inmemory.TestUtils.WRITEABLE_MODIFICATION_NODE;
17 import static org.opendaylight.mdsal.dom.store.inmemory.TestUtils.resetMocks;
19 import java.util.HashMap;
21 import org.junit.After;
22 import org.junit.Test;
23 import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor;
24 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
26 public class WriteableNodeWithSubshardTest {
29 public void basicTest() throws Exception {
30 doReturn("test").when(WRITEABLE_MODIFICATION_NODE).toString();
31 doNothing().when(WRITEABLE_MODIFICATION_NODE).markDeleted();
33 final Map<PathArgument, WriteableModificationNode> children = new HashMap<>();
34 children.put(NODE_IDENTIFIER, WRITEABLE_MODIFICATION_NODE);
36 final WriteableNodeWithSubshard writeableNodeWithSubshard = new WriteableNodeWithSubshardImpl(children);
38 assertEquals(writeableNodeWithSubshard.getChildrenWithSubshards(), children);
40 final WriteableModificationNode TestWriteableModificationNode =
41 writeableNodeWithSubshard.getChild(NODE_IDENTIFIER);
42 assertNotNull(TestWriteableModificationNode);
43 assertEquals(TestWriteableModificationNode, WRITEABLE_MODIFICATION_NODE);
45 writeableNodeWithSubshard.markDeleted();
46 verify(WRITEABLE_MODIFICATION_NODE).markDeleted();
54 private class WriteableNodeWithSubshardImpl extends WriteableNodeWithSubshard {
56 private WriteableNodeWithSubshardImpl(Map<PathArgument, WriteableModificationNode> children) {
61 WriteCursorStrategy createOperation(DOMDataTreeWriteCursor parentCursor) {
66 public PathArgument getIdentifier() {