Search in sources :

Example 11 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 12 with RequestError

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

the class E2EServiceInstancesTest method deleteE2EServiceInstance.

@Test
public void deleteE2EServiceInstance() throws IOException {
    RequestError expectedResponse = new RequestError();
    ServiceException exception = new ServiceException();
    exception.setMessageId("SVC1000");
    exception.setText("No communication to catalog DB null");
    expectedResponse.setServiceException(exception);
    String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e";
    ResponseEntity<String> response = sendRequest(inputStream("/DeleteRequest.json"), uri, HttpMethod.DELETE);
    assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
}
Also used : RequestError(org.onap.so.serviceinstancebeans.RequestError) ServiceException(org.onap.so.serviceinstancebeans.ServiceException) Test(org.junit.Test)

Example 13 with RequestError

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

the class E2EServiceInstancesTest method compareModelWithTargetVersionBadBpelResponse.

@Test
public void compareModelWithTargetVersionBadBpelResponse() throws IOException {
    wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CompareModelofE2EServiceInstance")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY)));
    String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e/modeldifferences";
    ResponseEntity<String> response = sendRequest(inputStream("/CompareModelRequest.json"), uri, HttpMethod.POST);
    assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
    RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
    assertTrue(realResponse.getServiceException().getText().contains("Request Failed due to BPEL error with HTTP Status"));
}
Also used : RequestError(org.onap.so.serviceinstancebeans.RequestError) Test(org.junit.Test)

Example 14 with RequestError

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

the class E2EServiceInstancesTest method updateE2EServiceInstanceJSONMappingError.

@Test
public void updateE2EServiceInstanceJSONMappingError() throws IOException {
    String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e";
    ResponseEntity<String> response = sendRequest(inputStream("/CompareModelRequest.json"), uri, HttpMethod.PUT);
    assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
    RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
    assertTrue(realResponse.getServiceException().getText().contains("Mapping of request to JSON object failed"));
}
Also used : RequestError(org.onap.so.serviceinstancebeans.RequestError) Test(org.junit.Test)

Example 15 with RequestError

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

the class E2EServiceInstancesTest method compareModelWithTargetVersionBadRequest.

@Test
public void compareModelWithTargetVersionBadRequest() throws IOException {
    String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e/modeldifferences";
    ResponseEntity<String> response = sendRequest(inputStream("/Request.json"), uri, HttpMethod.POST);
    assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
    RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
    assertTrue(realResponse.getServiceException().getText().contains("Mapping of request to JSON object failed"));
}
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