Search in sources :

Example 41 with RequestError

use of org.onap.so.serviceinstancebeans.RequestError in project so by onap.

the class ServiceInstancesTest method createVfModuleInstanceNoRecipe.

@Test
public void createVfModuleInstanceNoRecipe() throws IOException {
    wireMockServer.stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
    wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources" + "[?]MODEL_INSTANCE_NAME=test&VNF_RESOURCE_MODEL_UUID=fe6478e4-ea33-3346-ac12-ab121484a3fe")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationForVfModule_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
    wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/3/vfModuleCustomizations")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
    wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/search/findByModelCustomizationUUIDAndVfModuleModelUUID[?]" + "modelCustomizationUUID=b4ea86b4-253f-11e7-93ae-92361f002672&vfModuleModelUUID=066de97e-253e-11e7-93ae-92361f002672")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
    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());
    RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
    assertEquals("No valid vfModuleCustomization is specified", realResponse.getServiceException().getText());
}
Also used : RequestError(org.onap.so.serviceinstancebeans.RequestError) Test(org.junit.Test)

Example 42 with RequestError

use of org.onap.so.serviceinstancebeans.RequestError in project so by onap.

the class ServiceInstancesTest method createPortConfigDbUpdateError.

@Test
public void createPortConfigDbUpdateError() throws IOException {
    wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
    uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
    ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST, headers);
    assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
    RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
    assertEquals("Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error: [no body]", realResponse.getServiceException().getText());
}
Also used : RequestError(org.onap.so.serviceinstancebeans.RequestError) Test(org.junit.Test)

Example 43 with RequestError

use of org.onap.so.serviceinstancebeans.RequestError in project so by onap.

the class ServiceInstancesTest method invalidBPELResponse2.

@Test
public void invalidBPELResponse2() throws IOException {
    ServiceRecipe serviceRecipe = new ServiceRecipe();
    serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
    serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
    serviceRecipe.setAction(Action.createInstance.toString());
    serviceRecipe.setId(1);
    serviceRecipe.setRecipeTimeout(180);
    Service defaultService = new Service();
    defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
    wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
    wireMockServer.stubFor(get(urlMatching(".*/service/.*")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
    wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
    uri = servInstanceuri + "v5/serviceInstances";
    ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
    assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
    RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
    assertTrue(realResponse.getServiceException().getText().contains("<aetgt:ErrorMessage>Exception in create execution list 500"));
}
Also used : RequestError(org.onap.so.serviceinstancebeans.RequestError) Service(org.onap.so.db.catalog.beans.Service) ServiceRecipe(org.onap.so.db.catalog.beans.ServiceRecipe) Test(org.junit.Test)

Example 44 with RequestError

use of org.onap.so.serviceinstancebeans.RequestError in project so by onap.

the class ServiceInstancesTest method createServiceInstanceDuplicate.

@Test
public void createServiceInstanceDuplicate() throws IOException {
    wireMockServer.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);
    assertEquals("Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error: [no body]", realResponse.getServiceException().getText());
}
Also used : RequestError(org.onap.so.serviceinstancebeans.RequestError) Test(org.junit.Test)

Aggregations

RequestError (org.onap.so.serviceinstancebeans.RequestError)44 Test (org.junit.Test)33 ServiceException (org.onap.so.serviceinstancebeans.ServiceException)19 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)7 HttpHeaders (org.springframework.http.HttpHeaders)7 Service (org.onap.so.db.catalog.beans.Service)5 ServiceRecipe (org.onap.so.db.catalog.beans.ServiceRecipe)5 HttpEntity (org.springframework.http.HttpEntity)5 UriComponentsBuilder (org.springframework.web.util.UriComponentsBuilder)5 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 RequestDetails (org.onap.so.apihandlerinfra.tasksbeans.RequestDetails)2 RequestInfo (org.onap.so.apihandlerinfra.tasksbeans.RequestInfo)2 TasksRequest (org.onap.so.apihandlerinfra.tasksbeans.TasksRequest)2 IOException (java.io.IOException)1 Timestamp (java.sql.Timestamp)1 ValidateException (org.onap.so.apihandlerinfra.exceptions.ValidateException)1 ErrorLoggerInfo (org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo)1 InfraActiveRequests (org.onap.so.db.request.beans.InfraActiveRequests)1 PolicyException (org.onap.so.serviceinstancebeans.PolicyException)1 RequestReferences (org.onap.so.serviceinstancebeans.RequestReferences)1