diff options
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/test/java')
7 files changed, 166 insertions, 264 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandlerTest.java index f7e605bcc5..45fadb540a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandlerTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandlerTest.java @@ -24,10 +24,10 @@ import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Matchers.anyObject; -import static org.mockito.Matchers.anyString; +import static org.mockito.ArgumentMatchers.anyObject; +import static org.mockito.ArgumentMatchers.anyString; import java.net.URI; import java.util.Collections; import java.util.List; @@ -46,7 +46,7 @@ import org.json.JSONException; import org.junit.Rule; import org.junit.Test; import org.mockito.InjectMocks; -import org.mockito.Matchers; +import org.mockito.ArgumentMatchers; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.Spy; @@ -74,10 +74,10 @@ public class GlobalHealthcheckHandlerTest { ReflectionTestUtils.setField(globalhealth, "actuatorContextPath", "/manage"); ReflectionTestUtils.setField(globalhealth, "endpointBpmn", "http://localhost:8080"); - Mockito.when(restTemplate.exchange(Matchers.any(URI.class), - Matchers.any(HttpMethod.class), - Matchers.<HttpEntity<?>> any(), - Matchers.<Class<Object>> any())).thenReturn(null); + Mockito.when(restTemplate.exchange(ArgumentMatchers.any(URI.class), + ArgumentMatchers.any(HttpMethod.class), + ArgumentMatchers.<HttpEntity<?>> any(), + ArgumentMatchers.<Class<Object>> any())).thenReturn(null); String result = globalhealth.querySubsystemHealth(MsoSubsystems.BPMN); System.out.println(result); @@ -93,10 +93,10 @@ public class GlobalHealthcheckHandlerTest { subSystemResponse.setStatus("UP"); ResponseEntity<Object> r = new ResponseEntity<>(subSystemResponse,HttpStatus.OK); - Mockito.when(restTemplate.exchange(Matchers.any(URI.class), - Matchers.any(HttpMethod.class), - Matchers.<HttpEntity<?>> any(), - Matchers.<Class<Object>> any())).thenReturn(r); + Mockito.when(restTemplate.exchange(ArgumentMatchers.any(URI.class), + ArgumentMatchers.any(HttpMethod.class), + ArgumentMatchers.<HttpEntity<?>> any(), + ArgumentMatchers.<Class<Object>> any())).thenReturn(r); String result = globalhealth.querySubsystemHealth(MsoSubsystems.ASDC); System.out.println(result); @@ -117,10 +117,10 @@ public class GlobalHealthcheckHandlerTest { subSystemResponse.setStatus(status); ResponseEntity<Object> r = new ResponseEntity<>(subSystemResponse,HttpStatus.OK); - Mockito.when(restTemplate.exchange(Matchers.any(URI.class), - Matchers.any(HttpMethod.class), - Matchers.<HttpEntity<?>> any(), - Matchers.<Class<Object>> any())).thenReturn(r); + Mockito.when(restTemplate.exchange(ArgumentMatchers.any(URI.class), + ArgumentMatchers.any(HttpMethod.class), + ArgumentMatchers.<HttpEntity<?>> any(), + ArgumentMatchers.<Class<Object>> any())).thenReturn(r); Mockito.when(requestContext.getProperty(anyString())).thenReturn("1234567890"); Response response = globalhealth.globalHealthcheck(true, requestContext); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java index f84c2be898..5603ee8380 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java @@ -29,6 +29,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; @@ -52,6 +53,8 @@ import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.onap.logging.ref.slf4j.ONAPLogConstants; +import org.onap.so.apihandlerinfra.exceptions.ContactCamundaException; +import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException; import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.beans.ServiceRecipe; import org.onap.so.db.request.beans.InfraActiveRequests; @@ -87,6 +90,7 @@ import ch.qos.logback.classic.spi.ILoggingEvent; public class ServiceInstancesTest extends BaseTest{ private final ObjectMapper mapper = new ObjectMapper(); + private ObjectMapper errorMapper = new ObjectMapper(); @Autowired private ServiceInstances servInstances; @@ -104,6 +108,9 @@ public class ServiceInstancesTest extends BaseTest{ @Before public void beforeClass() { + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + errorMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + errorMapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); // set headers headers = new HttpHeaders(); headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "test_name"); @@ -218,9 +225,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v5/serviceInstances"; ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - //then assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); @@ -290,9 +294,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceUriPrev7 + "v5"; ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev7.json"), uri, HttpMethod.POST, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - //then assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); @@ -461,9 +462,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate"; ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivate.json"), uri, HttpMethod.POST, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -508,9 +506,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/deactivate"; ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDeactivate.json"), uri, HttpMethod.POST, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -553,9 +548,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a8868/"; ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDelete.json"), uri, HttpMethod.DELETE, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -598,9 +590,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v7" + "/serviceInstances/assign"; ResponseEntity<String> response = sendRequest(inputStream("/ServiceAssign.json"), uri, HttpMethod.POST, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -644,9 +633,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/unassign"; ResponseEntity<String> response = sendRequest(inputStream("/ServiceUnassign.json"), uri, HttpMethod.POST, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -665,9 +651,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations"; ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -695,9 +678,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970"; ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstance.json"), uri, HttpMethod.DELETE, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -716,9 +696,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/enablePort"; ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEnablePort.json"), uri, HttpMethod.POST, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -737,9 +714,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/disablePort"; ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDisablePort.json"), uri, HttpMethod.POST, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -758,9 +732,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/activate"; ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivatePort.json"), uri, HttpMethod.POST, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -779,9 +750,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/deactivate"; ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDeactivatePort.json"), uri, HttpMethod.POST, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -800,9 +768,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/addRelationships"; ResponseEntity<String> response = sendRequest(inputStream("/AddRelationships.json"), uri, HttpMethod.POST, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -821,9 +786,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/removeRelationships"; ResponseEntity<String> response = sendRequest(inputStream("/RemoveRelationships.json"), uri, HttpMethod.POST, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -859,9 +821,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v7" + "/serviceInstances/49585b36-2b5a-443a-8b10-c75d34bb5e46/vnfs"; ResponseEntity<String> response = sendRequest(inputStream("/VnfCreateDefault.json"), uri, HttpMethod.POST, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -901,9 +860,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs"; ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstance.json"), uri, HttpMethod.POST, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -920,13 +876,9 @@ public class ServiceInstancesTest extends BaseTest{ public void createVnfInstanceInvalidVnfResource() throws IOException { uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs"; ResponseEntity<String> response = sendRequest(inputStream("/NoVnfResource.json"), uri, HttpMethod.POST); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); - + assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); - RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); + RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class); assertEquals("No valid vnfResource is specified", realResponse.getServiceException().getText()); } @Test @@ -958,9 +910,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace"; ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnf.json"), uri, HttpMethod.POST, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -995,8 +944,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace"; ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnfRecreate.json"), uri, HttpMethod.POST, headers); logger.debug(response.getBody()); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); @@ -1032,8 +979,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/recreate"; ResponseEntity<String> response = sendRequest(inputStream("/VnfRecreate.json"), uri, HttpMethod.POST, headers); logger.debug(response.getBody()); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); @@ -1070,9 +1015,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000"; ResponseEntity<String> response = sendRequest(inputStream("/UpdateVnf.json"), uri, HttpMethod.PUT, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -1099,9 +1041,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/applyUpdatedConfig"; ResponseEntity<String> response = sendRequest(inputStream("/ApplyUpdatedConfig.json"), uri, HttpMethod.POST, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -1125,17 +1064,13 @@ public class ServiceInstancesTest extends BaseTest{ expectedResponse.setRequestReferences(requestReferences); uri = servInstanceuri + "v5" + "/serviceInstances/e446b97d-9c35-437a-95a2-6b4c542c4507/vnfs/49befbfe-fccb-421d-bb4c-0734a43f5ea0"; ResponseEntity<String> response = sendRequest(inputStream("/DeleteVnfV5.json"), uri, HttpMethod.DELETE, headers); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } @Test public void createVfModuleInstance() throws IOException { - stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json")) @@ -1169,9 +1104,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v7" + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules"; ResponseEntity<String> response = sendRequest(inputStream("/VfModuleWithRelatedInstances.json"), uri, HttpMethod.POST, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -1285,6 +1217,7 @@ public class ServiceInstancesTest extends BaseTest{ expectedResponse.setRequestReferences(requestReferences); uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000"; ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoMatchingModelUUID.json"), uri, HttpMethod.DELETE, headers); + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ObjectMapper mapper = new ObjectMapper(); @@ -1318,11 +1251,9 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules"; ResponseEntity<String> response = sendRequest(inputStream("/VfModuleInvalid.json"), uri, HttpMethod.POST, headers); - + assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); - RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); + RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class); assertEquals("No valid vfModuleCustomization is specified", realResponse.getServiceException().getText()); } @Test @@ -1351,9 +1282,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace"; ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVfModule.json"), uri, HttpMethod.POST, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -1395,9 +1323,6 @@ public class ServiceInstancesTest extends BaseTest{ ResponseEntity<String> response = sendRequest(inputStream("/UpdateVfModule.json"), uri, HttpMethod.PUT, headers); logger.debug(response.getBody()); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -1447,9 +1372,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/inPlaceSoftwareUpdate"; ResponseEntity<String> response = sendRequest(inputStream("/InPlaceSoftwareUpdate.json"), uri, HttpMethod.POST, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -1482,9 +1404,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000"; ResponseEntity<String> response = sendRequest(inputStream("/DeleteVfModule.json"), uri, HttpMethod.DELETE, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -1510,9 +1429,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v7" + "/serviceInstances/196b4a84-0858-4317-a1f6-497e2e52ae43/vnfs/36e4f902-ec32-451e-8d53-e3edc19e40a4/vfModules/09f3a38d-933f-450a-8784-9e6c4dec3f72"; ResponseEntity<String> response = sendRequest(inputStream("/DeleteVfModuleNoModelInvariantId.json"), uri, HttpMethod.DELETE, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -1543,10 +1459,7 @@ public class ServiceInstancesTest extends BaseTest{ expectedResponse.setRequestReferences(requestReferences); uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/deactivateAndCloudDelete"; ResponseEntity<String> response = sendRequest(inputStream("/DeactivateAndCloudDeleteVfModule.json"), uri, HttpMethod.POST, headers); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -1582,9 +1495,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups"; ResponseEntity<String> response = sendRequest(inputStream("/VolumeGroup.json"), uri, HttpMethod.POST, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -1621,9 +1531,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000"; ResponseEntity<String> response = sendRequest(inputStream("/UpdateVolumeGroup.json"), uri, HttpMethod.PUT, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -1662,10 +1569,7 @@ public class ServiceInstancesTest extends BaseTest{ expectedResponse.setRequestReferences(requestReferences); uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000"; ResponseEntity<String> response = sendRequest(inputStream("/DeleteVolumeGroup.json"), uri, HttpMethod.DELETE, headers); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -1701,9 +1605,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks"; ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreate.json"), uri, HttpMethod.POST, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -1738,9 +1639,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb"; ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -1759,7 +1657,7 @@ public class ServiceInstancesTest extends BaseTest{ stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) - .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json")) + .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json")) .withStatus(HttpStatus.SC_OK))); stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" + @@ -1777,9 +1675,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb"; ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -1806,9 +1701,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v6" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb"; ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstanceNoReqParams.json"), uri, HttpMethod.DELETE, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -1876,9 +1768,6 @@ public class ServiceInstancesTest extends BaseTest{ requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d")); expectedResponse.setRequestReferences(requestReferences); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -1916,9 +1805,6 @@ public class ServiceInstancesTest extends BaseTest{ requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d")); expectedResponse.setRequestReferences(requestReferences); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -1939,9 +1825,6 @@ public class ServiceInstancesTest extends BaseTest{ requestReferences.setInstanceId("1882939"); expectedResponse.setRequestReferences(requestReferences); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); } @@ -1977,9 +1860,6 @@ public class ServiceInstancesTest extends BaseTest{ requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d")); expectedResponse.setRequestReferences(requestReferences); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -2017,9 +1897,6 @@ public class ServiceInstancesTest extends BaseTest{ requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d")); expectedResponse.setRequestReferences(requestReferences); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -2059,9 +1936,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7999/activate"; ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev8.json"), uri, HttpMethod.POST, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -2106,13 +1980,9 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v5/serviceInstances"; ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); - + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); + RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class); assertEquals("Request Failed due to BPEL error with HTTP Status = 202{\"instanceId\": \"1882939\"}", realResponse.getServiceException().getText()); } @Test @@ -2144,12 +2014,8 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v5/serviceInstances"; ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); - assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); - RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); + RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class); assertEquals("Exception caught mapping Camunda JSON response to object", realResponse.getServiceException().getText()); } @@ -2180,13 +2046,9 @@ public class ServiceInstancesTest extends BaseTest{ .withStatus(HttpStatus.SC_OK))); uri = servInstanceuri + "v5/serviceInstances"; ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); - + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); + RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class); assertTrue(realResponse.getServiceException().getText().contains("<aetgt:ErrorMessage>Exception in create execution list 500")); } @@ -2228,9 +2090,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceUriPrev7 + "v5"; ResponseEntity<String> response = sendRequest(inputStream("/MacroServiceInstance.json"), uri, HttpMethod.POST, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - //then assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); @@ -2311,9 +2170,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v7" + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules/scaleOut"; ResponseEntity<String> response = sendRequest(inputStream("/ScaleOutRequest.json"), uri, HttpMethod.POST, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -2346,13 +2202,9 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v5/serviceInstances"; ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); - + assertEquals(Response.Status.NOT_ACCEPTABLE.getStatusCode(), response.getStatusCode().value()); - RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); + RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class); assertEquals("Exception caught mapping Camunda JSON response to object", realResponse.getServiceException().getText()); } @Test @@ -2363,15 +2215,59 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v5/serviceInstances"; ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); + + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); + RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class); + assertEquals("Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText()); + } + @Test + public void createServiceInstanceDuplicateHistoryCheck() throws IOException{ + stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBodyFile("InfraActiveRequests/createInfraActiveRequests.json") + .withStatus(HttpStatus.SC_ACCEPTED))); + stubFor(get(("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBodyFile("Camunda/HistoryCheckResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + uri = servInstanceuri + "v5/serviceInstances"; + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers); + + assertEquals(Response.Status.CONFLICT.getStatusCode(), response.getStatusCode().value()); + RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class); + assertEquals("Error: Locked instance - This service (testService9) already has a request being worked with a status of UNLOCKED (RequestId - f0a35706-efc4-4e27-80ea-a995d7a2a40f). The existing request must finish or be cleaned up before proceeding.", realResponse.getServiceException().getText()); + } + @Test + public void createServiceInstanceDuplicateHistoryCheckException() throws IOException{ + stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBodyFile("InfraActiveRequests/createInfraActiveRequests.json") + .withStatus(HttpStatus.SC_ACCEPTED))); + stubFor(get(("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(org.apache.http.HttpStatus.SC_INTERNAL_SERVER_ERROR))); + + uri = servInstanceuri + "v5/serviceInstances"; + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers); + + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); + RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class); + assertEquals("Unable to get process-instance history from Camunda for requestId: f0a35706-efc4-4e27-80ea-a995d7a2a40f due to error: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText()); + } + @Test + public void createServiceInstanceDuplicate() throws IOException{ + stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR))); + + uri = servInstanceuri + "v5/serviceInstances"; + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers); assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); - RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); + RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class); assertEquals("Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText()); } + @Test public void createServiceInstanceSaveError() throws IOException{ ServiceRecipe serviceRecipe = new ServiceRecipe(); @@ -2398,12 +2294,8 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v5/serviceInstances"; ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); - assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); - RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); + RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class); assertEquals("Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText()); } @Test @@ -2417,13 +2309,9 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations"; ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); - + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); - RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); + RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class); assertEquals("Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText()); } @Test @@ -2434,13 +2322,9 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations"; ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST, headers); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); - + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); - RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); + RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class); assertEquals("Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText()); } @Test @@ -2474,9 +2358,6 @@ public class ServiceInstancesTest extends BaseTest{ expectedResponse.setRequestReferences(requestReferences); uri = servInstanceuri + "v7/serviceInstances/e05864f0-ab35-47d0-8be4-56fd9619ba3c/vnfs/f501ce76-a9bc-4601-9837-74fd9f4d5eca"; ResponseEntity<String> response = sendRequest(inputStream("/VnfwithNeteworkInstanceGroup.json"), uri, HttpMethod.PUT, headers); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); //then assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); @@ -2506,9 +2387,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "/v7/instanceGroups"; ResponseEntity<String> response = sendRequest(inputStream("/CreateInstanceGroup.json"), uri, HttpMethod.POST, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - //then assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); @@ -2529,9 +2407,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c"; ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - //then assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); @@ -2541,14 +2416,9 @@ public class ServiceInstancesTest extends BaseTest{ public void deleteInstanceGroupNoRequestIdHeader() throws IOException{ uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c"; ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); - //then assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); - RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); + RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class); assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-RequestID header is specified"); } @Test @@ -2557,14 +2427,9 @@ public class ServiceInstancesTest extends BaseTest{ noPartnerHeaders.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4"); uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c"; ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, noPartnerHeaders); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); - //then assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); - RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); + RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class); assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-PartnerName header is specified"); } @Test @@ -2579,14 +2444,10 @@ public class ServiceInstancesTest extends BaseTest{ expectedResponse.setRequestReferences(requestReferences); uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c"; ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, noRequestorIdHheaders); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); - + //then assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); - RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); + RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class); assertEquals(realResponse.getServiceException().getText(), "No valid X-RequestorID header is specified"); } @Test @@ -2603,9 +2464,6 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/addMembers"; ResponseEntity<String> response = sendRequest(inputStream("/AddMembers.json"), uri, HttpMethod.POST, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - //then assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); @@ -2625,15 +2483,55 @@ public class ServiceInstancesTest extends BaseTest{ uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/removeMembers"; ResponseEntity<String> response = sendRequest(inputStream("/RemoveMembers.json"), uri, HttpMethod.POST, headers); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - //then assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } @Test + public void deleteNetworkInstanceNoCustomizationEntry() throws IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_NOT_FOUND))); + + stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" + + "modelName=VNF-API-DEFAULT&action=deleteInstance")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d")); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb"; + ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE, headers); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + @Test + public void updateNetworkInstanceNoCustomizationEntry() throws IOException { + stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_NOT_FOUND))); + + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb"; + ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT, headers); + + assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); + RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class); + assertEquals(realResponse.getServiceException().getText(), "No valid modelCustomizationId for networkResourceCustomization lookup is specified"); + } + + @Test public void setServiceTypeTestALaCarte() throws JsonProcessingException{ String requestScope = ModelType.service.toString(); Boolean aLaCarteFlag = true; diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequestTest.java index afcf0f54c8..9a8f4880f7 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequestTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequestTest.java @@ -26,8 +26,8 @@ import static org.hamcrest.Matchers.startsWith; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.contains; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.contains; import static org.mockito.Mockito.doNothing; import javax.inject.Provider; diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java index f9e3ec6498..b799394b7a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java @@ -29,7 +29,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Matchers.anyString; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; @@ -41,10 +41,10 @@ import java.util.Optional; import org.apache.http.HttpStatus; import org.junit.Test; +import org.onap.aai.domain.yang.OperationalEnvironment; import org.onap.so.apihandlerinfra.BaseTest; import org.onap.so.client.aai.AAIVersion; import org.onap.so.client.aai.entities.AAIResultWrapper; -import org.onap.so.client.aai.objects.AAIOperationalEnvironment; import org.springframework.beans.factory.annotation.Autowired; @@ -60,7 +60,7 @@ public class AAIClientHelperTest extends BaseTest{ .willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironment.json").withStatus(HttpStatus.SC_ACCEPTED))); AAIResultWrapper wrapper = clientHelper.getAaiOperationalEnvironment("EMOE-001"); - Optional<AAIOperationalEnvironment> aaiOpEnv = wrapper.asBean(AAIOperationalEnvironment.class); + Optional<OperationalEnvironment> aaiOpEnv = wrapper.asBean(OperationalEnvironment.class); assertEquals("EMOE-001", aaiOpEnv.get().getOperationalEnvironmentId()); } @@ -69,13 +69,13 @@ public class AAIClientHelperTest extends BaseTest{ stubFor(post(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*")) .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED))); - AAIOperationalEnvironment ecompEnv = new AAIOperationalEnvironment(); + OperationalEnvironment ecompEnv = new OperationalEnvironment(); ecompEnv.setTenantContext("Test"); ecompEnv.setWorkloadContext("ECOMPL_PSL"); try { AAIClientHelper clientHelper = mock(AAIClientHelper.class); - doNothing().when(clientHelper).updateAaiOperationalEnvironment(any(String.class), any(AAIOperationalEnvironment.class)); + doNothing().when(clientHelper).updateAaiOperationalEnvironment(any(String.class), any(OperationalEnvironment.class)); clientHelper.updateAaiOperationalEnvironment("EMOE-001", ecompEnv); verify(clientHelper, times(1)).updateAaiOperationalEnvironment("EMOE-001", ecompEnv); @@ -109,14 +109,14 @@ public class AAIClientHelperTest extends BaseTest{ stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*")) .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED))); - AAIOperationalEnvironment ecompEnv = new AAIOperationalEnvironment(); + OperationalEnvironment ecompEnv = new OperationalEnvironment(); ecompEnv.setOperationalEnvironmentId("opeEvnId"); ecompEnv.setTenantContext("Test"); ecompEnv.setWorkloadContext("ECOMPL_PSL"); try { AAIClientHelper clientHelper = mock(AAIClientHelper.class); - doNothing().when(clientHelper).createOperationalEnvironment(any(AAIOperationalEnvironment.class)); + doNothing().when(clientHelper).createOperationalEnvironment(any(OperationalEnvironment.class)); clientHelper.createOperationalEnvironment(ecompEnv); verify(clientHelper, times(1)).createOperationalEnvironment(ecompEnv); @@ -130,7 +130,7 @@ public class AAIClientHelperTest extends BaseTest{ stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*")) .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED))); - AAIOperationalEnvironment ecompEnv = new AAIOperationalEnvironment(); + OperationalEnvironment ecompEnv = new OperationalEnvironment(); ecompEnv.setTenantContext("Test"); ecompEnv.setWorkloadContext("ECOMPL_PSL"); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilderTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilderTest.java index cf6facc59f..3915fc8928 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilderTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilderTest.java @@ -35,7 +35,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; public class AAIClientObjectBuilderTest extends BaseTest{ - private String expectedAAIObject = "{\"operational-environment-name\":\"TEST_ECOMP_ENVIRONMENT\",\"operational-environment-type\":\"ECOMP\",\"operational-environment-status\":\"Active\",\"tenant-context\":\"TEST\",\"workload-context\":\"ECOMP_TEST\"}"; private CloudOrchestrationRequest request; private ObjectMapper mapper = new ObjectMapper(); @@ -62,8 +61,12 @@ public class AAIClientObjectBuilderTest extends BaseTest{ @Test public void testGetAaiClientObjectBuilder() throws Exception { AAIClientObjectBuilder builder = new AAIClientObjectBuilder(); - assertEquals(expectedAAIObject, mapper.writeValueAsString(builder.buildAAIOperationalEnvironment("Active", request))); + org.onap.aai.domain.yang.OperationalEnvironment operEnv = builder.buildAAIOperationalEnvironment("Active", request); + assertEquals("TEST", operEnv.getTenantContext()); + assertEquals("ECOMP_TEST", operEnv.getWorkloadContext()); + assertEquals("TEST_ECOMP_ENVIRONMENT", operEnv.getOperationalEnvironmentName()); + assertEquals(OperationalEnvironment.ECOMP.toString(), operEnv.getOperationalEnvironmentType()); } - - + + } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java index c36eb2b063..18af7fbaa0 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java @@ -42,6 +42,7 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.onap.aai.domain.yang.OperationalEnvironment; import org.onap.so.apihandlerinfra.BaseTest; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; @@ -54,7 +55,6 @@ import org.onap.so.apihandlerinfra.tenantisolationbeans.RecoveryAction; import org.onap.so.apihandlerinfra.tenantisolationbeans.Manifest; import org.onap.so.client.aai.AAIVersion; import org.onap.so.client.aai.entities.AAIResultWrapper; -import org.onap.so.client.aai.objects.AAIOperationalEnvironment; import org.onap.so.db.request.beans.InfraActiveRequests; import org.springframework.beans.factory.annotation.Autowired; @@ -99,16 +99,17 @@ public class ActivateVnfOperationalEnvironmentTest extends BaseTest{ @Test public void getAAIOperationalEnvironmentTest() { - AAIOperationalEnvironment aaiOpEnv; + OperationalEnvironment aaiOpEnv; stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironment.json").withStatus(HttpStatus.SC_ACCEPTED))); + .willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironmentWithRelationship.json").withStatus(HttpStatus.SC_ACCEPTED))); AAIResultWrapper wrapper = clientHelper.getAaiOperationalEnvironment("EMOE-001"); - aaiOpEnv = wrapper.asBean(AAIOperationalEnvironment.class).get(); + aaiOpEnv = wrapper.asBean(OperationalEnvironment.class).get(); assertEquals("EMOE-001", aaiOpEnv.getOperationalEnvironmentId()); + assertEquals("1dfe7154-eae0-44f2-8e7a-8e5e7882e55d", aaiOpEnv.getRelationshipList().getRelationship().get(0).getRelationshipData().get(0).getRelationshipValue()); assertNotNull(activateVnf.getAAIOperationalEnvironment(operationalEnvironmentId)); - assertEquals( "EMOE-001", activateVnf.getAAIOperationalEnvironment(operationalEnvironmentId).getOperationalEnvironmentId()); + assertEquals( "EMOE-001", activateVnf.getAAIOperationalEnvironment(operationalEnvironmentId).asBean(OperationalEnvironment.class).get().getOperationalEnvironmentId()); } @@ -138,7 +139,7 @@ public class ActivateVnfOperationalEnvironmentTest extends BaseTest{ jsonObject.put("distributionId", sdcDistributionId); stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironment.json").withStatus(HttpStatus.SC_ACCEPTED))); + .willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironmentWithRelationship.json").withStatus(HttpStatus.SC_ACCEPTED))); stubFor(post(urlPathMatching("/sdc/v1/catalog/services/TEST_serviceModelVersionId/distr.*")) .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonObject.toString()).withStatus(HttpStatus.SC_ACCEPTED))); activateVnf.execute(requestId, request); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java index 100bc82f7a..ac274dc8dc 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java @@ -32,11 +32,11 @@ import com.fasterxml.jackson.core.JsonProcessingException; import org.apache.http.HttpStatus; import org.junit.Before; import org.junit.Test; +import org.onap.aai.domain.yang.OperationalEnvironment; import org.onap.so.apihandlerinfra.BaseTest; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest; import org.onap.so.client.aai.AAIVersion; -import org.onap.so.client.aai.objects.AAIOperationalEnvironment; import org.onap.so.client.grm.beans.Property; import org.onap.so.client.grm.beans.ServiceEndPointList; import org.onap.so.db.request.beans.InfraActiveRequests; @@ -102,7 +102,7 @@ public class CreateVnfOperationalEnvironmentTest extends BaseTest{ @Test public void testGetSearchKey() { createVnfOpEnv.setRequest(request); - AAIOperationalEnvironment ecompEnv = new AAIOperationalEnvironment(); + OperationalEnvironment ecompEnv = new OperationalEnvironment(); ecompEnv.setTenantContext("Test"); ecompEnv.setWorkloadContext("ECOMPL_PSL"); assertEquals("Test.ECOMPL_PSL.*", createVnfOpEnv.getSearchKey(ecompEnv)); |