Bug 5947: Increasing code coverage - mdsal-dom-spi 93/40593/4
authorPeter Nosal <peter.nosal@pantheon.tech>
Tue, 21 Jun 2016 09:50:00 +0000 (11:50 +0200)
committerRobert Varga <nite@hq.sk>
Thu, 23 Jun 2016 12:45:19 +0000 (12:45 +0000)
Change-Id: Iac268bc99a5e48c083f6a67e7287a506d9431fb0
Signed-off-by: Peter Nosal <peter.nosal@pantheon.tech>
22 files changed:
dom/mdsal-dom-spi/pom.xml
dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/AbstractDOMDataTreeChangeListenerRegistrationTest.java [new file with mode: 0644]
dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/AbstractDOMRpcImplementationRegistrationTest.java [new file with mode: 0644]
dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/AbstractDOMRpcProviderServiceTest.java [new file with mode: 0644]
dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/AbstractRegistrationTreeTest.java [new file with mode: 0644]
dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/DOMDataTreePrefixTableEntryTest.java [new file with mode: 0644]
dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/DOMDataTreePrefixTableTest.java [new file with mode: 0644]
dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/DefaultDOMRpcResultTest.java [new file with mode: 0644]
dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/ForwardingDOMDataBrokerTest.java [new file with mode: 0644]
dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/ForwardingDOMDataReadOnlyTransactionTest.java [new file with mode: 0644]
dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/ForwardingDOMDataWriteTransactionTest.java [new file with mode: 0644]
dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/ForwardingDOMNotificationPublishServiceTest.java [new file with mode: 0644]
dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/ForwardingDOMNotificationServiceTest.java [new file with mode: 0644]
dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/ForwardingDOMRpcImplementationTest.java [new file with mode: 0644]
dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/ForwardingDOMRpcProviderServiceTest.java [new file with mode: 0644]
dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/ForwardingDOMRpcResultTest.java [new file with mode: 0644]
dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/ForwardingDOMRpcServiceTest.java [new file with mode: 0644]
dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/ForwardingDOMTransactionChainTest.java [new file with mode: 0644]
dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/RegistrationTreeNodeTest.java [new file with mode: 0644]
dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/RegistrationTreeSnapshotTest.java [new file with mode: 0644]
dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/RpcRoutingStrategyTest.java [new file with mode: 0644]
dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/SimpleDOMMountPointTest.java [new file with mode: 0644]

index 552d6bbe0c5def60c60d94b54208a7a0e8664995..465f80d77a3ddf7410c74ac43947a1e47cef6504 100644 (file)
@@ -6,7 +6,9 @@
     <artifactId>mdsal-dom</artifactId>
     <version>2.1.0-SNAPSHOT</version>
   </parent>
+
   <artifactId>mdsal-dom-spi</artifactId>
+
   <packaging>bundle</packaging>
 
   <dependencies>
       <groupId>org.opendaylight.mdsal</groupId>
       <artifactId>mdsal-dom-api</artifactId>
     </dependency>
+
+    <!-- Test Dependencies -->
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-simple</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.yangtools</groupId>
+      <artifactId>mockito-configuration</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <scm>
@@ -39,4 +58,4 @@
     </site>
   </distributionManagement>
 
