diff options
Diffstat (limited to 'appc-config/appc-config-params/provider')
7 files changed, 153 insertions, 25 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()); diff --git a/appc-config/appc-config-params/provider/src/test/resources/parser/merge-param.json b/appc-config/appc-config-params/provider/src/test/resources/parser/merge-param.json index 76aebb0ac..0c3a02331 100644 --- a/appc-config/appc-config-params/provider/src/test/resources/parser/merge-param.json +++ b/appc-config/appc-config-params/provider/src/test/resources/parser/merge-param.json @@ -1,6 +1,6 @@ { - "Additional1": "XX.XX.XX", - "Additional2": "XXXXXX", - "Additiona3": "00", - "Additional": "00" + "Additional1": "XX.XX.XX", + "Additional2": "XXXXXX", + "Additiona3": "00", + "Additional": "00" } diff --git a/appc-config/appc-config-params/provider/src/test/resources/parser/pd_with_required_keys.yaml b/appc-config/appc-config-params/provider/src/test/resources/parser/pd_with_required_keys.yaml new file mode 100644 index 000000000..716766a2e --- /dev/null +++ b/appc-config/appc-config-params/provider/src/test/resources/parser/pd_with_required_keys.yaml @@ -0,0 +1,96 @@ +# ============LICENSE_START========================================== +# ONAP : APPC +# =================================================================== +# Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the License); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +# ============LICENSE_END============================================ +--- +kind: "Property Definition" +version: "V1" +vnf-parameter-list: +- name: "LOCAL_ACCESS_IP_ADDR" + description: null + type: null + required: true + source: "INSTAR" + rule-type: "interface-ip-address" + default: "0.0.0.0" + request-keys: + - key-name: "address_fqdn" + key-value: "value" + - key-name: "address_type" + key-value: "v4" + response-keys: null +- name: "LOCAL_CORE_ALT_IP_ADDR" + description: null + type: null + required: true + source: "A&AI" + rule-type: null + default: "0:0:0:0" + request-keys: + - key-name: "address_fqdn" + key-value: "value" + - key-name: "address_type" + key-value: "v4" + response-keys: null +- name: "LOCAL_BILLING_IP_ADDR" + description: null + type: null + required: false + source: null + rule-type: null + default: "0.0.0.0" + request-keys: null + response-keys: null +- name: "REMOTE_ACCESS_IP_ADDR" + description: null + type: null + required: false + source: null + rule-type: null + default: "0.0.0.0" + request-keys: null + response-keys: null +- name: "REMOTE_CORE_ALT_IP_ADDR" + description: null + type: null + required: false + source: null + rule-type: null + default: "0:0:0:0" + request-keys: null + response-keys: null +- name: "REMOTE_BILLING_IP_ADDR" + description: null + type: null + required: false + source: "Manual" + rule-type: null + default: "0.0.0.0" + request-keys: null + response-keys: null +- name: "CORE_NETWORK_PLEN" + description: null + type: null + required: false + source: INSTAR + rule-type: null + default: "32" + request-keys: null + response-keys: null diff --git a/appc-config/appc-config-params/provider/src/test/resources/parser/request-param.json b/appc-config/appc-config-params/provider/src/test/resources/parser/request-param.json index f4dc6f2e3..fa141ea6c 100644 --- a/appc-config/appc-config-params/provider/src/test/resources/parser/request-param.json +++ b/appc-config/appc-config-params/provider/src/test/resources/parser/request-param.json @@ -1,6 +1,6 @@ -{ - "LOCAL_BILLING_IP_ADDR": "0.0.0.0", - "REMOTE_CORE_ALT_IP_ADDR": "value", - "REMOTE_BILLING_IP_ADDR": "0.0.0.0", - "CORE_NETWORK_PLEN": "32" +{ + "LOCAL_BILLING_IP_ADDR": "0.0.0.0", + "REMOTE_CORE_ALT_IP_ADDR": "value", + "REMOTE_BILLING_IP_ADDR": "0.0.0.0", + "CORE_NETWORK_PLEN": "32" } diff --git a/appc-config/appc-config-params/provider/src/test/resources/parser/request-param_missing_keys.json b/appc-config/appc-config-params/provider/src/test/resources/parser/request-param_missing_keys.json new file mode 100644 index 000000000..94630f8fb --- /dev/null +++ b/appc-config/appc-config-params/provider/src/test/resources/parser/request-param_missing_keys.json @@ -0,0 +1,6 @@ +{ + "LOCAL_CORE_ALT_IP_ADDR": "0.0.0.0", + "REMOTE_CORE_ALT_IP_ADDR": "value", + "REMOTE_BILLING_IP_ADDR": "0.0.0.0", + "CORE_NETWORK_PLEN": "32" +} diff --git a/appc-config/appc-config-params/provider/src/test/resources/parser/system-param.json b/appc-config/appc-config-params/provider/src/test/resources/parser/system-param.json index bb3fdfc50..33672001e 100644 --- a/appc-config/appc-config-params/provider/src/test/resources/parser/system-param.json +++ b/appc-config/appc-config-params/provider/src/test/resources/parser/system-param.json @@ -1,5 +1,5 @@ { - "LOCAL_ACCESS_IP_ADDR": "XX.XX.XX", - "LOCAL_BILLING_IP_ADDR": "XXXXXX", - "CORE_NETWORK_PLEN": "00" + "LOCAL_ACCESS_IP_ADDR": "XX.XX.XX", + "LOCAL_BILLING_IP_ADDR": "XXXXXX", + "CORE_NETWORK_PLEN": "00" } |