aboutsummaryrefslogtreecommitdiffstats
path: root/appc-config/appc-config-params/provider/src/test/java
diff options
context:
space:
mode:
authorJoss Armstrong <joss.armstrong@ericsson.com>2018-11-29 12:46:23 +0000
committerTakamune Cho <takamune.cho@att.com>2018-11-29 20:56:25 +0000
commit93cb989bb80197a1e6db289d4fc58a7ef6d48216 (patch)
tree02e1a10420d0d9b682901541d7c60b6a1790d7dd /appc-config/appc-config-params/provider/src/test/java
parenta8ef67dbd6e3905cf28392d1ef6442d5904d6f5e (diff)
Test case improvements for APPC-1262
Improvements to existing test cases and new test case to increase coverage of PropertyDefinition code from 84% to 96% and coverage of ArtifactProcess code to 95% Issue-ID: APPC-1262 Change-Id: Ibfd46c341e218ffac0505b097770c64aa00a494e Signed-off-by: Joss Armstrong <joss.armstrong@ericsson.com>
Diffstat (limited to 'appc-config/appc-config-params/provider/src/test/java')
-rw-r--r--appc-config/appc-config-params/provider/src/test/java/org/onap/sdnc/config/params/parser/TestPropertyDefinitionNode.java42
-rw-r--r--appc-config/appc-config-params/provider/src/test/java/org/onap/sdnc/config/params/transformer/tosca/TestArtifactProcessor.java10
2 files changed, 39 insertions, 13 deletions
diff --git a/appc-config/appc-config-params/provider/src/test/java/org/onap/sdnc/config/params/parser/TestPropertyDefinitionNode.java b/appc-config/appc-config-params/provider/src/test/java/org/onap/sdnc/config/params/parser/TestPropertyDefinitionNode.java
index 2a0999783..fe7cb1d7b 100644
--- a/appc-config/appc-config-params/provider/src/test/java/org/onap/sdnc/config/params/parser/TestPropertyDefinitionNode.java
+++ b/appc-config/appc-config-params/provider/src/test/java/org/onap/sdnc/config/params/parser/TestPropertyDefinitionNode.java
@@ -52,6 +52,9 @@ public class TestPropertyDefinitionNode {
public void setup() {
propertyDefinitionNode = new PropertyDefinitionNode();
}
+
+ @Rule
+ public ExpectedException expectedEx = ExpectedException.none();
@Test
public void testProcessMissingParamKeys() throws Exception {
@@ -75,7 +78,7 @@ public class TestPropertyDefinitionNode {
}
- @Test(expected = SvcLogicException.class)
+ @Test
public void testInProcessMissingParamKeysForEmptyPdContent() throws Exception {
Map<String, String> inParams = new HashMap<String, String>();
inParams.put(ParamsHandlerConstant.INPUT_PARAM_RESPONSE_PRIFIX, "test");
@@ -83,7 +86,8 @@ public class TestPropertyDefinitionNode {
TestPropertyDefinitionNode.class.getClassLoader().getResourceAsStream("parser/request-param.json"),
Charset.defaultCharset());
inParams.put(ParamsHandlerConstant.INPUT_PARAM_JSON_DATA, jsonData);
-
+ expectedEx.expect(SvcLogicException.class);
+ expectedEx.expectMessage("Request Param (pdContent) is Missing ..");
SvcLogicContext ctx = new SvcLogicContext();
propertyDefinitionNode.processMissingParamKeys(inParams, ctx);
}
@@ -118,7 +122,7 @@ public class TestPropertyDefinitionNode {
assertEquals(ctx.getAttribute("test." + ParamsHandlerConstant.OUTPUT_PARAM_STATUS),
ParamsHandlerConstant.OUTPUT_STATUS_SUCCESS);
}
-
+
@Test
public void testProcessExternalSystemParamKeysForEmptyParamData() throws Exception {
Map<String, String> inParams = new HashMap<String, String>();
@@ -134,13 +138,8 @@ public class TestPropertyDefinitionNode {
propertyDefinitionNode.processExternalSystemParamKeys(inParams, ctx);
assertEquals(ctx.getAttribute("test." + ParamsHandlerConstant.OUTPUT_PARAM_STATUS),
ParamsHandlerConstant.OUTPUT_STATUS_SUCCESS);
-
-
}
- @Rule
- public ExpectedException expectedEx = ExpectedException.none();
-
@Test
public void testProcessExternalSystemParamKeysForEmptySystemName() throws Exception {
Map<String, String> inParams = new HashMap<String, String>();
@@ -160,16 +159,16 @@ public class TestPropertyDefinitionNode {
expectedEx.expect(SvcLogicException.class);
expectedEx.expectMessage("Request Param (systemName) is Missing ..");
propertyDefinitionNode.processExternalSystemParamKeys(inParams, ctx);
-
}
- @Test(expected = SvcLogicException.class)
+ @Test
public void testProcessExternalSystemParamKeysForEmptyPdContent() throws Exception {
-
Map<String, String> inParams = new HashMap<String, String>();
inParams.put(ParamsHandlerConstant.INPUT_PARAM_RESPONSE_PRIFIX, "test");
inParams.put(ParamsHandlerConstant.INPUT_PARAM_SYSTEM_NAME, "SOURCE");
SvcLogicContext ctx = new SvcLogicContext();
+ expectedEx.expect(SvcLogicException.class);
+ expectedEx.expectMessage("Request Param (pdContent) is Missing ..");
propertyDefinitionNode.processExternalSystemParamKeys(inParams, ctx);
}
@@ -198,7 +197,6 @@ public class TestPropertyDefinitionNode {
@Test
public void mergeJsonDataForEmptyParams() throws SvcLogicException, IOException {
-
Map<String, String> inParams = new HashMap<String, String>();
inParams.put(ParamsHandlerConstant.INPUT_PARAM_RESPONSE_PRIFIX, "test");
String mergeJsonData = IOUtils.toString(
@@ -209,7 +207,6 @@ public class TestPropertyDefinitionNode {
propertyDefinitionNode.mergeJsonData(inParams, ctx);
String status = ctx.getAttribute("test.status");
assertEquals(ParamsHandlerConstant.OUTPUT_STATUS_SUCCESS, status);
-
}
@Test(expected = SvcLogicException.class)
@@ -247,6 +244,25 @@ public class TestPropertyDefinitionNode {
propertyDefinitionNode.validateParams(inParams, ctx);
}
+ @Test
+ public void testValidationPdWithMissingKeys() throws Exception {
+ Map<String, String> inParams = new HashMap<String, String>();
+ SvcLogicContext ctx = new SvcLogicContext();
+ String jsonData = IOUtils.toString(
+ TestPropertyDefinitionNode.class.getClassLoader().getResourceAsStream("parser/pd_with_required_keys.yaml"),
+ Charset.defaultCharset());
+ String mergeJsonData = IOUtils.toString(
+ TestPropertyDefinitionNode.class.getClassLoader().getResourceAsStream("parser/request-param_missing_keys.json"),
+ Charset.defaultCharset());
+ inParams.put(ParamsHandlerConstant.INPUT_PARAM_PD_CONTENT, jsonData);
+ inParams.put(ParamsHandlerConstant.OUTPUT_PARAM_CONFIGURATION_PARAMETER, mergeJsonData);
+ inParams.put(ParamsHandlerConstant.INPUT_PARAM_SYSTEM_NAME, "INSTAR");
+ expectedEx.expect(SvcLogicException.class);
+ expectedEx.expectMessage("Missing Mandatory Keys and source are{\"LOCAL_ACCESS_IP_ADDR\":\"INSTAR\"}");
+ propertyDefinitionNode.validateParams(inParams, ctx);
+ //assertEquals(ParamsHandlerConstant.OUTPUT_STATUS_SUCCESS,ctx.getAttribute(ParamsHandlerConstant.OUTPUT_PARAM_STATUS));
+ }
+
@Test(expected=SvcLogicException.class)
public void testValidateParamsForEmptyParams() throws Exception
{
diff --git a/appc-config/appc-config-params/provider/src/test/java/org/onap/sdnc/config/params/transformer/tosca/TestArtifactProcessor.java b/appc-config/appc-config-params/provider/src/test/java/org/onap/sdnc/config/params/transformer/tosca/TestArtifactProcessor.java
index a321c686f..d9b31e4bb 100644
--- a/appc-config/appc-config-params/provider/src/test/java/org/onap/sdnc/config/params/transformer/tosca/TestArtifactProcessor.java
+++ b/appc-config/appc-config-params/provider/src/test/java/org/onap/sdnc/config/params/transformer/tosca/TestArtifactProcessor.java
@@ -36,6 +36,8 @@ import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
+import org.onap.sdnc.config.params.data.PropertyDefinition;
+import org.onap.sdnc.config.params.transformer.ArtificatTransformer;
import org.onap.sdnc.config.params.transformer.tosca.exceptions.ArtifactProcessorException;
public class TestArtifactProcessor {
@@ -79,6 +81,14 @@ public class TestArtifactProcessor {
String toscaString = outstream.toString();
}
+ @Test
+ public void testReadArtifact() throws IOException, ArtifactProcessorException {
+ ArtifactProcessor arp = ArtifactProcessorFactory.getArtifactProcessor();
+ String pdString = getFileContent("tosca/ExpectedTosca.yml");
+ PropertyDefinition propertyDefinitionObj = arp.readArtifact(pdString);
+ Assert.assertEquals(7, propertyDefinitionObj.getParameters().size());
+ }
+
private String getFileContent(String fileName) throws IOException {
ClassLoader classLoader = new TestArtifactProcessor().getClass().getClassLoader();
InputStream is = new FileInputStream(classLoader.getResource(fileName).getFile());