FailedDataTreeModification JUnit test 01/53601/3
authormatus.kubica <matus.kubica@pantheon.tech>
Tue, 21 Mar 2017 11:35:40 +0000 (12:35 +0100)
committerIvan Hrasko <ivan.hrasko@pantheon.tech>
Thu, 30 Mar 2017 06:00:09 +0000 (08:00 +0200)
Change-Id: Icac1405b8a17ce18119fbefb55e71898dc90082f
Signed-off-by: matus.kubica <matus.kubica@pantheon.tech>
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/FailedDataTreeModificationTest.java [new file with mode: 0644]

diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/FailedDataTreeModificationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/FailedDataTreeModificationTest.java
new file mode 100644 (file)
index 0000000..da7f9dc
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.controller.cluster.databroker.actors.dds;
+
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import java.util.function.Supplier;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModificationCursor;
+
+public class FailedDataTreeModificationTest {
+
+    private FailedDataTreeModification failedDataTreeModification;
+
+    @Mock
+    private YangInstanceIdentifier instanceIdentifier;
+    @Mock
+    private NormalizedNode normalizedNode;
+    @Mock
+    private DataTreeModificationCursor dataTreeModificationCursor;
+
+    @Before
+    public void setUp() throws Exception {
+        initMocks(this);
+        final Supplier supplier = () -> new RuntimeException("Operation failed.");
+        failedDataTreeModification = new FailedDataTreeModification(supplier);
+    }
+
+    @Test(expected = RuntimeException.class)
+    public void testReadNode() throws Exception {
+        failedDataTreeModification.readNode(instanceIdentifier);
+    }
+
+    @Test(expected = RuntimeException.class)
+    public void testNewModification() throws Exception {
+        failedDataTreeModification.newModification();
+    }
+
+    @Test(expected = RuntimeException.class)
+    public void testDelete() throws Exception {
+        failedDataTreeModification.delete(instanceIdentifier);
+    }
+
+    @Test(expected = RuntimeException.class)
+    public void testMerge() throws Exception {
+        failedDataTreeModification.merge(instanceIdentifier, normalizedNode);
+    }
+
+    @Test(expected = RuntimeException.class)
+    public void testWrite() throws Exception {
+        failedDataTreeModification.write(instanceIdentifier, normalizedNode);
+    }
+
+    @Test(expected = RuntimeException.class)
+    public void testReady() throws Exception {
+        failedDataTreeModification.ready();
+    }
+
+    @Test(expected = RuntimeException.class)
+    public void testApplyToCursor() throws Exception {
+        failedDataTreeModification.applyToCursor(dataTreeModificationCursor);
+    }
+
+    @Test(expected = RuntimeException.class)
+    public void testCreateCursor() throws Exception {
+        failedDataTreeModification.createCursor(instanceIdentifier);
+    }
+}

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.