Search in sources :

Example 1 with ServiceException

use of org.onap.so.serviceinstancebeans.ServiceException 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 2 with ServiceException

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

the class CloudConfigurationNotFoundMapper method toResponse.

@Override
public Response toResponse(CloudConfigurationNotFoundException e) {
    logger.error("Cloud Configuration Not Found", e);
    RequestError error = new RequestError();
    ServiceException value = new ServiceException();
    value.setMessageId(ErrorNumbers.SVC_GENERAL_SERVICE_ERROR);
    value.setText(e.getMessage());
    error.setServiceException(value);
    return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build();
}
Also used : RequestError(org.onap.so.serviceinstancebeans.RequestError) ServiceException(org.onap.so.serviceinstancebeans.ServiceException)

Example 3 with ServiceException

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

the class RequestConflictMapper method toResponse.

@Override
public Response toResponse(RequestConflictedException e) {
    logger.error("Request Conflict Error", e);
    RequestError error = new RequestError();
    ServiceException value = new ServiceException();
    value.setMessageId(ErrorNumbers.SVC_GENERAL_SERVICE_ERROR);
    value.setText(e.getMessage());
    error.setServiceException(value);
    return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build();
}
Also used : RequestError(org.onap.so.serviceinstancebeans.RequestError) ServiceException(org.onap.so.serviceinstancebeans.ServiceException)

Example 4 with ServiceException

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

the class OrchestrationRequestsTest method testUnlockOrchestrationRequest.

@Test
public void testUnlockOrchestrationRequest() throws Exception {
    setupTestUnlockOrchestrationRequest("0017f68c-eb2d-45bb-b7c7-ec31b37dc349", "UNLOCKED");
    ObjectMapper mapper = new ObjectMapper();
    String requestJSON = new String(Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/Request.json")));
    HttpHeaders headers = new HttpHeaders();
    headers.set("Accept", MediaType.APPLICATION_JSON);
    headers.set("Content-Type", MediaType.APPLICATION_JSON);
    HttpEntity<String> entity = new HttpEntity<String>(requestJSON, headers);
    UriComponentsBuilder builder;
    ResponseEntity<String> response;
    RequestError expectedRequestError;
    RequestError actualRequestError;
    ServiceException se;
    // Test invalid JSON
    expectedRequestError = new RequestError();
    se = new ServiceException();
    se.setMessageId(ErrorNumbers.SVC_DETAILED_SERVICE_ERROR);
    se.setText("Orchestration RequestId 0017f68c-eb2d-45bb-b7c7-ec31b37dc349 has a status of UNLOCKED and can not be unlocked");
    expectedRequestError.setServiceException(se);
    builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v6/0017f68c-eb2d-45bb-b7c7-ec31b37dc349/unlock"));
    response = restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
    actualRequestError = mapper.readValue(response.getBody(), RequestError.class);
    assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
    assertThat(actualRequestError, sameBeanAs(expectedRequestError));
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) RequestError(org.onap.so.serviceinstancebeans.RequestError) HttpEntity(org.springframework.http.HttpEntity) ServiceException(org.onap.so.serviceinstancebeans.ServiceException) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 5 with ServiceException

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

the class RequestIdFilterTest method getRequestError.

private RequestError getRequestError() throws IOException {
    RequestError requestError = new RequestError();
    mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, false);
    ServiceException serviceException = new ServiceException();
    serviceException.setMessageId("SVC0002");
    serviceException.setText("RequestId: 32807a28-1a14-4b88-b7b3-2950918aa769 already exists in the RequestDB InfraActiveRequests table");
    requestError.setServiceException(serviceException);
    return requestError;
}
Also used : RequestError(org.onap.so.serviceinstancebeans.RequestError) ServiceException(org.onap.so.serviceinstancebeans.ServiceException)

Aggregations

RequestError (org.onap.so.serviceinstancebeans.RequestError)19 ServiceException (org.onap.so.serviceinstancebeans.ServiceException)19 Test (org.junit.Test)8 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)7 HttpEntity (org.springframework.http.HttpEntity)5 HttpHeaders (org.springframework.http.HttpHeaders)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