Unit Tests for appc-dg-mdsal-store classes-Part 1 47/29647/2
authoramshegokar <AS00500801@techmahindra.com>
Tue, 30 Jan 2018 12:50:05 +0000 (18:20 +0530)
committerPatrick Brady <pb071s@att.com>
Wed, 31 Jan 2018 20:50:28 +0000 (20:50 +0000)
Adding Unit test for
org.onap.appc.mdsal.operation package
https://sonar.onap.org/drilldown/measures/org.onap.appc:appc?highlight=overall_coverage&metric=overall_uncovered_lines&rids%5B%5D=117465&rids%5B%5D=124943

Change-Id: I8c5b08406b5308dcfef1fd71826f9d8bc908e908
Issue-ID: APPC-501
Signed-off-by: amshegokar <AS00500801@techmahindra.com>
appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/src/test/java/org/onap/appc/mdsal/operation/TestConfigOperationRequestFormatter.java [new file with mode: 0644]

diff --git a/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/src/test/java/org/onap/appc/mdsal/operation/TestConfigOperationRequestFormatter.java b/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/src/test/java/org/onap/appc/mdsal/operation/TestConfigOperationRequestFormatter.java
new file mode 100644 (file)
index 0000000..a55bd81
--- /dev/null
@@ -0,0 +1,47 @@
+package org.onap.appc.mdsal.operation;
+
+import static org.junit.Assert.*;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestConfigOperationRequestFormatter {
+    private ConfigOperationRequestFormatter requestFormatter;
+
+    @Before
+    public void setUp() {
+        requestFormatter = new ConfigOperationRequestFormatter();
+    }
+
+    @Test
+    public void testBuildPath_ValidPath() {
+        String validBuildPath = "/restconf/config/appc-dg-mdsal-store:appc-dg-mdsal-bundle/appc-dg-mdsal-bundle/appc-dg-mdsal-model/";
+        String module = "appc-dg-mdsal-store";
+        String containerName = "appc-dg-mdsal-bundle";
+        String[] subModules = { "appc-dg-mdsal-bundle", "appc-dg-mdsal-model" };
+        assertEquals(validBuildPath, requestFormatter.buildPath(module, containerName, subModules));
+    }
+    @Test
+    public void testBuildPath_One_SubModule() {
+        String validBuildPath = "/restconf/config/appc-dg-mdsal-store:appc-dg-mdsal-bundle/appc-dg-mdsal-bundle/";
+        String module = "appc-dg-mdsal-store";
+        String containerName = "appc-dg-mdsal-bundle";
+        String[] subModules = { "appc-dg-mdsal-bundle"};
+        assertEquals(validBuildPath, requestFormatter.buildPath(module, containerName, subModules));
+    }
+    @Test
+    public void testBuildPath_Zero_SubModule() {
+        String validBuildPathWithoutSubModule = "/restconf/config/appc-dg-mdsal-store:appc-dg-mdsal-bundle/";
+        String module = "appc-dg-mdsal-store";
+        String containerName = "appc-dg-mdsal-bundle";
+        assertEquals(validBuildPathWithoutSubModule, requestFormatter.buildPath(module, containerName));
+    }
+    @Test
+    public void testBuildPath_InvalidPath() {
+        String inValidBuildPath = "/restcon/config/appc-dg-mdsal-storeappc-dg-mdsal-bundle/appc-dg-mdsal-bundle/appc-dg-mdsal-model/";
+        String module = "appc-dg-mdsal-store";
+        String containerName = "appc-dg-mdsal-bundle";
+        String[] subModules = { "appc-dg-mdsal-bundle", "appc-dg-mdsal-model" };
+        assertNotEquals(inValidBuildPath, requestFormatter.buildPath(module, containerName,subModules));
+
+    }
+}