Search in sources :

Example 1 with RequestError

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

the class ServiceInstancesTest method createServiceInstanceSaveError.

@Test
public void createServiceInstanceSaveError() 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(urlMatching(".*/infraActiveRequests/")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
    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.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) Service(org.onap.so.db.catalog.beans.Service) ServiceRecipe(org.onap.so.db.catalog.beans.ServiceRecipe) Test(org.junit.Test)

Example 2 with RequestError

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

the class ServiceInstancesTest method createServiceInstanceDuplicateHistoryCheckException.

@Test
public void createServiceInstanceDuplicateHistoryCheckException() throws IOException {
    wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBodyFile("InfraActiveRequests/createInfraActiveRequests.json").withStatus(HttpStatus.SC_ACCEPTED)));
    wireMockServer.stubFor(get(("/sobpmnengine/history/process-instance?processInstanceBusinessKey=f0a35706-efc4-4e27-80ea-a995d7a2a40f&active=true&maxResults=1")).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 = mapper.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$InternalServerError: 500 Server Error: [no body]", realResponse.getServiceException().getText());
}
Also used : RequestError(org.onap.so.serviceinstancebeans.RequestError) Test(org.junit.Test)

Example 3 with RequestError

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

the class ServiceInstancesTest method invalidBPELResponse.

@Test
public void invalidBPELResponse() 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/TestResponseInvalid2.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);
    assertEquals("Request Failed due to BPEL error with HTTP Status = 202{\"instanceId\": \"1882939\"}", realResponse.getServiceException().getText());
}
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 4 with RequestError

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

the class ServiceInstancesTest method deleteInstanceGroupNoPartnerNameHeader.

@Test
public void deleteInstanceGroupNoPartnerNameHeader() throws IOException {
    HttpHeaders noPartnerHeaders = new HttpHeaders();
    noPartnerHeaders.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
    noPartnerHeaders.set(REQUESTOR_ID, "xxxxxx");
    uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
    ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, noPartnerHeaders);
    // then
    assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
    RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
    assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-PartnerName header is specified");
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) RequestError(org.onap.so.serviceinstancebeans.RequestError) Test(org.junit.Test)

Example 5 with RequestError

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

the class ServiceInstancesTest method getCloudConfigurationAAIEntityNotFoundTest.

@Test
public void getCloudConfigurationAAIEntityNotFoundTest() throws IOException {
    RequestError expectedResponse = mapper.readValue(inputStream("/AAIEntityNotFoundResponse.json"), RequestError.class);
    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("/ReplaceVfModuleNoCloudConfig.json"), uri, HttpMethod.POST, headers);
    assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
    RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
    assertThat(expectedResponse, sameBeanAs(realResponse));
}
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