removed redundant object assignment
[appc.git] / appc-config / appc-config-params / provider / src / test / java / org / onap / sdnc / config / params / parser / TestPropertyDefinitionNode.java
index 2fdc90a..569fb9e 100644 (file)
@@ -6,7 +6,7 @@
  * ================================================================================
  * Copyright (C) 2017 Amdocs
  * =============================================================================
- * Modification Copyright (C) 2018 IBM
+ * Modifications Copyright (C) 2018 IBM
  * =============================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -53,7 +53,6 @@ public class TestPropertyDefinitionNode {
 
     @Test
     public void testProcessMissingParamKeys() throws Exception {
-        PropertyDefinitionNode propertyDefinitionNode = new PropertyDefinitionNode();
         Map<String, String> inParams = new HashMap<String, String>();
         inParams.put(ParamsHandlerConstant.INPUT_PARAM_RESPONSE_PRIFIX, "test");
 
@@ -76,7 +75,6 @@ public class TestPropertyDefinitionNode {
 
     @Test(expected = SvcLogicException.class)
     public void testInProcessMissingParamKeysForEmptyPdContent() throws Exception {
-        PropertyDefinitionNode propertyDefinitionNode = new PropertyDefinitionNode();
         Map<String, String> inParams = new HashMap<String, String>();
         inParams.put(ParamsHandlerConstant.INPUT_PARAM_RESPONSE_PRIFIX, "test");
         String jsonData = IOUtils.toString(
@@ -90,7 +88,6 @@ public class TestPropertyDefinitionNode {
 
     @Test
     public void testProcessExternalSystemParamKeys() throws Exception {
-        PropertyDefinitionNode propertyDefinitionNode = new PropertyDefinitionNode();
         Map<String, String> inParams = new HashMap<String, String>();
         inParams.put(ParamsHandlerConstant.INPUT_PARAM_RESPONSE_PRIFIX, "test");
 
@@ -132,7 +129,6 @@ public class TestPropertyDefinitionNode {
 
     @Test
     public void mergeJsonData() throws Exception {
-        PropertyDefinitionNode propertyDefinitionNode = new PropertyDefinitionNode();
         Map<String, String> inParams = new HashMap<String, String>();
         inParams.put(ParamsHandlerConstant.INPUT_PARAM_RESPONSE_PRIFIX, "test");
 
@@ -157,7 +153,6 @@ public class TestPropertyDefinitionNode {
     @Test
     public void mergeJsonDataForEmptyParams() throws SvcLogicException, IOException {
 
-        PropertyDefinitionNode propertyDefinitionNode = new PropertyDefinitionNode();
         Map<String, String> inParams = new HashMap<String, String>();
         inParams.put(ParamsHandlerConstant.INPUT_PARAM_RESPONSE_PRIFIX, "test");
         String mergeJsonData = IOUtils.toString(
@@ -171,6 +166,14 @@ public class TestPropertyDefinitionNode {
 
     }
 
+    @Test(expected = SvcLogicException.class)
+    public void testMergeJsonDataCatchPortion() throws Exception {
+        Map<String, String> inParams = new HashMap<String, String>();
+        inParams.put(ParamsHandlerConstant.INPUT_PARAM_RESPONSE_PRIFIX, "test");
+        SvcLogicContext ctx = new SvcLogicContext();
+        propertyDefinitionNode.mergeJsonData(inParams, ctx);
+    }
+
     @Test
     public void testArtificatTransformer() throws Exception {
         ArtificatTransformer transformer = new ArtificatTransformer();
@@ -184,7 +187,6 @@ public class TestPropertyDefinitionNode {
 
     @Test
     public void testValidationPd() throws Exception {
-        PropertyDefinitionNode propertyDefinitionNode = new PropertyDefinitionNode();
         Map<String, String> inParams = new HashMap<String, String>();
         SvcLogicContext ctx = new SvcLogicContext();
         String jsonData = IOUtils.toString(
@@ -198,5 +200,27 @@ public class TestPropertyDefinitionNode {
         inParams.put(ParamsHandlerConstant.INPUT_PARAM_SYSTEM_NAME, "INSTAR");
         propertyDefinitionNode.validateParams(inParams, ctx);
     }
+    
+    @Test(expected=SvcLogicException.class)
+    public void testValidateParamsForEmptyParams() throws Exception
+    {
+        Map<String, String> inParams = new HashMap<String, String>();
+        SvcLogicContext ctx = new SvcLogicContext();
+        propertyDefinitionNode.validateParams(inParams, ctx);
+    }
+    
+    @Test
+    public void testValidateParamsForEmptyConfigParams() throws Exception
+    {
+        Map<String, String> inParams = new HashMap<String, String>();
+        String jsonData = IOUtils.toString(
+                TestPropertyDefinitionNode.class.getClassLoader().getResourceAsStream("parser/pd.yaml"),
+                Charset.defaultCharset());
+        inParams.put(ParamsHandlerConstant.INPUT_PARAM_PD_CONTENT, jsonData);
+        SvcLogicContext ctx = new SvcLogicContext();
+        propertyDefinitionNode.validateParams(inParams, ctx);
+        String status = ctx.getAttribute("status");
+        assertEquals(ParamsHandlerConstant.OUTPUT_STATUS_SUCCESS,status);
+    }
 
 }