aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/MsoRequestTest.java
diff options
context:
space:
mode:
authorSeshu Kumar M <seshu.kumar.m@huawei.com>2018-03-09 10:00:26 +0000
committerGerrit Code Review <gerrit@onap.org>2018-03-09 10:00:26 +0000
commitf3b28a0aafd83a57d42afbf23c9f6fbe6f546db3 (patch)
tree5ecb2b2a78ab3139828db18de5f2a76d76c77519 /mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/MsoRequestTest.java
parent8d0b9eb56af520d28c423da76c0f0be02cb453c7 (diff)
parent327b17ab250b4c17cf3f91f5e4cd9bffd89f3d1e (diff)
Merge "Reduce log noise/warnings format to conventions"
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/MsoRequestTest.java')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/MsoRequestTest.java512
1 files changed, 255 insertions, 257 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
index c4a1c1fffc..58e17ff273 100644
--- 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
@@ -41,261 +41,259 @@ import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.ServiceInstancesRe
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<>();
- 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<>();
- 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<>();
- 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<>();
- 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<>();
- 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<>();
- 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<>();
- 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<>();
- 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 testVfModuleV4UsePreLoad() throws JsonParseException, JsonMappingException, IOException, ValidationException {
- String requestJSON;
- try {
- requestJSON = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/v4CreateVfModule.json"));
-
- } catch (IOException e) {
- fail ("Exception caught");
- e.printStackTrace ();
- return;
- }
-
- ObjectMapper mapper = new ObjectMapper();
- HashMap<String, String> instanceIdMap = new HashMap<>();
- instanceIdMap.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
- instanceIdMap.put("vnfInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
- ServiceInstancesRequest sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
- MsoRequest msoRequest = new MsoRequest ("1234");
- msoRequest.parse(sir, instanceIdMap, Action.createInstance, "v4");
-
-
-
- try {
- requestJSON = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/v4CreateVfModuleNoCustomizationId.json"));
-
- } catch (IOException e) {
- fail ("Exception caught");
- e.printStackTrace ();
- return;
- }
-
- mapper = new ObjectMapper();
- instanceIdMap = new HashMap<>();
- instanceIdMap.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
- instanceIdMap.put("vnfInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
- sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
- msoRequest = new MsoRequest ("1234");
- msoRequest.parse(sir, instanceIdMap, Action.createInstance, "v4");
- }
-
- @Test(expected = ValidationException.class)
- public void testV4UsePreLoadMissingModelCustomizationId() throws JsonParseException, JsonMappingException, IOException, ValidationException {
- String requestJSON;
- try {
- requestJSON = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/v4CreateVfModuleMissingModelCustomizationId.json"));
-
- } catch (IOException e) {
- fail ("Exception caught");
- e.printStackTrace ();
- return;
- }
-
- ObjectMapper mapper = new ObjectMapper();
- HashMap<String, String> instanceIdMap = new HashMap<>();
- instanceIdMap.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
- instanceIdMap.put("vnfInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
- ServiceInstancesRequest sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
- MsoRequest msoRequest = new MsoRequest ("1234");
- msoRequest.parse(sir, instanceIdMap, Action.createInstance, "v4");
- }
+ @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<>();
+ 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<>();
+ 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<>();
+ 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<>();
+ 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<>();
+ 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<>();
+ 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<>();
+ 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<>();
+ 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 testVfModuleV4UsePreLoad() throws JsonParseException, JsonMappingException, IOException, ValidationException {
+ String requestJSON;
+ try {
+ requestJSON = IOUtils.toString(ClassLoader.class.getResourceAsStream("/v4CreateVfModule.json"));
+
+ } catch (IOException e) {
+ fail("Exception caught");
+ e.printStackTrace();
+ return;
+ }
+
+ ObjectMapper mapper = new ObjectMapper();
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
+ instanceIdMap.put("vnfInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
+ ServiceInstancesRequest sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
+ MsoRequest msoRequest = new MsoRequest("1234");
+ msoRequest.parse(sir, instanceIdMap, Action.createInstance, "v4");
+
+
+ try {
+ requestJSON = IOUtils.toString(ClassLoader.class.getResourceAsStream("/v4CreateVfModuleNoCustomizationId.json"));
+
+ } catch (IOException e) {
+ fail("Exception caught");
+ e.printStackTrace();
+ return;
+ }
+
+ mapper = new ObjectMapper();
+ instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
+ instanceIdMap.put("vnfInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
+ sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
+ msoRequest = new MsoRequest("1234");
+ msoRequest.parse(sir, instanceIdMap, Action.createInstance, "v4");
+ }
+
+ @Test(expected = ValidationException.class)
+ public void testV4UsePreLoadMissingModelCustomizationId() throws JsonParseException, JsonMappingException, IOException, ValidationException {
+ String requestJSON;
+ try {
+ requestJSON = IOUtils.toString(ClassLoader.class.getResourceAsStream("/v4CreateVfModuleMissingModelCustomizationId.json"));
+
+ } catch (IOException e) {
+ fail("Exception caught");
+ e.printStackTrace();
+ return;
+ }
+
+ ObjectMapper mapper = new ObjectMapper();
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
+ instanceIdMap.put("vnfInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
+ ServiceInstancesRequest sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
+ MsoRequest msoRequest = new MsoRequest("1234");
+ msoRequest.parse(sir, instanceIdMap, Action.createInstance, "v4");
+ }
}