ValidateSchemaTest sonar issue, Replace these 3 tests with a single Parameterized one 35/129735/1
authorGanesh <ganesh.c@samsung.com>
Fri, 1 Jul 2022 13:13:23 +0000 (18:43 +0530)
committerGanesh <ganesh.c@samsung.com>
Fri, 1 Jul 2022 13:13:46 +0000 (18:43 +0530)
Signed-off-by: Ganesh <ganesh.c@samsung.com>
Change-Id: I7f65fcecea7ac6ba574f2cb9bd128a200fbae4e1
Issue-ID: CLI-444

framework/src/test/java/org/onap/cli/fw/schema/ValidateSchemaTest.java

index 00c311f..5c83342 100644 (file)
@@ -35,15 +35,18 @@ public class ValidateSchemaTest {
 
     @Test(expected = OnapCommandInvalidSchema.class)
     public void invalidateTest1() throws OnapCommandException {
-
         OnapCommand cmd = new OnapCommand() {
             @Override
             protected void run() throws OnapCommandException {}
         };
-        OnapCommandSchemaLoader.loadSchema(cmd, "fdsfds.yaml", true, true);
+        try {
+            OnapCommandSchemaLoader.loadSchema(cmd, "fdsfds", true, true);
+        } catch(Exception e) {
+            assertEquals(e.getClass(), OnapCommandInvalidSchema.class);
+        }
+        OnapCommandSchemaLoader.loadSchema(cmd, "schema-invalid-file.yaml", true, true);
     }
 
-
     @Test
     public void validateTestMerge() throws OnapCommandException {
 
@@ -56,15 +59,6 @@ public class ValidateSchemaTest {
 
     @Test(expected = OnapCommandInvalidSchema.class)
     public void invalidateTest2() throws OnapCommandException {
-        OnapCommand cmd = new OnapCommand() {
-            @Override
-            protected void run() throws OnapCommandException {}
-        };
-        OnapCommandSchemaLoader.loadSchema(cmd, "fdsfds", true, true);
-    }
-
-    @Test(expected = OnapCommandInvalidSchema.class)
-    public void invalidateTest4() throws OnapCommandException {
         OnapCommand cmd = new OnapCommand() {
             @Override
             protected void run() throws OnapCommandException {}
@@ -75,7 +69,7 @@ public class ValidateSchemaTest {
     }
 
     @Test(expected = OnapCommandInvalidSchema.class)
-    public void invalidateTest5() throws OnapCommandException {
+    public void invalidateTest3() throws OnapCommandException {
         OnapCommand cmd = new OnapCommand() {
             @Override
             protected void run() throws OnapCommandException {}
@@ -95,15 +89,6 @@ public class ValidateSchemaTest {
         assertTrue(list.isEmpty());
     }
 
-    @Test(expected = OnapCommandInvalidSchema.class)
-    public void invalidateTest3() throws OnapCommandException {
-        OnapCommand cmd = new OnapCommand() {
-            @Override
-            protected void run() throws OnapCommandException {}
-        };
-        OnapCommandSchemaLoader.loadSchema(cmd, "schema-invalid-file.yaml", true, true);
-    }
-
     @Test
     public void validateTest() throws OnapCommandException {