-</project>
+</project>
\ No newline at end of file
diff --git a/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/AbstractDOMDataTreeChangeListenerRegistrationTest.java b/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/AbstractDOMDataTreeChangeListenerRegistrationTest.java
new file mode 100644 (file)
index 0000000..a31373b
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.dom.spi;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+
+import org.junit.Test;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
+
+public class AbstractDOMDataTreeChangeListenerRegistrationTest extends AbstractDOMDataTreeChangeListenerRegistration {
+
+    private static final DOMDataTreeChangeListener DOM_DATA_TREE_CHANGE_LISTENER =
+            mock(DOMDataTreeChangeListener.class);
+
+    @Test
+    public void basicTest() throws Exception {
+        AbstractDOMDataTreeChangeListenerRegistration abstractDOMDataTreeChangeListenerRegistration =
+                new AbstractDOMDataTreeChangeListenerRegistrationTest();
+        assertEquals(DOM_DATA_TREE_CHANGE_LISTENER, abstractDOMDataTreeChangeListenerRegistration.getInstance());
+    }
+
+    public AbstractDOMDataTreeChangeListenerRegistrationTest() {
+        super(DOM_DATA_TREE_CHANGE_LISTENER);
+    }
+
+    @Override
+    protected void removeRegistration() {
+        // NOOP
+    }
+}
\ No newline at end of file
diff --git a/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/AbstractDOMRpcImplementationRegistrationTest.java b/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/AbstractDOMRpcImplementationRegistrationTest.java
new file mode 100644 (file)
index 0000000..82ac101
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.dom.spi;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+
+import org.junit.Test;
+import org.opendaylight.mdsal.dom.api.DOMRpcImplementation;
+
+public class AbstractDOMRpcImplementationRegistrationTest extends AbstractDOMRpcImplementationRegistration {
+
+    private static final DOMRpcImplementation DOM_RPC_IMPLEMENTATION = mock(DOMRpcImplementation.class);
+
+    @Test
+    public void basicTest() throws Exception {
+        AbstractDOMRpcImplementationRegistration abstractDOMRpcImplementationRegistration =
+                new AbstractDOMRpcImplementationRegistrationTest();
+        assertEquals(DOM_RPC_IMPLEMENTATION, abstractDOMRpcImplementationRegistration.getInstance());
+    }
+
+    public AbstractDOMRpcImplementationRegistrationTest() {
+        super(DOM_RPC_IMPLEMENTATION);
+    }
+
+    @Override
+    protected void removeRegistration() {
+        // NOOP
+    }
+}
\ No newline at end of file
diff --git a/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/AbstractDOMRpcProviderServiceTest.java b/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/AbstractDOMRpcProviderServiceTest.java
new file mode 100644 (file)
index 0000000..27b087a
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.dom.spi;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import java.util.Set;
+import javax.annotation.Nonnull;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
+import org.opendaylight.mdsal.dom.api.DOMRpcImplementation;
+import org.opendaylight.mdsal.dom.api.DOMRpcImplementationRegistration;
+
+public class AbstractDOMRpcProviderServiceTest extends AbstractDOMRpcProviderService {
+
+    @Mock(name = "domRpcImplementationRegistration")
+    private DOMRpcImplementationRegistration domRpcImplementationRegistration;
+
+    @Test
+    public void registerRpcImplementation() throws Exception {
+        initMocks(this);
+        assertEquals(domRpcImplementationRegistration, this.registerRpcImplementation(null));
+    }
+
+    @Nonnull
+    @Override
+    public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation
+            (@Nonnull T implementation, @Nonnull Set<DOMRpcIdentifier> rpcs) {
+        return domRpcImplementationRegistration;
+    }
+}
\ No newline at end of file
diff --git a/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/AbstractRegistrationTreeTest.java b/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/AbstractRegistrationTreeTest.java
new file mode 100644 (file)
index 0000000..530359f
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.dom.spi;
+
+import static junit.framework.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.mock;
+
+import com.google.common.collect.ImmutableList;
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
+
+public class AbstractRegistrationTreeTest extends AbstractRegistrationTree<Object> {
+
+    @Test
+    public void basicTest() throws Exception {
+        final PathArgument pathArgument = mock(PathArgument.class);
+        final RegistrationTreeNode<Object> registrationTreeNodeParent = new RegistrationTreeNode<>(null, pathArgument);
+        final RegistrationTreeNode<Object> registrationTreeNode =
+                new RegistrationTreeNode<>(registrationTreeNodeParent, pathArgument);
+
+        final Object registration = new Object();
+        this.takeLock();
+        this.addRegistration(registrationTreeNode, registration);
+        assertTrue(registrationTreeNode.getRegistrations().contains(registration));
+
+        this.removeRegistration(registrationTreeNode, registration);
+        assertFalse(registrationTreeNode.getRegistrations().contains(registration));
+
+        assertNotNull(this.findNodeFor(ImmutableList.of(pathArgument)));
+        assertNotNull(this.takeSnapshot());
+    }
+
+    @Test(expected = IllegalMonitorStateException.class)
+    public void unlockTest() throws Exception {
+        this.releaseLock();
+    }
+}
\ No newline at end of file
diff --git a/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/DOMDataTreePrefixTableEntryTest.java b/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/DOMDataTreePrefixTableEntryTest.java
new file mode 100644 (file)
index 0000000..5e3438e
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.dom.spi;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.mockito.Mockito.mock;
+
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
+
+public class DOMDataTreePrefixTableEntryTest {
+
+    @Test
+    public void basicTest() throws Exception {
+        final DOMDataTreePrefixTableEntry<Object> domDataTreePrefixTableEntry = new DOMDataTreePrefixTableEntry<>();
+        final PathArgument pathArgument = mock(PathArgument.class);
+        final Object testObject = new Object();
+        final YangInstanceIdentifier yangInstanceIdentifier = YangInstanceIdentifier.of(QName.create("test"));
+
+        assertEquals(pathArgument, new DOMDataTreePrefixTableEntry(pathArgument).getIdentifier());
+        domDataTreePrefixTableEntry.store(yangInstanceIdentifier, testObject);
+        assertEquals(QName.create("test"),
+                domDataTreePrefixTableEntry.lookup(yangInstanceIdentifier).getIdentifier().getNodeType());
+        domDataTreePrefixTableEntry.remove(yangInstanceIdentifier);
+        domDataTreePrefixTableEntry.remove(yangInstanceIdentifier);
+        assertNull(domDataTreePrefixTableEntry.lookup(yangInstanceIdentifier).getIdentifier());
+    }
+}
\ No newline at end of file
diff --git a/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/DOMDataTreePrefixTableTest.java b/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/DOMDataTreePrefixTableTest.java
new file mode 100644 (file)
index 0000000..2df469b
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.dom.spi;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Test;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+
+public class DOMDataTreePrefixTableTest {
+
+    @Test
+    public void basicTest() throws Exception {
+        final DOMDataTreePrefixTable<Object> domDataTreePrefixTable = DOMDataTreePrefixTable.create();
+        final Object testObject = new Object();
+        final YangInstanceIdentifier yangInstanceIdentifier = YangInstanceIdentifier.of(QName.create("test"));
+        final DOMDataTreeIdentifier domDataTreeIdentifier =
+                new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, yangInstanceIdentifier);
+
+        domDataTreePrefixTable.store(domDataTreeIdentifier, testObject);
+        assertEquals(QName.create("test"),
+                domDataTreePrefixTable.lookup(domDataTreeIdentifier).getIdentifier().getNodeType());
+        domDataTreePrefixTable.remove(domDataTreeIdentifier);
+        assertNull(domDataTreePrefixTable.lookup(domDataTreeIdentifier).getIdentifier());
+
+        final DOMDataTreeIdentifier invalidDOMDataTreeIdentifier =
+                new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, yangInstanceIdentifier);
+        domDataTreePrefixTable.remove(invalidDOMDataTreeIdentifier);
+        assertNull(domDataTreePrefixTable.lookup(invalidDOMDataTreeIdentifier));
+    }
+}
\ No newline at end of file
diff --git a/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/DefaultDOMRpcResultTest.java b/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/DefaultDOMRpcResultTest.java
new file mode 100644 (file)
index 0000000..b98a884
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.dom.spi;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+
+import java.util.Collections;
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.common.RpcError;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+
+public class DefaultDOMRpcResultTest {
+
+    @Test
+    public void basicTest() throws Exception {
+        RpcError rpcError = mock(RpcError.class);
+        NormalizedNode normalizedNode = mock(NormalizedNode.class);
+        DefaultDOMRpcResult defaultDOMRpcResult = new DefaultDOMRpcResult(normalizedNode, rpcError);
+        assertEquals(normalizedNode, defaultDOMRpcResult.getResult());
+        assertTrue(defaultDOMRpcResult.getErrors().contains(rpcError));
+        assertTrue(new DefaultDOMRpcResult(normalizedNode).getErrors().isEmpty());
+        assertTrue(new DefaultDOMRpcResult().getErrors().isEmpty());
+        assertTrue(new DefaultDOMRpcResult(Collections.EMPTY_LIST).getErrors().isEmpty());
+        assertEquals(defaultDOMRpcResult.hashCode(), new DefaultDOMRpcResult(normalizedNode, rpcError).hashCode());
+        assertTrue(new DefaultDOMRpcResult(normalizedNode, rpcError).equals(defaultDOMRpcResult));
+        assertTrue(defaultDOMRpcResult.equals(defaultDOMRpcResult));
+        assertFalse(defaultDOMRpcResult.equals("test"));
+        assertFalse(defaultDOMRpcResult.equals(new DefaultDOMRpcResult()));
+    }
+}
\ No newline at end of file
diff --git a/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/ForwardingDOMDataBrokerTest.java b/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/ForwardingDOMDataBrokerTest.java
new file mode 100644 (file)
index 0000000..ec721bc
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.dom.spi;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import javax.annotation.Nonnull;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.opendaylight.mdsal.dom.api.DOMDataBroker;
+
+public class ForwardingDOMDataBrokerTest extends ForwardingDOMDataBroker {
+
+    @Mock(name = "domDataBroker")
+    private DOMDataBroker domDataBroker;
+
+    @Test
+    public void basicTest() throws Exception {
+        initMocks(this);
+
+        Mockito.doReturn(null).when(domDataBroker).createTransactionChain(any());
+        this.createTransactionChain(null);
+        verify(domDataBroker).createTransactionChain(any());
+
+        doReturn(null).when(domDataBroker).getSupportedExtensions();
+        this.getSupportedExtensions();
+        verify(domDataBroker).getSupportedExtensions();
+
+        doReturn(null).when(domDataBroker).newReadOnlyTransaction();
+        this.newReadOnlyTransaction();
+        verify(domDataBroker).newReadOnlyTransaction();
+
+        doReturn(null).when(domDataBroker).newWriteOnlyTransaction();
+        this.newWriteOnlyTransaction();
+        verify(domDataBroker).newWriteOnlyTransaction();
+    }
+
+    @Nonnull
+    @Override
+    protected DOMDataBroker delegate() {
+        return domDataBroker;
+    }
+}
\ No newline at end of file
diff --git a/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/ForwardingDOMDataReadOnlyTransactionTest.java b/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/ForwardingDOMDataReadOnlyTransactionTest.java
new file mode 100644 (file)
index 0000000..8988c85
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.dom.spi;
+
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import javax.annotation.Nonnull;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
+
+public class ForwardingDOMDataReadOnlyTransactionTest extends ForwardingDOMDataReadOnlyTransaction {
+
+    @Mock(name = "domDataTreeReadTransaction")
+    private DOMDataTreeReadTransaction domDataTreeReadTransaction;
+
+    @Test
+    public void basicTest() throws Exception {
+        initMocks(this);
+
+        doReturn(null).when(domDataTreeReadTransaction).read(null, null);
+        this.read(null, null);
+        verify(domDataTreeReadTransaction).read(null, null);
+
+        doReturn(null).when(domDataTreeReadTransaction).exists(null, null);
+        this.exists(null, null);
+        verify(domDataTreeReadTransaction).exists(null, null);
+
+        doReturn(null).when(domDataTreeReadTransaction).getIdentifier();
+        this.getIdentifier();
+        verify(domDataTreeReadTransaction).getIdentifier();
+
+        doNothing().when(domDataTreeReadTransaction).close();
+        this.close();
+        verify(domDataTreeReadTransaction).close();
+    }
+
+    @Nonnull
+    @Override
+    protected DOMDataTreeReadTransaction delegate() {
+        return domDataTreeReadTransaction;
+    }
+}
\ No newline at end of file
diff --git a/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/ForwardingDOMDataWriteTransactionTest.java b/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/ForwardingDOMDataWriteTransactionTest.java
new file mode 100644 (file)
index 0000000..74f1fe8
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.dom.spi;
+
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import javax.annotation.Nonnull;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
+
+public class ForwardingDOMDataWriteTransactionTest extends ForwardingDOMDataWriteTransaction {
+
+    @Mock(name = "domDataTreeWriteTransaction")
+    private DOMDataTreeWriteTransaction domDataTreeWriteTransaction;
+
+    @Test
+    public void basicTest() throws Exception {
+        initMocks(this);
+
+        doReturn(null).when(domDataTreeWriteTransaction).getIdentifier();
+        this.getIdentifier();
+        verify(domDataTreeWriteTransaction).getIdentifier();
+
+        doNothing().when(domDataTreeWriteTransaction).put(null, null, null);
+        this.put(null, null, null);
+        verify(domDataTreeWriteTransaction).put(null, null, null);
+
+        doNothing().when(domDataTreeWriteTransaction).merge(null, null, null);
+        this.merge(null, null, null);
+        verify(domDataTreeWriteTransaction).merge(null, null, null);
+
+        doNothing().when(domDataTreeWriteTransaction).delete(null, null);
+        this.delete(null, null);
+        verify(domDataTreeWriteTransaction).delete(null, null);
+
+        doReturn(null).when(domDataTreeWriteTransaction).submit();
+        this.submit();
+        verify(domDataTreeWriteTransaction).submit();
+
+        doReturn(false).when(domDataTreeWriteTransaction).cancel();
+        this.cancel();
+        verify(domDataTreeWriteTransaction).cancel();
+    }
+
+    @Nonnull
+    @Override
+    protected DOMDataTreeWriteTransaction delegate() {
+        return domDataTreeWriteTransaction;
+    }
+}
\ No newline at end of file
diff --git a/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/ForwardingDOMNotificationPublishServiceTest.java b/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/ForwardingDOMNotificationPublishServiceTest.java
new file mode 100644 (file)
index 0000000..a30f123
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.dom.spi;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import java.util.concurrent.TimeUnit;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.mdsal.dom.api.DOMNotification;
+import org.opendaylight.mdsal.dom.api.DOMNotificationPublishService;
+
+public class ForwardingDOMNotificationPublishServiceTest extends ForwardingDOMNotificationPublishService {
+
+    @Mock(name = "domNotificationPublishService")
+    private DOMNotificationPublishService domNotificationPublishService;
+
+    @Test
+    public void basicTest() throws Exception {
+        initMocks(this);
+
+        final DOMNotification domNotification = mock(DOMNotification.class);
+
+        doReturn(null).when(domNotificationPublishService).putNotification(domNotification);
+        this.putNotification(domNotification);
+        verify(domNotificationPublishService).putNotification(domNotification);
+
+        doReturn(null).when(domNotificationPublishService).offerNotification(domNotification);
+        this.offerNotification(domNotification);
+        verify(domNotificationPublishService).offerNotification(domNotification);
+
+        doReturn(null).when(domNotificationPublishService).offerNotification(domNotification, 1, TimeUnit.MILLISECONDS);
+        this.offerNotification(domNotification, 1, TimeUnit.MILLISECONDS);
+        verify(domNotificationPublishService).offerNotification(domNotification, 1, TimeUnit.MILLISECONDS);
+    }
+
+    @Override
+    protected DOMNotificationPublishService delegate() {
+        return domNotificationPublishService;
+    }
+}
\ No newline at end of file
diff --git a/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/ForwardingDOMNotificationServiceTest.java b/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/ForwardingDOMNotificationServiceTest.java
new file mode 100644 (file)
index 0000000..feebbe0
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.dom.spi;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import java.util.Collections;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.mdsal.dom.api.DOMNotificationListener;
+import org.opendaylight.mdsal.dom.api.DOMNotificationService;
+
+public class ForwardingDOMNotificationServiceTest extends ForwardingDOMNotificationService {
+
+    @Mock(name = "domNotificationService")
+    private DOMNotificationService domNotificationService;
+
+    @Test
+    public void basicTest() throws Exception {
+        initMocks(this);
+
+        final DOMNotificationListener domNotificationListener = mock(DOMNotificationListener.class);
+
+        doReturn(null).when(domNotificationService).registerNotificationListener(domNotificationListener);
+        this.registerNotificationListener(domNotificationListener);
+        verify(domNotificationService).registerNotificationListener(domNotificationListener);
+
+        doReturn(null).when(domNotificationService).registerNotificationListener(domNotificationListener,
+                Collections.EMPTY_SET);
+        this.registerNotificationListener(domNotificationListener, Collections.EMPTY_SET);
+        verify(domNotificationService).registerNotificationListener(domNotificationListener, Collections.EMPTY_SET);
+    }
+
+    @Override
+    protected DOMNotificationService delegate() {
+        return domNotificationService;
+    }
+}
\ No newline at end of file
diff --git a/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/ForwardingDOMRpcImplementationTest.java b/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/ForwardingDOMRpcImplementationTest.java
new file mode 100644 (file)
index 0000000..f33e843
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.dom.spi;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import javax.annotation.Nonnull;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
+import org.opendaylight.mdsal.dom.api.DOMRpcImplementation;
+
+public class ForwardingDOMRpcImplementationTest extends ForwardingDOMRpcImplementation {
+
+    @Mock(name = "domRpcImplementation")
+    private DOMRpcImplementation domRpcImplementation;
+
+    @Test
+    public void basicTest() throws Exception {
+        initMocks(this);
+
+        final DOMRpcIdentifier domRpcIdentifier = mock(DOMRpcIdentifier.class);
+
+        doReturn(null).when(domRpcImplementation).invokeRpc(domRpcIdentifier, null);
+        this.invokeRpc(domRpcIdentifier, null);
+        verify(domRpcImplementation).invokeRpc(domRpcIdentifier, null);
+    }
+
+    @Nonnull
+    @Override
+    protected DOMRpcImplementation delegate() {
+        return domRpcImplementation;
+    }
+}
\ No newline at end of file
diff --git a/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/ForwardingDOMRpcProviderServiceTest.java b/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/ForwardingDOMRpcProviderServiceTest.java
new file mode 100644 (file)
index 0000000..11f9d83
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.dom.spi;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import java.util.Collections;
+import javax.annotation.Nonnull;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.mdsal.dom.api.DOMRpcImplementation;
+import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
+
+public class ForwardingDOMRpcProviderServiceTest extends ForwardingDOMRpcProviderService {
+
+    @Mock(name = "domRpcProviderService")
+    private DOMRpcProviderService domRpcProviderService;
+
+    @Test
+    public void basicTest() throws Exception {
+        initMocks(this);
+
+        final DOMRpcImplementation domRpcImplementation = mock(DOMRpcImplementation.class);
+
+        doReturn(null).when(domRpcProviderService).registerRpcImplementation(domRpcImplementation);
+        this.registerRpcImplementation(domRpcImplementation);
+        verify(domRpcProviderService).registerRpcImplementation(domRpcImplementation);
+
+        doReturn(null).when(domRpcProviderService).registerRpcImplementation(domRpcImplementation,
+                Collections.EMPTY_SET);
+        this.registerRpcImplementation(domRpcImplementation, Collections.EMPTY_SET);
+        verify(domRpcProviderService).registerRpcImplementation(domRpcImplementation, Collections.EMPTY_SET);
+    }
+
+    @Nonnull
+    @Override
+    protected DOMRpcProviderService delegate() {
+        return domRpcProviderService;
+    }
+}
\ No newline at end of file
diff --git a/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/ForwardingDOMRpcResultTest.java b/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/ForwardingDOMRpcResultTest.java
new file mode 100644 (file)
index 0000000..85cf8a0
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.dom.spi;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import javax.annotation.Nonnull;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.mdsal.dom.api.DOMRpcResult;
+
+public class ForwardingDOMRpcResultTest extends ForwardingDOMRpcResult {
+
+    @Mock(name = "domRpcResult")
+    private DOMRpcResult domRpcResult;
+
+    @Test
+    public void basicTest() throws Exception {
+        initMocks(this);
+
+        doReturn(null).when(domRpcResult).getErrors();
+        this.getErrors();
+        verify(domRpcResult).getErrors();
+
+        doReturn(null).when(domRpcResult).getResult();
+        this.getResult();
+        verify(domRpcResult).getResult();
+    }
+
+    @Nonnull
+    @Override
+    protected DOMRpcResult delegate() {
+        return domRpcResult;
+    }
+}
\ No newline at end of file
diff --git a/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/ForwardingDOMRpcServiceTest.java b/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/ForwardingDOMRpcServiceTest.java
new file mode 100644 (file)
index 0000000..8e43ec7
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.dom.spi;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import javax.annotation.Nonnull;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.mdsal.dom.api.DOMRpcAvailabilityListener;
+import org.opendaylight.mdsal.dom.api.DOMRpcService;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+
+public class ForwardingDOMRpcServiceTest extends ForwardingDOMRpcService {
+
+    @Mock(name = "domRpcService")
+    private DOMRpcService domRpcService;
+
+    @Test
+    public void basicTest() throws Exception {
+        initMocks(this);
+
+        final DOMRpcAvailabilityListener domRpcAvailabilityListener = mock(DOMRpcAvailabilityListener.class);
+
+        doReturn(null).when(domRpcService).invokeRpc(SchemaPath.SAME, null);
+        this.invokeRpc(SchemaPath.SAME, null);
+        verify(domRpcService).invokeRpc(SchemaPath.SAME, null);
+
+        doReturn(null).when(domRpcService).registerRpcListener(domRpcAvailabilityListener);
+        this.registerRpcListener(domRpcAvailabilityListener);
+        verify(domRpcService).registerRpcListener(domRpcAvailabilityListener);
+    }
+
+    @Nonnull
+    @Override
+    protected DOMRpcService delegate() {
+        return domRpcService;
+    }
+}
\ No newline at end of file
diff --git a/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/ForwardingDOMTransactionChainTest.java b/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/ForwardingDOMTransactionChainTest.java
new file mode 100644 (file)
index 0000000..82ab02e
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.dom.spi;
+
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import javax.annotation.Nonnull;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
+
+public class ForwardingDOMTransactionChainTest extends ForwardingDOMTransactionChain {
+
+    @Mock(name = "domTransactionChain")
+    private DOMTransactionChain domTransactionChain;
+
+    @Test
+    public void basicTest() throws Exception {
+        initMocks(this);
+
+        doReturn(null).when(domTransactionChain).newWriteOnlyTransaction();
+        this.newWriteOnlyTransaction();
+        verify(domTransactionChain).newWriteOnlyTransaction();
+
+        doReturn(null).when(domTransactionChain).newReadOnlyTransaction();
+        this.newReadOnlyTransaction();
+        verify(domTransactionChain).newReadOnlyTransaction();
+
+        doNothing().when(domTransactionChain).close();
+        this.close();
+        verify(domTransactionChain).close();
+    }
+
+    @Nonnull
+    @Override
+    protected DOMTransactionChain delegate() {
+        return domTransactionChain;
+    }
+}
\ No newline at end of file
diff --git a/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/RegistrationTreeNodeTest.java b/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/RegistrationTreeNodeTest.java
new file mode 100644 (file)
index 0000000..c6a4926
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.dom.spi;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertTrue;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+
+import java.util.Collections;
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
+
+public class RegistrationTreeNodeTest {
+
+    @Test
+    public void basicTest() throws Exception {
+        final PathArgument pathArgument = mock(PathArgument.class);
+        final RegistrationTreeNode<Object> registrationTreeNodeParent = new RegistrationTreeNode<>(null, pathArgument);
+        final RegistrationTreeNode<Object> registrationTreeNode =
+                new RegistrationTreeNode<>(registrationTreeNodeParent, pathArgument);
+
+        assertEquals(pathArgument, registrationTreeNode.getIdentifier());
+
+        final Object registration = new Object();
+        assertFalse(registrationTreeNode.getRegistrations().contains(registration));
+        registrationTreeNode.addRegistration(registration);
+        assertTrue(registrationTreeNode.getRegistrations().contains(registration));
+        registrationTreeNode.removeRegistration(registration);
+        assertFalse(registrationTreeNode.getRegistrations().contains(registration));
+        registrationTreeNode.removeRegistration(registration);
+
+        assertNotNull(registrationTreeNode.ensureChild(pathArgument));
+        assertNotNull(registrationTreeNode.getExactChild(pathArgument));
+
+        final NodeWithValue nodeWithValue = new NodeWithValue<>(QName.create("testNode"), new Object());
+        assertEquals(Collections.EMPTY_LIST, registrationTreeNode.getInexactChildren(nodeWithValue));
+        assertEquals(Collections.EMPTY_LIST, registrationTreeNode.getInexactChildren(pathArgument));
+
+        final NodeIdentifier nodeWithoutValue = new NodeIdentifier(QName.create("testNode"));
+        assertNotNull(registrationTreeNode.ensureChild(nodeWithoutValue));
+        assertFalse(registrationTreeNode.getInexactChildren(nodeWithValue).isEmpty());
+
+        doReturn("TestPathArgument").when(pathArgument).toString();
+        assertNotNull(registrationTreeNode.toString());
+        assertTrue(registrationTreeNode.toString().contains(pathArgument.toString()));
+    }
+}
\ No newline at end of file
diff --git a/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/RegistrationTreeSnapshotTest.java b/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/RegistrationTreeSnapshotTest.java
new file mode 100644 (file)
index 0000000..99b8069
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.dom.spi;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+import java.util.concurrent.locks.Lock;
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
+
+public class RegistrationTreeSnapshotTest {
+
+    @Test
+    public void basicTest() throws Exception {
+        final Lock lock = mock(Lock.class);
+        final PathArgument pathArgument = mock(PathArgument.class);
+        final RegistrationTreeNode registrationTreeNode = new RegistrationTreeNode(null, pathArgument);
+        final RegistrationTreeSnapshot registrationTreeSnapshot =
+                new RegistrationTreeSnapshot(lock, registrationTreeNode);
+
+        assertNotNull(registrationTreeSnapshot.getRootNode());
+        assertEquals(registrationTreeNode, registrationTreeSnapshot.getRootNode());
+
+        doNothing().when(lock).unlock();
+        registrationTreeSnapshot.close();
+        verify(lock).unlock();
+    }
+}
\ No newline at end of file
diff --git a/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/RpcRoutingStrategyTest.java b/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/RpcRoutingStrategyTest.java
new file mode 100644 (file)
index 0000000..c0ee5ac
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.dom.spi;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.reset;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import java.lang.reflect.Field;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+
+public class RpcRoutingStrategyTest {
+
+    private static RpcRoutingStrategy rpcRoutingStrategy;
+    private static final QName Q_NAME = QName.create("testQname");
+    private static final RpcDefinition RPC_DEFINITION = mock(RpcDefinition.class);
+    private static final DataSchemaNode DATA_SCHEMA_NODE = mock(DataSchemaNode.class);
+    private static final UnknownSchemaNode UNKNOWN_SCHEMA_NODE = mock(UnknownSchemaNode.class);
+
+    @Before
+    public void setUp() throws Exception {
+        final ContainerSchemaNode containerSchemaNode = mock(ContainerSchemaNode.class);
+
+        doReturn(containerSchemaNode).when(RPC_DEFINITION).getInput();
+        doReturn(ImmutableSet.of(DATA_SCHEMA_NODE)).when(containerSchemaNode).getChildNodes();
+        doReturn(ImmutableList.of(UNKNOWN_SCHEMA_NODE)).when(DATA_SCHEMA_NODE).getUnknownSchemaNodes();
+        doReturn(QName.create("testNode")).when(UNKNOWN_SCHEMA_NODE).getNodeType();
+        doReturn(Q_NAME).when(RPC_DEFINITION).getQName();
+
+        rpcRoutingStrategy = RpcRoutingStrategy.from(RPC_DEFINITION);
+        assertNotNull(rpcRoutingStrategy);
+
+        assertEquals(Q_NAME, rpcRoutingStrategy.getIdentifier());
+        assertFalse(rpcRoutingStrategy.isContextBasedRouted());
+    }
+
+    @Test()
+    public void routedRpcStrategyTest() throws Exception {
+        final Field contextReferenceField = RpcRoutingStrategy.class.getDeclaredField("CONTEXT_REFERENCE");
+        contextReferenceField.setAccessible(true);
+
+        final QName contextReference = (QName) contextReferenceField.get(rpcRoutingStrategy);
+
+        reset(UNKNOWN_SCHEMA_NODE);
+        doReturn(contextReference).when(UNKNOWN_SCHEMA_NODE).getNodeType();
+        doReturn(Q_NAME).when(UNKNOWN_SCHEMA_NODE).getQName();
+        doReturn(Q_NAME).when(DATA_SCHEMA_NODE).getQName();
+        rpcRoutingStrategy = RpcRoutingStrategy.from(RPC_DEFINITION);
+
+        assertNotNull(rpcRoutingStrategy);
+
+        assertTrue(rpcRoutingStrategy.isContextBasedRouted());
+        assertEquals(Q_NAME, rpcRoutingStrategy.getContext());
+        assertEquals(Q_NAME, rpcRoutingStrategy.getLeaf());
+    }
+
+    @Test(expected = UnsupportedOperationException.class)
+    public void getLeafTest() throws Exception {
+        rpcRoutingStrategy.getLeaf();
+    }
+
+    @Test(expected = UnsupportedOperationException.class)
+    public void getContextTest() throws Exception {
+        rpcRoutingStrategy.getContext();
+    }
+}
\ No newline at end of file
diff --git a/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/SimpleDOMMountPointTest.java b/dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/SimpleDOMMountPointTest.java
new file mode 100644 (file)
index 0000000..d08a2d8
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.dom.spi;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+
+import com.google.common.collect.ClassToInstanceMap;
+import com.google.common.collect.ImmutableClassToInstanceMap;
+import org.junit.Test;
+import org.opendaylight.mdsal.dom.api.DOMService;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+
+public class SimpleDOMMountPointTest {
+
+    @Test
+    public void basicTest() throws Exception {
+        final YangInstanceIdentifier yangInstanceIdentifier = mock(YangInstanceIdentifier.class);
+        final SchemaContext schemaContext = mock(SchemaContext.class);
+        final DOMService domService = mock(DOMService.class);
+        final ClassToInstanceMap classToInstanceMap =
+                ImmutableClassToInstanceMap.builder().put(DOMService.class, domService).build();
+
+        final SimpleDOMMountPoint simpleDOMMountPoint =
+                SimpleDOMMountPoint.create(yangInstanceIdentifier, classToInstanceMap, schemaContext);
+
+        assertNotNull(simpleDOMMountPoint);
+
+        assertEquals(yangInstanceIdentifier, simpleDOMMountPoint.getIdentifier());
+        assertEquals(schemaContext, simpleDOMMountPoint.getSchemaContext());
+
+        assertTrue(simpleDOMMountPoint.getService(DOMService.class).isPresent());
+        assertEquals(domService, simpleDOMMountPoint.getService(DOMService.class).get());
+    }
+}
\ No newline at end of file