Containerization feature of SO
[so.git] / mso-api-handlers / mso-api-handler-infra / src / test / java / org / onap / so / apihandlerinfra / ServiceInstancesTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.so.apihandlerinfra;
22
23
24 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
25 import static com.github.tomakehurst.wiremock.client.WireMock.post;
26 import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
27 import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
28 import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
29 import static org.hamcrest.CoreMatchers.containsString;
30 import static org.junit.Assert.assertEquals;
31 import static org.junit.Assert.assertNotNull;
32 import static org.junit.Assert.assertNull;
33 import static org.junit.Assert.assertThat;
34 import static org.junit.Assert.assertTrue;
35
36 import java.io.IOException;
37 import java.nio.file.Files;
38 import java.nio.file.Paths;
39 import java.util.List;
40 import java.util.Map;
41
42 import javax.ws.rs.core.HttpHeaders;
43 import javax.ws.rs.core.MediaType;
44 import javax.ws.rs.core.Response;
45
46 import org.apache.log4j.MDC;
47 import org.junit.Ignore;
48 import org.junit.Test;
49 import org.onap.so.db.request.beans.InfraActiveRequests;
50 import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository;
51 import org.onap.so.logger.MsoLogger;
52 import org.onap.so.serviceinstancebeans.CloudConfiguration;
53 import org.onap.so.serviceinstancebeans.ModelInfo;
54 import org.onap.so.serviceinstancebeans.RequestError;
55 import org.onap.so.serviceinstancebeans.RequestParameters;
56 import org.onap.so.serviceinstancebeans.RequestReferences;
57 import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
58 import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
59 import org.springframework.beans.factory.annotation.Autowired;
60 import org.springframework.http.HttpEntity;
61 import org.springframework.http.HttpMethod;
62 import org.springframework.http.ResponseEntity;
63 import org.springframework.web.util.UriComponentsBuilder;
64
65 import com.fasterxml.jackson.annotation.JsonInclude.Include;
66 import com.fasterxml.jackson.core.JsonParseException;
67 import com.fasterxml.jackson.databind.DeserializationFeature;
68 import com.fasterxml.jackson.databind.JsonMappingException;
69 import com.fasterxml.jackson.databind.ObjectMapper;
70 import com.github.tomakehurst.wiremock.http.Fault;
71
72 import ch.qos.logback.classic.spi.ILoggingEvent;
73
74
75 public class ServiceInstancesTest extends BaseTest{
76         
77         @Autowired
78         private InfraActiveRequestsRepository iar;
79         
80         @Autowired
81         private ServiceInstances servInstances;
82
83         private final String servInstanceuri = "/onap/so/infra/serviceInstantiation/";
84         private final String servInstanceUriPrev7 = "/onap/so/infra/serviceInstances/";
85         private String uri;
86         
87         public String inputStream(String JsonInput)throws IOException{
88                 JsonInput = "src/test/resources/ServiceInstanceTest" + JsonInput;
89                 String input = new String(Files.readAllBytes(Paths.get(JsonInput)));
90                 return input;
91         }
92         
93         public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod){             
94                 headers.set("Accept", MediaType.APPLICATION_JSON);
95                 headers.set("Content-Type",MediaType.APPLICATION_JSON);
96                 
97                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(uriPath));
98                 
99                 HttpEntity<String> request = new HttpEntity<String>(requestJson, headers);  
100                 ResponseEntity<String> response = restTemplate.exchange(builder.toUriString(),
101                                 reqMethod, request, String.class);
102                 
103                 return response;
104         }
105         
106         @Test
107         public void test_mapJSONtoMSOStyle() throws IOException{
108                 ObjectMapper mapper = new ObjectMapper();
109                 mapper.setSerializationInclusion(Include.NON_NULL);
110                 String testRequest= inputStream("/ServiceInstanceDefault.json");
111                 String resultString = servInstances.mapJSONtoMSOStyle(testRequest, null, false, null);
112         ServiceInstancesRequest sir = mapper.readValue(resultString, ServiceInstancesRequest.class);
113         ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
114         assertEquals("f7ce78bb-423b-11e7-93f8-0050569a796",modelInfo.getModelCustomizationUuid());
115         assertEquals("modelInstanceName",modelInfo.getModelInstanceName());
116         assertEquals("f7ce78bb-423b-11e7-93f8-0050569a7965",modelInfo.getModelInvariantUuid());
117         assertEquals("10",modelInfo.getModelUuid());
118         
119         }
120         @Test
121         public void createServiceInstanceVIDDefault() throws JsonParseException, JsonMappingException, IOException{
122                 TestAppender.events.clear();
123                 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
124                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
125                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
126                         
127                 headers.set(MsoLogger.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
128                 headers.set(MsoLogger.CLIENT_ID, "VID");
129                 //expect
130                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
131                 RequestReferences requestReferences = new RequestReferences();
132                 requestReferences.setInstanceId("1882939");
133                 expectedResponse.setRequestReferences(requestReferences);
134                 uri = servInstanceuri + "v5/serviceInstances";
135                 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
136                                 
137                 ObjectMapper mapper = new ObjectMapper();
138                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
139         
140                 //then          
141                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
142                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
143                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
144                 ILoggingEvent logEvent = TestAppender.events.get(0);
145         Map<String,String> mdc = logEvent.getMDCPropertyMap();
146         assertEquals("32807a28-1a14-4b88-b7b3-2950918aa76d", mdc.get(MsoLogger.REQUEST_ID));
147         assertEquals("VID", mdc.get(MsoLogger.CLIENT_ID));
148         MDC.remove(MsoLogger.CLIENT_ID);
149         assertTrue(response.getBody().contains("1882939"));
150         assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
151         assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
152         assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
153         assertEquals("5.0.0", response.getHeaders().get("X-LatestVersion").get(0));
154         assertEquals("32807a28-1a14-4b88-b7b3-2950918aa76d", response.getHeaders().get("X-TransactionID").get(0));
155         
156       //ExpectedRecord
157                 InfraActiveRequests expectedRecord = new InfraActiveRequests();
158                 expectedRecord.setRequestStatus("IN_PROGRESS");
159                 expectedRecord.setRequestBody(inputStream("/ServiceInstanceDefault.json"));
160                 expectedRecord.setAction("createInstance");
161                 expectedRecord.setSource("VID");
162                 expectedRecord.setVnfId("1882938");
163                 expectedRecord.setLastModifiedBy("APIH");
164                 expectedRecord.setServiceInstanceId("1882939");
165                 expectedRecord.setServiceInstanceName("testService9");
166                 expectedRecord.setRequestScope("service");
167                 expectedRecord.setRequestorId("xxxxxx");
168                 expectedRecord.setRequestAction("createInstance");
169                 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
170                 
171                 //ActualRecord
172                 InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
173                 assertEquals(sameBeanAs(expectedRecord).toString(), sameBeanAs(requestRecord).ignoring("startTime").ignoring("modifyTime").toString());
174         
175         }
176         @Test
177         public void createServiceInstanceServiceInstancesUri() throws JsonParseException, JsonMappingException, IOException{
178                 stubFor(post(urlPathEqualTo("/mso/async/services/CreateGenericALaCarteServiceInstance"))
179                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
180                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
181                 
182                 //expect
183                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
184                 RequestReferences requestReferences = new RequestReferences();
185                 requestReferences.setInstanceId("1882939");
186                 expectedResponse.setRequestReferences(requestReferences);
187                 uri = servInstanceUriPrev7 + "v5";
188                 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev7.json"), uri, HttpMethod.POST);
189                                 
190                 ObjectMapper mapper = new ObjectMapper();
191                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
192         
193                 //then          
194                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
195                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
196                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
197         }
198         @Test
199         public void createServiceInstanceBpelStatusError() throws JsonParseException, JsonMappingException, IOException{
200                 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
201                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
202                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY)));
203
204                 uri = servInstanceuri + "v5/serviceInstances";
205                 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceStatusError.json"), uri, HttpMethod.POST);
206                 
207                 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
208         }
209         @Test
210         public void createServiceInstanceBadGateway() throws JsonParseException, JsonMappingException, IOException{
211                 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
212                                 .willReturn(aResponse().withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY).withBody("{}")));
213         
214                 uri = servInstanceuri + "v5/serviceInstances";
215                 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceBadGateway.json"), uri, HttpMethod.POST);
216         
217                 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
218         }
219         @Test
220         public void createServiceInstanceEmptyResponse() throws JsonParseException, JsonMappingException, IOException{
221                 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
222                                 .willReturn(aResponse().withFault(Fault.EMPTY_RESPONSE)));
223                 
224                 uri = servInstanceuri + "v5/serviceInstances";
225                 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEmpty.json"), uri, HttpMethod.POST);
226                                 
227                 assertEquals(Response.Status.BAD_GATEWAY.getStatusCode(), response.getStatusCode().value());
228         }
229         @Test
230         public void activateServiceInstanceNoRecipeALaCarte() throws JsonParseException, JsonMappingException, IOException{
231                 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
232                 headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
233                 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"), uri, HttpMethod.POST);
234                 
235                 //ExpectedRecord
236                 InfraActiveRequests expectedRecord = new InfraActiveRequests();
237                 expectedRecord.setRequestStatus("FAILED");
238                 expectedRecord.setAction("activateInstance");
239                 expectedRecord.setStatusMessage("Recipe could not be retrieved from catalog DB.");
240                 expectedRecord.setProgress(new Long(100));
241                 expectedRecord.setSource("VID");
242                 expectedRecord.setVnfId("1882938");
243                 expectedRecord.setRequestBody(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"));
244                 expectedRecord.setLastModifiedBy("APIH");
245                 expectedRecord.setServiceInstanceId("f7ce78bb-423b-11e7-93f8-0050569a7968");
246                 expectedRecord.setServiceInstanceName("testService7");
247                 expectedRecord.setRequestScope("service");
248                 expectedRecord.setRequestAction("activateInstance");
249                 expectedRecord.setRequestorId("xxxxxx");
250                 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
251         
252                 //ActualRecord
253                 InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
254                 assertEquals(sameBeanAs(expectedRecord).toString(), sameBeanAs(requestRecord).ignoring("startTime").ignoring("endTime").ignoring("modifyTime").toString());
255                 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
256         }
257         @Test
258         public void activateServiceInstanceNoRecipe() throws JsonParseException, JsonMappingException, IOException{
259                 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
260                 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceNoRecipe.json"), uri, HttpMethod.POST);
261         
262                 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
263         }
264         @Test
265         public void activateServiceInstance() throws JsonParseException, JsonMappingException, IOException{
266                 stubFor(post(urlPathEqualTo("/mso/async/services/ActivateInstance"))
267                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
268                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
269
270                 headers.set("X-TransactionID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
271                 //expected response
272                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
273                 RequestReferences requestReferences = new RequestReferences();
274                 requestReferences.setInstanceId("1882939");
275                 expectedResponse.setRequestReferences(requestReferences);
276                 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
277                 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivate.json"), uri, HttpMethod.POST);
278                 
279                 ObjectMapper mapper = new ObjectMapper();
280                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
281                 
282                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
283                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
284                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
285         }
286         @Test
287         public void deactivateServiceInstance() throws JsonParseException, JsonMappingException, IOException{
288                 stubFor(post(urlPathEqualTo("/mso/async/services/DeactivateInstance"))
289                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
290                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
291                 //expected response
292                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
293                 RequestReferences requestReferences = new RequestReferences();
294                 requestReferences.setInstanceId("1882939");
295                 expectedResponse.setRequestReferences(requestReferences);
296                 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/deactivate";
297                 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDeactivate.json"), uri, HttpMethod.POST);
298                 
299                 ObjectMapper mapper = new ObjectMapper();
300                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
301                 
302                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
303                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
304                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
305         }
306         @Test
307         public void deleteServiceInstance() throws JsonParseException, JsonMappingException, IOException {
308                 stubFor(post(urlPathEqualTo("/mso/async/services/DeleteInstance"))
309                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
310                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
311                 //expected response
312                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
313                 RequestReferences requestReferences = new RequestReferences();
314                 requestReferences.setInstanceId("1882939");
315                 expectedResponse.setRequestReferences(requestReferences);
316                 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a8868/";
317                 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDelete.json"), uri, HttpMethod.DELETE);
318                 
319                 ObjectMapper mapper = new ObjectMapper();
320                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
321                 
322                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
323                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
324                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
325         }
326         @Test
327         public void assignServiceInstance() throws JsonParseException, JsonMappingException, IOException {
328                 stubFor(post(urlPathEqualTo("/mso/async/services/AssignServiceInstance"))
329                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
330                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
331                 //expected response
332                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
333                 RequestReferences requestReferences = new RequestReferences();
334                 requestReferences.setInstanceId("1882939");
335                 expectedResponse.setRequestReferences(requestReferences);
336                 uri = servInstanceuri + "v7" + "/serviceInstances/assign";
337                 ResponseEntity<String> response = sendRequest(inputStream("/ServiceAssign.json"), uri, HttpMethod.POST);
338                 
339                 ObjectMapper mapper = new ObjectMapper();
340                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
341                 
342                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
343                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
344                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
345         }
346         
347         @Test
348         public void unassignServiceInstance() throws JsonParseException, JsonMappingException, IOException {
349                 stubFor(post(urlPathEqualTo("/mso/async/services/UnassignServiceInstance"))
350                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
351                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
352                 //expected response
353                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
354                 RequestReferences requestReferences = new RequestReferences();
355                 requestReferences.setInstanceId("1882939");
356                 expectedResponse.setRequestReferences(requestReferences);
357                 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/unassign";
358                 ResponseEntity<String> response = sendRequest(inputStream("/ServiceUnassign.json"), uri, HttpMethod.POST);
359                 
360                 ObjectMapper mapper = new ObjectMapper();
361                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
362                 
363                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
364                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
365                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
366         }
367         @Test
368         public void createPortConfiguration() throws JsonParseException, JsonMappingException, IOException {
369                 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
370                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
371                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
372                 headers.set("X-TransactionID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
373                 //expected response
374                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
375                 RequestReferences requestReferences = new RequestReferences();
376                 requestReferences.setInstanceId("1882939");
377                 expectedResponse.setRequestReferences(requestReferences);
378                 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
379                 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST);
380                 
381                 ObjectMapper mapper = new ObjectMapper();
382                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
383                 
384                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
385                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
386                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));         
387                 assertTrue(response.getBody().contains("1882939"));
388         }
389         @Test
390         public void createPortConfigurationEmptyProductFamilyId() throws JsonParseException, JsonMappingException, IOException {
391                 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
392                 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST);
393                 
394                 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());    
395         }
396         @Test
397         public void deletePortConfiguration() throws JsonParseException, JsonMappingException, IOException {
398                 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
399                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
400                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
401                 
402                 headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
403                 //expected response
404                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
405                 RequestReferences requestReferences = new RequestReferences();
406                 requestReferences.setInstanceId("1882939");
407                 expectedResponse.setRequestReferences(requestReferences);
408                 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970";
409                 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstance.json"), uri, HttpMethod.DELETE);
410                 
411                 ObjectMapper mapper = new ObjectMapper();
412                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
413                 
414                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
415                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
416                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));         
417         }
418         @Test
419         public void enablePort() throws JsonParseException, JsonMappingException, IOException {
420                 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
421                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
422                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
423                 //expected response
424                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
425                 RequestReferences requestReferences = new RequestReferences();
426                 requestReferences.setInstanceId("1882939");
427                 expectedResponse.setRequestReferences(requestReferences);
428                 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/enablePort";
429                 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEnablePort.json"), uri, HttpMethod.POST);
430                 
431                 ObjectMapper mapper = new ObjectMapper();
432                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
433                 
434                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
435                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
436                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
437         }
438         @Test
439         public void disablePort() throws JsonParseException, JsonMappingException, IOException {
440                 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
441                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
442                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
443                 //expected response
444                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
445                 RequestReferences requestReferences = new RequestReferences();
446                 requestReferences.setInstanceId("1882939");
447                 expectedResponse.setRequestReferences(requestReferences);
448                 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/disablePort";
449                 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDisablePort.json"), uri, HttpMethod.POST);
450                 
451                 ObjectMapper mapper = new ObjectMapper();
452                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
453                 
454                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
455                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
456                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
457         }
458         @Test
459         public void activatePort() throws JsonParseException, JsonMappingException, IOException {
460                 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
461                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
462                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
463                 //expected response
464                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
465                 RequestReferences requestReferences = new RequestReferences();
466                 requestReferences.setInstanceId("1882939");
467                 expectedResponse.setRequestReferences(requestReferences);
468                 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/activate";
469                 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivatePort.json"), uri, HttpMethod.POST);
470                 
471                 ObjectMapper mapper = new ObjectMapper();
472                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
473                 
474                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
475                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
476                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
477         }
478         @Test
479         public void deactivatePort() throws JsonParseException, JsonMappingException, IOException {
480                 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
481                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
482                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
483                 //expected response
484                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
485                 RequestReferences requestReferences = new RequestReferences();
486                 requestReferences.setInstanceId("1882939");
487                 expectedResponse.setRequestReferences(requestReferences);
488                 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/deactivate";
489                 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDeactivatePort.json"), uri, HttpMethod.POST);
490                 
491                 ObjectMapper mapper = new ObjectMapper();
492                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
493                 
494                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
495                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
496                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
497         }
498         @Test
499         public void addRelationships() throws JsonParseException, JsonMappingException, IOException {
500                 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
501                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
502                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
503                 
504                 //expected response
505                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
506                 RequestReferences requestReferences = new RequestReferences();
507                 requestReferences.setInstanceId("1882939");
508                 expectedResponse.setRequestReferences(requestReferences);
509                 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/addRelationships";
510                 ResponseEntity<String> response = sendRequest(inputStream("/AddRelationships.json"), uri, HttpMethod.POST);
511                 
512                 ObjectMapper mapper = new ObjectMapper();
513                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
514                 
515                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
516                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
517                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
518         }
519         @Test
520         public void removeRelationships() throws JsonParseException, JsonMappingException, IOException {
521                 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
522                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
523                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
524                 
525                 //expected response
526                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
527                 RequestReferences requestReferences = new RequestReferences();
528                 requestReferences.setInstanceId("1882939");
529                 expectedResponse.setRequestReferences(requestReferences);
530                 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/removeRelationships";
531                 ResponseEntity<String> response = sendRequest(inputStream("/RemoveRelationships.json"), uri, HttpMethod.POST);
532                 
533                 ObjectMapper mapper = new ObjectMapper();
534                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
535                 
536                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
537                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
538                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
539         }
540         @Test
541         public void createVnfInstanceNoALaCarte() throws JsonParseException, JsonMappingException, IOException {
542                 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
543                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
544                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
545                 
546                 //expected response
547                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
548                 RequestReferences requestReferences = new RequestReferences();
549                 requestReferences.setInstanceId("1882939");
550                 expectedResponse.setRequestReferences(requestReferences);
551                 uri = servInstanceuri + "v7" + "/serviceInstances/49585b36-2b5a-443a-8b10-c75d34bb5e46/vnfs";
552                 ResponseEntity<String> response = sendRequest(inputStream("/VnfCreateDefault.json"), uri, HttpMethod.POST);
553                 
554                 ObjectMapper mapper = new ObjectMapper();
555                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
556                 
557                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
558                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
559                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
560         }
561         @Test
562         public void createVnfInstance() throws JsonParseException, JsonMappingException, IOException {
563                 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
564                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
565                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
566                 
567                 String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c3";
568                 headers.set(MsoLogger.TRANSACTION_ID, requestId);
569                 //expected response
570                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
571                 RequestReferences requestReferences = new RequestReferences();
572                 requestReferences.setInstanceId("1882939");
573                 expectedResponse.setRequestReferences(requestReferences);
574                 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
575                 ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstance.json"), uri, HttpMethod.POST);
576                 
577                 ObjectMapper mapper = new ObjectMapper();
578                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
579                 
580                 InfraActiveRequests record = iar.findOneByRequestId(requestId);
581                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
582                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
583                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
584                 assertTrue(response.getBody().contains("1882939"));
585                 assertEquals(record.getVnfType(), "vSAMP12/test");
586         }
587         @Test
588         public void createVnfWithServiceRelatedInstanceFail() throws JsonParseException, JsonMappingException, IOException {
589                 uri = servInstanceUriPrev7 + "v6" + "/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs";
590                 ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstanceFail.json"), uri, HttpMethod.POST);
591                 
592                 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
593         }
594         @Test
595         public void createVnfInstanceInvalidVnfResource() throws JsonParseException, JsonMappingException, IOException {                
596                 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
597                 ResponseEntity<String> response = sendRequest(inputStream("/NoVnfResource.json"), uri, HttpMethod.POST);
598                 
599                 ObjectMapper mapper = new ObjectMapper();
600                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
601                 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
602                 
603                 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
604                 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
605                 assertTrue(realResponse.getServiceException().getText().equals("No valid vnfResource is specified"));
606         }
607         @Test
608         public void replaceVnfInstance() throws JsonParseException, JsonMappingException, IOException {
609                 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
610                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
611                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
612                 
613                 //expected response
614                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
615                 RequestReferences requestReferences = new RequestReferences();
616                 requestReferences.setInstanceId("1882939");
617                 expectedResponse.setRequestReferences(requestReferences);
618                 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
619                 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnf.json"), uri, HttpMethod.POST);
620                 
621                 ObjectMapper mapper = new ObjectMapper();
622                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
623                 
624                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
625                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
626                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
627         }
628         @Test
629         public void replaceVnfRecreateInstance() throws JsonParseException, JsonMappingException, IOException {
630                 stubFor(post(urlPathEqualTo("/mso/async/services/RecreateInfraVce"))
631                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
632                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
633                 
634                 //expected response
635                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
636                 RequestReferences requestReferences = new RequestReferences();
637                 requestReferences.setInstanceId("1882939");
638                 expectedResponse.setRequestReferences(requestReferences);
639                 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
640                 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnfRecreate.json"), uri, HttpMethod.POST);
641                 logger.debug(response.getBody());
642                 ObjectMapper mapper = new ObjectMapper();
643                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
644                 
645                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
646                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
647                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
648         }
649         @Test
650         public void updateVnfInstance() throws JsonParseException, JsonMappingException, IOException {  
651                 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
652                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
653                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
654                 
655                 //expected response
656                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
657                 RequestReferences requestReferences = new RequestReferences();
658                 requestReferences.setInstanceId("1882939");
659                 expectedResponse.setRequestReferences(requestReferences);
660                 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
661                 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVnf.json"), uri, HttpMethod.PUT);
662                 
663                 ObjectMapper mapper = new ObjectMapper();
664                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
665                 
666                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
667                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
668                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
669         }
670         @Test
671         public void applyUpdatedConfig() throws JsonParseException, JsonMappingException, IOException {                 
672                 stubFor(post(urlPathEqualTo("/mso/async/services/VnfConfigUpdate"))
673                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
674                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
675                 
676                 String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c5";
677                 headers.set(MsoLogger.TRANSACTION_ID, requestId);
678                 //expected response
679                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
680                 RequestReferences requestReferences = new RequestReferences();
681                 requestReferences.setInstanceId("1882939");
682                 expectedResponse.setRequestReferences(requestReferences);
683                 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/applyUpdatedConfig";
684                 ResponseEntity<String> response = sendRequest(inputStream("/ApplyUpdatedConfig.json"), uri, HttpMethod.POST);
685                 
686                 ObjectMapper mapper = new ObjectMapper();
687                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
688                 
689                 InfraActiveRequests record = iar.findOneByRequestId(requestId);
690                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
691                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
692                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
693                 assertNull(record.getVnfType());
694         }
695         @Test
696         public void deleteVnfInstanceV5() throws JsonParseException, JsonMappingException, IOException {
697                 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
698                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
699                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
700                 
701                 //expected response
702                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
703                 RequestReferences requestReferences = new RequestReferences();
704                 requestReferences.setInstanceId("1882939");
705                 expectedResponse.setRequestReferences(requestReferences);
706                 uri = servInstanceuri + "v5" + "/serviceInstances/e446b97d-9c35-437a-95a2-6b4c542c4507/vnfs/49befbfe-fccb-421d-bb4c-0734a43f5ea0";
707                 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVnfV5.json"), uri, HttpMethod.DELETE);
708                 
709                 ObjectMapper mapper = new ObjectMapper();
710                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
711                 
712                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
713                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
714                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
715         }
716         @Test
717         public void createVfModuleInstance() throws JsonParseException, JsonMappingException, IOException {
718                 stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
719                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
720                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
721                 
722                 //expected response
723                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
724                 RequestReferences requestReferences = new RequestReferences();
725                 requestReferences.setInstanceId("1882939");
726                 expectedResponse.setRequestReferences(requestReferences);
727                 uri = servInstanceuri + "v7" + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules";
728                 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleWithRelatedInstances.json"), uri, HttpMethod.POST);
729                 
730                 ObjectMapper mapper = new ObjectMapper();
731                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
732                 
733                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
734                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
735                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
736                 assertTrue(response.getBody().contains("1882939"));
737         }
738         @Test
739         public void createVfModuleInstanceNoModelCustomization() throws JsonParseException, JsonMappingException, IOException {
740                 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
741                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
742                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
743                 
744                 //expected response
745                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
746                 RequestReferences requestReferences = new RequestReferences();
747                 requestReferences.setInstanceId("1882939");
748                 expectedResponse.setRequestReferences(requestReferences);
749                 uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
750                 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoModelCustomization.json"), uri, HttpMethod.POST);
751                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
752                 ObjectMapper mapper = new ObjectMapper();
753                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
754                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
755         }
756         @Test
757         public void deleteVfModuleInstanceNoMatchingModelUUD() throws JsonParseException, JsonMappingException, IOException {
758                 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
759                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
760                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
761                 
762                 //expected response
763                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
764                 RequestReferences requestReferences = new RequestReferences();
765                 requestReferences.setInstanceId("1882939");
766                 expectedResponse.setRequestReferences(requestReferences);
767                 uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
768                 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoMatchingModelUUID.json"), uri, HttpMethod.DELETE);
769                 
770                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
771                 ObjectMapper mapper = new ObjectMapper();
772                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
773                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
774         }
775         @Test
776         public void createVfModuleInstanceNoRecipe() throws JsonParseException, JsonMappingException, IOException {
777                 uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
778                 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleInvalid.json"), uri, HttpMethod.POST);
779                 
780                 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
781                 ObjectMapper mapper = new ObjectMapper();
782                 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE,  true);
783                 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
784                 assertTrue(realResponse.getServiceException().getText().equals("No valid vfModuleCustomization is specified"));
785         }
786         @Test
787         public void replaceVfModuleInstance() throws JsonParseException, JsonMappingException, IOException {
788                 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
789                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
790                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
791                 
792                 //expected response
793                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
794                 RequestReferences requestReferences = new RequestReferences();
795                 requestReferences.setInstanceId("1882939");
796                 expectedResponse.setRequestReferences(requestReferences);
797                 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
798                 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVfModule.json"), uri, HttpMethod.POST);
799                 
800                 ObjectMapper mapper = new ObjectMapper();
801                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
802                 
803                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
804                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
805                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
806         }
807         @Test
808         public void updateVfModuleInstance() throws JsonParseException, JsonMappingException, IOException {
809                 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
810                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
811                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
812                 
813                 //expected response
814                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
815                 RequestReferences requestReferences = new RequestReferences();
816                 requestReferences.setInstanceId("1882939");
817                 expectedResponse.setRequestReferences(requestReferences);
818                 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
819                 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVfModule.json"), uri, HttpMethod.PUT);
820                 logger.debug(response.getBody());
821                 
822                 ObjectMapper mapper = new ObjectMapper();
823                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
824                 
825                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
826                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
827                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
828         }
829         @Test
830         public void createVfModuleNoModelType() throws JsonParseException, JsonMappingException, IOException{
831                 headers.set(MsoLogger.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
832                 InfraActiveRequests expectedRecord = new InfraActiveRequests();
833                 expectedRecord.setRequestStatus("FAILED");
834                 expectedRecord.setAction("createInstance");
835                 expectedRecord.setStatusMessage("Error parsing request: No valid modelType is specified");
836                 expectedRecord.setProgress(new Long(100));
837                 expectedRecord.setSource("VID");
838                 expectedRecord.setRequestBody(inputStream("/VfModuleNoModelType.json"));
839                 expectedRecord.setLastModifiedBy("APIH");
840                 expectedRecord.setVfModuleName("testVfModule2");
841                 expectedRecord.setVfModuleModelName("serviceModel");
842                 expectedRecord.setRequestScope("vfModule");
843                 expectedRecord.setRequestAction("createInstance");
844                 expectedRecord.setRequestorId("zz9999");
845                 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
846                 //VnfType is not sent in this request, should be blank in db
847                 expectedRecord.setVnfType("");
848                 uri = servInstanceuri + "v5/serviceInstances/32807a28-1a14-4b88-b7b3-2950918aa76d/vnfs/32807a28-1a14-4b88-b7b3-2950918aa76d/vfModules";
849                 
850                 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoModelType.json"), uri, HttpMethod.POST);
851                 //ActualRecord
852                 InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
853                 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
854                 assertEquals(sameBeanAs(expectedRecord).toString(), sameBeanAs(requestRecord).ignoring("startTime").ignoring("endTime").ignoring("modifyTime").toString());
855                 assertNotNull(requestRecord.getStartTime());
856                 assertNotNull(requestRecord.getEndTime());
857         }
858         @Test
859         public void inPlaceSoftwareUpdate() throws JsonParseException, JsonMappingException, IOException {                      
860                 stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate"))
861                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
862                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
863                 
864                 //expected response
865                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
866                 RequestReferences requestReferences = new RequestReferences();
867                 requestReferences.setInstanceId("1882939");
868                 expectedResponse.setRequestReferences(requestReferences);
869                 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/inPlaceSoftwareUpdate";
870                 ResponseEntity<String> response = sendRequest(inputStream("/InPlaceSoftwareUpdate.json"), uri, HttpMethod.POST);
871                 
872                 ObjectMapper mapper = new ObjectMapper();
873                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
874                 
875                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
876                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
877                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
878         }
879         
880         @Test
881         public void inPlaceSoftwareUpdateDuplicate() throws JsonParseException, JsonMappingException, IOException {                     
882                 stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate"))
883                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
884                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
885                 
886                 InfraActiveRequests req = new InfraActiveRequests();
887                 req.setRequestStatus("IN_PROGRESS");
888                 req.setAction("inPlaceSoftwareUpdate");
889                 req.setProgress(new Long(10));
890                 req.setRequestBody(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"));
891                 req.setServiceInstanceId("f7ce78bb-423b-11e7-93f8-0050569a7908");
892                 req.setVnfId("ff305d54-75b4-431b-adb2-eb6b9e5ff033");
893                 req.setRequestScope("vnf");
894                 req.setVnfName("duplicateCheck123");
895                 req.setRequestAction("inPlaceSoftwareUpdate");
896                 req.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
897                 iar.save(req);
898                 
899                 //expected response
900                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
901                 RequestReferences requestReferences = new RequestReferences();
902                 requestReferences.setInstanceId("1882939");
903                 expectedResponse.setRequestReferences(requestReferences);
904                 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7908/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff033/inPlaceSoftwareUpdate";
905                 ResponseEntity<String> response = sendRequest(inputStream("/InPlaceSoftwareUpdate2.json"), uri, HttpMethod.POST);
906                 
907                 ObjectMapper mapper = new ObjectMapper();
908                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
909                 
910                 assertEquals(Response.Status.CONFLICT.getStatusCode(), response.getStatusCode().value());
911                 
912                 InfraActiveRequests newRecord = iar.findOneByRequestBody(inputStream("/InPlaceSoftwareUpdate2.json"));
913                 
914                 assertNotNull(newRecord.getServiceInstanceId());
915                 assertNotNull(newRecord.getVnfId());
916                 
917         }
918         
919         @Test
920         public void deleteVfModuleInstance() throws JsonParseException, JsonMappingException, IOException {
921                 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
922                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
923                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
924                 
925                 //expected response
926                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
927                 RequestReferences requestReferences = new RequestReferences();
928                 requestReferences.setInstanceId("1882939");
929                 expectedResponse.setRequestReferences(requestReferences);
930                 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
931                 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVfModule.json"), uri, HttpMethod.DELETE);
932                 
933                 ObjectMapper mapper = new ObjectMapper();
934                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
935                 
936                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
937                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
938                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
939         }
940         @Test
941         public void deactivateAndCloudDeleteVfModuleInstance() throws JsonParseException, JsonMappingException, IOException {
942                 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
943                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
944                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
945                 
946                 //expected response
947                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
948                 RequestReferences requestReferences = new RequestReferences();
949                 requestReferences.setInstanceId("1882939");
950                 expectedResponse.setRequestReferences(requestReferences);
951                 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/deactivateAndCloudDelete";
952                 ResponseEntity<String> response = sendRequest(inputStream("/DeactivateAndCloudDeleteVfModule.json"), uri, HttpMethod.POST);
953                 
954                 ObjectMapper mapper = new ObjectMapper();
955                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
956                 
957                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
958                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
959                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
960         }
961         @Test
962         public void createVolumeGroupInstance() throws JsonParseException, JsonMappingException, IOException {
963                 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
964                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
965                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
966                 
967                 //expected response
968                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
969                 RequestReferences requestReferences = new RequestReferences();
970                 requestReferences.setInstanceId("1882939");
971                 expectedResponse.setRequestReferences(requestReferences);
972                 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups";
973                 ResponseEntity<String> response = sendRequest(inputStream("/VolumeGroup.json"), uri, HttpMethod.POST);
974                 
975                 ObjectMapper mapper = new ObjectMapper();
976                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
977                 
978                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
979                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
980                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
981                 assertTrue(response.getBody().contains("1882939"));
982         }
983         @Test
984         public void updateVolumeGroupInstance() throws JsonParseException, JsonMappingException, IOException {
985                 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
986                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
987                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
988                 
989                 //expected response
990                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
991                 RequestReferences requestReferences = new RequestReferences();
992                 requestReferences.setInstanceId("1882939");
993                 expectedResponse.setRequestReferences(requestReferences);
994                 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
995                 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVolumeGroup.json"), uri, HttpMethod.PUT);
996                 
997                 ObjectMapper mapper = new ObjectMapper();
998                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
999                 
1000                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1001                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1002                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
1003         }
1004         @Test
1005         public void deleteVolumeGroupInstance() throws JsonParseException, JsonMappingException, IOException {
1006                 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1007                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
1008                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1009                 
1010                 //expected response
1011                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1012                 RequestReferences requestReferences = new RequestReferences();
1013                 requestReferences.setInstanceId("1882939");
1014                 expectedResponse.setRequestReferences(requestReferences);
1015                 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1016                 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVolumeGroup.json"), uri, HttpMethod.DELETE);
1017                 
1018                 ObjectMapper mapper = new ObjectMapper();
1019                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1020                 
1021                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1022                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1023                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
1024         }
1025         @Test
1026         public void createNetworkInstance() throws JsonParseException, JsonMappingException, IOException {
1027                 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1028                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
1029                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1030                 
1031                 String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c4";
1032                 headers.set(MsoLogger.TRANSACTION_ID, requestId);
1033                 //expected response
1034                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1035                 RequestReferences requestReferences = new RequestReferences();
1036                 requestReferences.setInstanceId("1882939");
1037                 expectedResponse.setRequestReferences(requestReferences);
1038                 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1039                 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreate.json"), uri, HttpMethod.POST);
1040                 
1041                 ObjectMapper mapper = new ObjectMapper();
1042                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1043                 
1044                 InfraActiveRequests record = iar.findOneByRequestId(requestId);
1045                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1046                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1047                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
1048                 assertEquals(record.getNetworkType(), "TestNetworkType");
1049         }
1050         @Test
1051         public void updateNetworkInstance() throws JsonParseException, JsonMappingException, IOException {
1052                 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1053                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
1054                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1055                 
1056                 //expected response
1057                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1058                 RequestReferences requestReferences = new RequestReferences();
1059                 requestReferences.setInstanceId("1882939");
1060                 expectedResponse.setRequestReferences(requestReferences);
1061                 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1062                 ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT);
1063                 
1064                 ObjectMapper mapper = new ObjectMapper();
1065                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1066                 
1067                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1068                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1069                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
1070                 assertTrue(response.getBody().contains("1882939"));
1071         }
1072         @Test
1073         public void deleteNetworkInstance() throws JsonParseException, JsonMappingException, IOException {
1074                 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1075                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
1076                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1077                 
1078                 //expected response
1079                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1080                 RequestReferences requestReferences = new RequestReferences();
1081                 requestReferences.setInstanceId("1882939");
1082                 expectedResponse.setRequestReferences(requestReferences);
1083                 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1084                 ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE);
1085                 
1086                 ObjectMapper mapper = new ObjectMapper();
1087                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1088                 
1089                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1090                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1091                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
1092         }
1093         @Test
1094         public void deleteNetworkInstanceNoReqParams() throws JsonParseException, JsonMappingException, IOException {
1095                 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1096                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
1097                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1098                 
1099                 //expected response
1100                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1101                 RequestReferences requestReferences = new RequestReferences();
1102                 requestReferences.setInstanceId("1882939");
1103                 expectedResponse.setRequestReferences(requestReferences);
1104                 uri = servInstanceuri + "v6" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1105                 ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstanceNoReqParams.json"), uri, HttpMethod.DELETE);
1106                 
1107                 ObjectMapper mapper = new ObjectMapper();
1108                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1109                 
1110                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1111                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1112                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
1113         }
1114         @Test
1115         public void convertJsonToServiceInstanceRequestFail() throws JsonParseException, JsonMappingException, IOException {
1116                 headers.set(MsoLogger.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
1117                 //ExpectedRecord
1118                 InfraActiveRequests expectedRecord = new InfraActiveRequests();
1119                 expectedRecord.setRequestStatus("FAILED");
1120                 expectedRecord.setStatusMessage("Error mapping request: ");
1121                 expectedRecord.setProgress(new Long(100));
1122                 expectedRecord.setRequestBody(inputStream("/ConvertRequestFail.json"));
1123                 expectedRecord.setLastModifiedBy("APIH");
1124                 expectedRecord.setRequestScope("network");
1125                 expectedRecord.setRequestAction("deleteInstance");
1126                 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1127         
1128                 uri = servInstanceuri + "v6" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1129                 ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.DELETE);
1130         
1131                 //ActualRecord
1132                 InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1133                 
1134                 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1135                 assertThat(expectedRecord, sameBeanAs(requestRecord).ignoring("startTime").ignoring("endTime").ignoring("modifyTime").ignoring("statusMessage"));
1136                 assertThat(requestRecord.getStatusMessage(), containsString("Error mapping request: "));
1137                 assertNotNull(requestRecord.getStartTime());
1138                 assertNotNull(requestRecord.getEndTime());
1139         }
1140         @Test
1141         public void convertJsonToServiceInstanceRequestConfigurationFail() throws JsonParseException, JsonMappingException, IOException {
1142                 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/configurations/test/enablePort";
1143                 ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.POST);
1144         
1145                 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1146         }
1147         
1148         @Test
1149         public void creatServiceInstanceGRTestApiNoCustomRecipeFound() throws IOException {
1150                 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1151                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
1152                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1153                 
1154                 uri = servInstanceuri + "v7" + "/serviceInstances";
1155                 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceMacro.json"), uri, HttpMethod.POST);
1156                 
1157                 //expected response
1158                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1159                 RequestReferences requestReferences = new RequestReferences();
1160                 requestReferences.setInstanceId("1882939");
1161                 expectedResponse.setRequestReferences(requestReferences);
1162                 
1163                 ObjectMapper mapper = new ObjectMapper();
1164                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1165                 
1166                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1167                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1168                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
1169         }
1170         
1171         @Test
1172         public void createNetworkInstanceTestApiUndefinedUsePropertiesDefault() throws IOException {
1173                 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1174                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
1175                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1176                 
1177                 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1178                 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateAlternateInstanceName.json"), uri, HttpMethod.POST);
1179                 
1180                 //expected response
1181                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1182                 RequestReferences requestReferences = new RequestReferences();
1183                 requestReferences.setInstanceId("1882939");
1184                 expectedResponse.setRequestReferences(requestReferences);
1185                 
1186                 ObjectMapper mapper = new ObjectMapper();
1187                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1188                 
1189                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1190                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1191                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
1192         }
1193         
1194         @Test
1195         public void createNetworkInstanceTestApiIncorrectUsePropertiesDefault() throws IOException {
1196                 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1197                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
1198                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1199                 
1200                 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1201                 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiIncorrect.json"), uri, HttpMethod.POST);
1202                 
1203                 //expected response
1204                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1205                 RequestReferences requestReferences = new RequestReferences();
1206                 requestReferences.setInstanceId("1882939");
1207                 expectedResponse.setRequestReferences(requestReferences);
1208                 
1209                 ObjectMapper mapper = new ObjectMapper();
1210                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1211                 
1212                 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
1213         }
1214         
1215         @Test
1216         public void createNetworkInstanceTestApiGrApi() throws IOException {
1217                 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1218                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
1219                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1220                 
1221                 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1222                 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiGrApi.json"), uri, HttpMethod.POST);
1223                 
1224                 //expected response
1225                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1226                 RequestReferences requestReferences = new RequestReferences();
1227                 requestReferences.setInstanceId("1882939");
1228                 expectedResponse.setRequestReferences(requestReferences);
1229                 
1230                 ObjectMapper mapper = new ObjectMapper();
1231                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1232                 
1233                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1234                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1235                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
1236         }
1237         
1238         @Test
1239         public void createNetworkInstanceTestApiVnfApi() throws IOException {
1240                 stubFor(post(urlPathEqualTo("/mso/async/services/CreateNetworkInstance"))
1241                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
1242                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1243                 
1244                 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1245                 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiVnfApi.json"), uri, HttpMethod.POST);
1246                 
1247                 //expected response
1248                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1249                 RequestReferences requestReferences = new RequestReferences();
1250                 requestReferences.setInstanceId("1882939");
1251                 expectedResponse.setRequestReferences(requestReferences);
1252                 
1253                 ObjectMapper mapper = new ObjectMapper();
1254                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1255                 
1256                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1257                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1258                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
1259         }
1260         
1261         @Test
1262         public void activateServiceInstanceRequestStatus() throws JsonParseException, JsonMappingException, IOException{
1263                 stubFor(post(urlPathEqualTo("/mso/async/services/ActivateInstance"))
1264                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
1265                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1266                 headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
1267                 
1268                 InfraActiveRequests expectedRecord = new InfraActiveRequests();
1269                 expectedRecord.setRequestStatus("FAILED");
1270                 expectedRecord.setAction("activateInstance");
1271                 expectedRecord.setStatusMessage("Recipe could not be retrieved from catalog DB.");
1272                 expectedRecord.setProgress(new Long(100));
1273                 expectedRecord.setSource("VID");
1274                 expectedRecord.setRequestBody(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"));
1275                 expectedRecord.setLastModifiedBy("APIH");
1276                 expectedRecord.setServiceInstanceId("f7ce78bb-423b-11e7-93f8-0050569a7999");
1277                 expectedRecord.setServiceInstanceName("testService1234");
1278                 expectedRecord.setRequestScope("service");
1279                 expectedRecord.setRequestAction("activateInstance");
1280                 expectedRecord.setRequestorId("xxxxxx");
1281                 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1282                 
1283                 //expect
1284                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1285                 RequestReferences requestReferences = new RequestReferences();
1286                 requestReferences.setInstanceId("1882939");
1287                 expectedResponse.setRequestReferences(requestReferences);
1288                 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7999/activate";
1289                 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev8.json"), uri, HttpMethod.POST);
1290                                 
1291                 ObjectMapper mapper = new ObjectMapper();
1292                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1293                 
1294                 InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1295                 
1296                 //then          
1297                 assertEquals(Status.IN_PROGRESS.name(), requestRecord.getRequestStatus());
1298                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1299                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1300                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
1301         }
1302         
1303         @Test
1304         public void invalidRequestId() throws IOException {
1305                 String illegalRequestId = "1234";
1306                 headers.set("X-ECOMP-RequestID", illegalRequestId);
1307
1308                 uri = servInstanceuri + "v5/serviceInstances";
1309                 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
1310                 
1311                 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
1312                 assertTrue(response.getBody().contains("Request Id " + illegalRequestId + " is not a valid UUID"));
1313         }
1314         @Test
1315         public void invalidBPELResponse() throws IOException{
1316                 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1317                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
1318                                                 .withBodyFile("Camunda/TestResponseInvalid2.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1319                 
1320                 uri = servInstanceuri + "v5/serviceInstances";
1321                 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
1322                                 
1323                 ObjectMapper mapper = new ObjectMapper();
1324                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1325                 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
1326         
1327                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1328                 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
1329                 assertEquals("Request Failed due to BPEL error with HTTP Status = 202{\"instanceId\": \"1882939\"}", realResponse.getServiceException().getText());
1330         }
1331         
1332         @Test
1333         public void invalidBPELResponse2() throws IOException{
1334                 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1335                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
1336                                                 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1337                 
1338                 uri = servInstanceuri + "v5/serviceInstances";
1339                 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
1340                                 
1341                 ObjectMapper mapper = new ObjectMapper();
1342                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1343                 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
1344         
1345                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1346                 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
1347                 assertTrue(realResponse.getServiceException().getText().contains("<aetgt:ErrorMessage>Exception in create execution list 500"));
1348         }
1349         
1350         @Test
1351         public void createMacroServiceInstance() throws JsonParseException, JsonMappingException, IOException{
1352                 stubFor(post(urlPathEqualTo("/mso/async/services/CreateMacroServiceNetworkVnf"))
1353                                 .willReturn(aResponse().withHeader("Content-Type", "application/json")
1354                                                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1355                 
1356                 //expect
1357                 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1358                 RequestReferences requestReferences = new RequestReferences();
1359                 requestReferences.setInstanceId("1882939");
1360                 expectedResponse.setRequestReferences(requestReferences);
1361                 uri = servInstanceUriPrev7 + "v5";
1362                 ResponseEntity<String> response = sendRequest(inputStream("/MacroServiceInstance.json"), uri, HttpMethod.POST);
1363                                 
1364                 ObjectMapper mapper = new ObjectMapper();
1365                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1366         
1367                 //then          
1368                 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1369                 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1370                 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); 
1371         }
1372         
1373         @Test
1374         public void testUserParams() throws JsonParseException, JsonMappingException, IOException {
1375                 ObjectMapper mapper = new ObjectMapper();
1376                 ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
1377                 RequestParameters requestParameters = request.getRequestDetails().getRequestParameters();
1378                 String userParamsTxt = inputStream("/userParams.txt");
1379                 
1380                 List<Map<String, Object>> userParams = servInstances.configureUserParams(requestParameters);
1381                 System.out.println(userParams);
1382                 assertTrue(userParams.size() > 0);
1383                 assertTrue(userParams.get(0).containsKey("name"));
1384                 assertTrue(userParams.get(0).containsKey("value"));
1385                 assertTrue(userParamsTxt.replaceAll("\\s+","").equals(userParams.toString().replaceAll("\\s+","")));
1386         }
1387         
1388         @Test
1389         public void testConfigureCloudConfig() throws IOException {
1390                 ObjectMapper mapper = new ObjectMapper();
1391                 ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
1392                 CloudConfiguration cloudConfig = servInstances.configureCloudConfig(request.getRequestDetails().getRequestParameters());
1393                 
1394                 assertEquals("mdt25b", cloudConfig.getLcpCloudRegionId());
1395                 assertEquals("aefb697db6524ddebfe4915591b0a347", cloudConfig.getTenantId());
1396         }
1397         
1398         @Test
1399         public void testMapToLegacyRequest() throws IOException {
1400                 ObjectMapper mapper = new ObjectMapper();
1401                 ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
1402                 ServiceInstancesRequest expected = mapper.readValue(inputStream("/LegacyMacroServiceInstance.json"), ServiceInstancesRequest.class);
1403                 servInstances.mapToLegacyRequest(request.getRequestDetails());
1404                 System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(request));
1405                 assertThat(request, sameBeanAs(expected));
1406         }
1407 }