diff options
author | Determe, Sebastien (sd378r) <sd378r@intl.att.com> | 2017-05-02 03:53:18 -0700 |
---|---|---|
committer | Determe, Sebastien (sd378r) <sd378r@intl.att.com> | 2017-05-02 06:59:21 -0700 |
commit | 94ee92559b051f2f82ed681f841f4f13016842ed (patch) | |
tree | 9760a0ad7da03572ed4c9dc596c4b0f537e64112 /mso-api-handlers/mso-api-handler-infra/src/test | |
parent | 43bbca64032716730d2e7795b6569d5fdbda9d12 (diff) |
[MSO-8] Second step of the rebase for MSO
Second rebase containing additional features for MSO + total reworking
of the BPMN structure + Notification flow can now be added at the end of
some BPMN flows
Change-Id: I7e937c7a0ba1593ca85e164a093f79c7e38b6ce0
Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/test')
11 files changed, 500 insertions, 0 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/MsoRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/MsoRequestTest.java new file mode 100644 index 0000000000..dde7ecf20b --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/MsoRequestTest.java @@ -0,0 +1,235 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ +package org.openecomp.mso.apihandlerinfra; + +import org.openecomp.mso.apihandler.common.ValidationException; +import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.ServiceInstancesRequest; +import org.apache.commons.io.IOUtils; +import org.codehaus.jackson.JsonParseException; +import org.codehaus.jackson.map.JsonMappingException; +import org.codehaus.jackson.map.ObjectMapper; +import org.junit.Test; + +import java.io.IOException; +import java.util.HashMap; + +import static org.junit.Assert.*; + +public class MsoRequestTest { + + + + @Test + public void testParseOrchestration() throws JsonParseException, JsonMappingException, IOException, ValidationException{ + ObjectMapper mapper = new ObjectMapper(); + String requestJSON = " {\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"}}}"; + ServiceInstancesRequest sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); + MsoRequest msoRequest = new MsoRequest ("1234"); + msoRequest.parseOrchestration(sir); + assertEquals(msoRequest.getRequestInfo().getSource(),"VID"); + assertEquals(msoRequest.getRequestInfo().getRequestorId(),"zz9999"); + + } + + @Test(expected = ValidationException.class) + public void testParseOrchestrationFailure() throws JsonParseException, JsonMappingException, IOException, ValidationException{ + ObjectMapper mapper = new ObjectMapper(); + String requestJSON = " {\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\"}}}"; + ServiceInstancesRequest sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); + MsoRequest msoRequest = new MsoRequest ("1234"); + msoRequest.parseOrchestration(sir); + + } + + @Test + public void testParseV3VnfCreate() throws JsonParseException, JsonMappingException, IOException, ValidationException{ + String requestJSON; + try { + requestJSON = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/v3VnfCreate.json")); + + } catch (IOException e) { + fail ("Exception caught"); + e.printStackTrace (); + return; + } + ObjectMapper mapper = new ObjectMapper(); + HashMap<String, String> instanceIdMap = new HashMap<String,String>(); + instanceIdMap.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"); + ServiceInstancesRequest sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); + MsoRequest msoRequest = new MsoRequest ("1234"); + msoRequest.parse(sir, instanceIdMap, Action.createInstance, "v3"); + assertEquals(msoRequest.getRequestInfo().getSource(),"VID"); + assertFalse(msoRequest.getALaCarteFlag()); + assertEquals(msoRequest.getReqVersion(),3); + boolean testIsALaCarteSet = msoRequest.getServiceInstancesRequest().getRequestDetails().getRequestParameters().isALaCarteSet(); + assertFalse(testIsALaCarteSet); + + } + + @Test(expected = ValidationException.class) + public void testParseV3VolumeGroupFail() throws JsonParseException, JsonMappingException, IOException, ValidationException{ + String requestJSON; + try { + requestJSON = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/v3VolumeGroupBad.json")); + + } catch (IOException e) { + fail ("Exception caught"); + e.printStackTrace (); + return; + } + ObjectMapper mapper = new ObjectMapper(); + HashMap<String, String> instanceIdMap = new HashMap<String,String>(); + instanceIdMap.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"); + ServiceInstancesRequest sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); + MsoRequest msoRequest = new MsoRequest ("1234"); + msoRequest.parse(sir, instanceIdMap, Action.updateInstance, "v3"); + + } + + @Test + public void testParseV3UpdateNetwork() throws JsonParseException, JsonMappingException, IOException, ValidationException{ + String requestJSON; + try { + requestJSON = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/v3UpdateNetwork.json")); + + } catch (IOException e) { + fail ("Exception caught"); + e.printStackTrace (); + return; + } + ObjectMapper mapper = new ObjectMapper(); + HashMap<String, String> instanceIdMap = new HashMap<String,String>(); + instanceIdMap.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"); + ServiceInstancesRequest sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); + MsoRequest msoRequest = new MsoRequest ("1234"); + msoRequest.parse(sir, instanceIdMap, Action.updateInstance, "v3"); + + } + + @Test(expected = ValidationException.class) + public void testParseV3UpdateNetworkFail() throws JsonParseException, JsonMappingException, IOException, ValidationException{ + String requestJSON; + try { + requestJSON = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/v3UpdateNetworkBad.json")); + + } catch (IOException e) { + fail ("Exception caught"); + e.printStackTrace (); + return; + } + ObjectMapper mapper = new ObjectMapper(); + HashMap<String, String> instanceIdMap = new HashMap<String,String>(); + instanceIdMap.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"); + ServiceInstancesRequest sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); + MsoRequest msoRequest = new MsoRequest ("1234"); + msoRequest.parse(sir, instanceIdMap, Action.updateInstance, "v3"); + + } + + @Test + public void testParseV3DeleteNetwork() throws JsonParseException, JsonMappingException, IOException, ValidationException{ + String requestJSON; + try { + requestJSON = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/v3DeleteNetwork.json")); + + } catch (IOException e) { + fail ("Exception caught"); + e.printStackTrace (); + return; + } + ObjectMapper mapper = new ObjectMapper(); + HashMap<String, String> instanceIdMap = new HashMap<String,String>(); + instanceIdMap.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"); + ServiceInstancesRequest sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); + MsoRequest msoRequest = new MsoRequest ("1234"); + msoRequest.parse(sir, instanceIdMap, Action.deleteInstance, "v3"); + } + + @Test + public void testParseV3ServiceInstanceDelete() throws JsonParseException, JsonMappingException, IOException, ValidationException{ + String requestJSON1, requestJSON2; + try { + requestJSON1 = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/v3DeleteServiceInstance.json")); + requestJSON2 = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/v3DeleteServiceInstanceALaCarte.json")); + + } catch (IOException e) { + fail ("Exception caught"); + e.printStackTrace (); + return; + } + ObjectMapper mapper = new ObjectMapper(); + HashMap<String, String> instanceIdMap = new HashMap<String,String>(); + instanceIdMap.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"); + ServiceInstancesRequest sir = mapper.readValue(requestJSON1, ServiceInstancesRequest.class); + MsoRequest msoRequest = new MsoRequest ("1234"); + msoRequest.parse(sir, instanceIdMap, Action.deleteInstance, "v3"); + boolean testIsALaCarteSet = msoRequest.getServiceInstancesRequest().getRequestDetails().getRequestParameters().isALaCarteSet(); + assertTrue(testIsALaCarteSet); + assertFalse(msoRequest.getALaCarteFlag()); + sir = mapper.readValue(requestJSON2, ServiceInstancesRequest.class); + msoRequest = new MsoRequest ("12345"); + msoRequest.parse(sir, instanceIdMap, Action.deleteInstance, "v3"); + testIsALaCarteSet = msoRequest.getServiceInstancesRequest().getRequestDetails().getRequestParameters().isALaCarteSet(); + assertTrue(testIsALaCarteSet); + assertTrue(msoRequest.getALaCarteFlag()); + + } + + @Test(expected = ValidationException.class) + public void testParseV3ServiceInstanceCreateFail() throws JsonParseException, JsonMappingException, IOException, ValidationException{ + String requestJSON2; + try { + requestJSON2 = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/v3DeleteServiceInstanceALaCarte.json")); + + } catch (IOException e) { + fail ("Exception caught"); + e.printStackTrace (); + return; + } + ObjectMapper mapper = new ObjectMapper(); + HashMap<String, String> instanceIdMap = new HashMap<String,String>(); + instanceIdMap.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"); + ServiceInstancesRequest sir = mapper.readValue(requestJSON2, ServiceInstancesRequest.class); + MsoRequest msoRequest = new MsoRequest ("1234"); + msoRequest.parse(sir, instanceIdMap, Action.createInstance, "v3"); + + } + + @Test(expected = ValidationException.class) + public void testParseV3ServiceInstanceDeleteMacroFail() throws JsonParseException, JsonMappingException, IOException, ValidationException{ + String requestJSON; + try { + requestJSON = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/v3DeleteServiceInstanceBad.json")); + + } catch (IOException e) { + fail ("Exception caught"); + e.printStackTrace (); + return; + } + ObjectMapper mapper = new ObjectMapper(); + HashMap<String, String> instanceIdMap = new HashMap<String,String>(); + instanceIdMap.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"); + ServiceInstancesRequest sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); + MsoRequest msoRequest = new MsoRequest ("1234"); + msoRequest.parse(sir, instanceIdMap, Action.deleteInstance, "v3"); + + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/logback-test.xml b/mso-api-handlers/mso-api-handler-infra/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..4609de0d77 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/logback-test.xml @@ -0,0 +1,28 @@ +<configuration > + + + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>%d{MM/dd-HH:mm:ss.SSS}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}||%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}||%X{Timer}|%msg%n</pattern> + </encoder> + </appender> + + + <logger name="com.att.ecomp.audit" level="debug" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.metrics" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.error" level="debug" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <root level="debug"> + <appender-ref ref="STDOUT" /> + </root> + + +</configuration>
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/logging.properties b/mso-api-handlers/mso-api-handler-infra/src/test/resources/logging.properties new file mode 100644 index 0000000000..4941c55971 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/logging.properties @@ -0,0 +1,2 @@ +#register SLF4JBridgeHandler as handler for the j.u.l. root logger +handlers = org.slf4j.bridge.SLF4JBridgeHandler diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3DeleteNetwork.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3DeleteNetwork.json new file mode 100644 index 0000000000..98610afe6e --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3DeleteNetwork.json @@ -0,0 +1,15 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "network" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "8b1df54faa3b49078e3416e21370a3ba" + }, + "requestInfo": { + "source": "VID", + "requestorId": "az2016" + } + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3DeleteServiceInstance.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3DeleteServiceInstance.json new file mode 100644 index 0000000000..4d1719f467 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3DeleteServiceInstance.json @@ -0,0 +1,27 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "service", + "modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", + "modelName": "Test", + "modelVersion": "1.0" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "88a6ca3ee0394ade9403f075db23167e" + }, + "requestInfo": { + "source": "VID", + "requestorId": "az2016" + }, + "requestParameters": { + "aLaCarte": false, + "userParams": [ + { + "name": "someUserParam", + "value": "someValue" + } + ] + } + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3DeleteServiceInstanceALaCarte.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3DeleteServiceInstanceALaCarte.json new file mode 100644 index 0000000000..5a9320675e --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3DeleteServiceInstanceALaCarte.json @@ -0,0 +1,22 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "service", + "modelName": "Test", + "modelVersion": "1.0" + }, + "requestInfo": { + "source": "VID", + "requestorId": "az2016" + }, + "requestParameters": { + "aLaCarte": true, + "userParams": [ + { + "name": "someUserParam", + "value": "someValue" + } + ] + } + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3DeleteServiceInstanceBad.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3DeleteServiceInstanceBad.json new file mode 100644 index 0000000000..dcf47d0aa0 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3DeleteServiceInstanceBad.json @@ -0,0 +1,26 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "service", + "modelName": "Test", + "modelVersion": "1.0" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "88a6ca3ee0394ade9403f075db23167e" + }, + "requestInfo": { + "source": "VID", + "requestorId": "az2016" + }, + "requestParameters": { + "aLaCarte": false, + "userParams": [ + { + "name": "someUserParam", + "value": "someValue" + } + ] + } + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3UpdateNetwork.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3UpdateNetwork.json new file mode 100644 index 0000000000..2aef2e7604 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3UpdateNetwork.json @@ -0,0 +1,39 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "network", + "modelName": "CONTRAIL30_BASIC", + "modelCustomizationName": "CONTRAIL30_BASIC 1", + "modelCustomizationId": "b0ed83ec-b7b4-4c70-91c2-63feeaf8609b" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "8b1df54faa3b49078e3416e21370a3ba" + }, + "requestInfo": { + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "source": "VID", + "suppressRollback": true, + "requestorId": "az2016" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc", + "modelInfo": { + "modelType": "service", + "modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", + "modelVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelName": "{parent service model name}", + "modelVersion": "1.0" + } + } + } + + ], + "requestParameters": { + "userParams": [] + + } + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3UpdateNetworkBad.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3UpdateNetworkBad.json new file mode 100644 index 0000000000..956d771c79 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3UpdateNetworkBad.json @@ -0,0 +1,38 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "network", + "modelName": "CONTRAIL30_BASIC", + "modelCustomizationName": "CONTRAIL30_BASIC 1" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "8b1df54faa3b49078e3416e21370a3ba" + }, + "requestInfo": { + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "source": "VID", + "suppressRollback": true, + "requestorId": "az2016" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc", + "modelInfo": { + "modelType": "service", + "modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", + "modelVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelName": "{parent service model name}", + "modelVersion": "1.0" + } + } + } + + ], + "requestParameters": { + "userParams": [] + + } + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3VnfCreate.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3VnfCreate.json new file mode 100644 index 0000000000..90fc84178c --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3VnfCreate.json @@ -0,0 +1,41 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "vnf", + "modelInvariantId": "ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12", + "modelVersion": "1.0", + "modelCustomizationName": "vSAMP12 1", + "modelCustomizationId": "a7f1d08e-b02d-11e6-80f5-76304dec7eb7" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "88a6ca3ee0394ade9403f075db23167e" + }, + "requestInfo": { + "instanceName": "MSOTEST103a", + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "source": "VID", + "suppressRollback": false, + "requestorId": "az2016" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc", + "modelInfo": { + "modelType": "service", + "modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", + "modelVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelName": "aparent", + "modelVersion": "1.0" + } + } + } + ], + "requestParameters": { + "autoBuildVfModules": true + } + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3VolumeGroupBad.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3VolumeGroupBad.json new file mode 100644 index 0000000000..526be72895 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3VolumeGroupBad.json @@ -0,0 +1,27 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "volumeGroup", + "modelInvariantId": "ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12", + "modelVersion": "1.0", + "modelCustomizationName": "vSAMP12 1", + "modelCustomizationId": "a7f1d08e-b02d-11e6-80f5-76304dec7eb7" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "88a6ca3ee0394ade9403f075db23167e" + }, + "requestInfo": { + "instanceName": "MSOTEST103a", + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "source": "VID", + "suppressRollback": false, + "requestorId": "az2016" + }, + "requestParameters": { + "autoBuildVfModules": true + } + } +} |