Search in sources :

Example 1 with GetOrchestrationListResponse

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

the class OrchestrationRequestsTest method generateOrchestrationList.

private static GetOrchestrationListResponse generateOrchestrationList() {
    GetOrchestrationListResponse list = null;
    try {
        ObjectMapper mapper = new ObjectMapper();
        list = mapper.readValue(new File("src/test/resources/OrchestrationRequest/OrchestrationList.json"), GetOrchestrationListResponse.class);
    } catch (JsonParseException jpe) {
        jpe.printStackTrace();
    } catch (JsonMappingException jme) {
        jme.printStackTrace();
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }
    return list;
}
Also used : GetOrchestrationListResponse(org.onap.so.serviceinstancebeans.GetOrchestrationListResponse) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) IOException(java.io.IOException) JsonParseException(com.fasterxml.jackson.core.JsonParseException) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 2 with GetOrchestrationListResponse

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

the class OrchestrationRequests method getOrchestrationRequest.

@GET
@Path("/{version:[vV][4-8]}")
@Operation(description = "Find Orchestrated Requests for a URI Information", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))))
@Produces(MediaType.APPLICATION_JSON)
@Transactional
public Response getOrchestrationRequest(@Context UriInfo ui, @PathParam("version") String version, @QueryParam("includeCloudRequest") boolean includeCloudRequest, @QueryParam(value = "format") String format) throws ApiException {
    MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
    List<InfraActiveRequests> activeRequests;
    GetOrchestrationListResponse orchestrationList;
    Map<String, List<String>> orchestrationMap;
    String apiVersion = version.substring(1);
    try {
        orchestrationMap = msoRequest.getOrchestrationFilters(queryParams);
        if (orchestrationMap.isEmpty()) {
            throw new ValidationException("At least one filter query param must be specified");
        }
    } catch (ValidationException ex) {
        logger.error("Exception occurred", ex);
        ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.DataError).build();
        ValidateException validateException = new ValidateException.Builder(ex.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_GENERAL_SERVICE_ERROR).cause(ex).errorInfo(errorLoggerInfo).build();
        throw validateException;
    }
    activeRequests = requestsDbClient.getOrchestrationFiltersFromInfraActive(orchestrationMap);
    orchestrationList = new GetOrchestrationListResponse();
    List<RequestList> requestLists = new ArrayList<>();
    for (InfraActiveRequests infraActive : activeRequests) {
        RequestList requestList = new RequestList();
        Request request = mapInfraActiveRequestToRequest(infraActive, includeCloudRequest, format, version);
        if (isRequestProcessingDataRequired(format)) {
            List<RequestProcessingData> requestProcessingData = requestsDbClient.getExternalRequestProcessingDataBySoRequestId(infraActive.getRequestId());
            if (null != requestProcessingData && !requestProcessingData.isEmpty()) {
                request.setRequestProcessingData(mapRequestProcessingData(requestProcessingData));
            }
        }
        requestList.setRequest(request);
        requestLists.add(requestList);
    }
    orchestrationList.setRequestList(requestLists);
    return builder.buildResponse(HttpStatus.SC_OK, MDC.get(ONAPLogConstants.MDCs.REQUEST_ID), orchestrationList, apiVersion);
}
Also used : ValidateException(org.onap.so.apihandlerinfra.exceptions.ValidateException) GetOrchestrationListResponse(org.onap.so.serviceinstancebeans.GetOrchestrationListResponse) ValidationException(org.onap.so.exceptions.ValidationException) ResponseBuilder(org.onap.so.apihandler.common.ResponseBuilder) ArrayList(java.util.ArrayList) Request(org.onap.so.serviceinstancebeans.Request) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) ErrorLoggerInfo(org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo) RequestProcessingData(org.onap.so.db.request.beans.RequestProcessingData) List(java.util.List) ArrayList(java.util.ArrayList) RequestList(org.onap.so.serviceinstancebeans.RequestList) RequestList(org.onap.so.serviceinstancebeans.RequestList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Operation(io.swagger.v3.oas.annotations.Operation) Transactional(javax.transaction.Transactional)

Example 3 with GetOrchestrationListResponse

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

the class OrchestrationRequestsTest method testGetOrchestrationRequestFilter.

@Test
public void testGetOrchestrationRequestFilter() throws Exception {
    setupTestGetOrchestrationRequestFilter();
    List<String> values = new ArrayList<>();
    values.add("EQUALS");
    values.add("vfModule");
    ObjectMapper mapper = new ObjectMapper();
    GetOrchestrationListResponse testResponse = mapper.readValue(new File("src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json"), GetOrchestrationListResponse.class);
    Map<String, List<String>> orchestrationMap = new HashMap<>();
    orchestrationMap.put("modelType", values);
    List<InfraActiveRequests> requests = requestsDbClient.getOrchestrationFiltersFromInfraActive(orchestrationMap);
    HttpHeaders headers = new HttpHeaders();
    headers.set("Accept", MediaType.APPLICATION_JSON);
    HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
    UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v6?filter=modelType:EQUALS:vfModule"));
    ResponseEntity<GetOrchestrationListResponse> response = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationListResponse.class);
    assertThat(response.getBody(), sameBeanAs(testResponse).ignoring("requestList.request.startTime").ignoring("requestList.request.finishTime").ignoring("requestList.request.requestStatus.timeStamp"));
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
    assertEquals(requests.size(), response.getBody().getRequestList().size());
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) GetOrchestrationListResponse(org.onap.so.serviceinstancebeans.GetOrchestrationListResponse) HttpEntity(org.springframework.http.HttpEntity) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Request(org.onap.so.serviceinstancebeans.Request) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 4 with GetOrchestrationListResponse

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

the class OrchestrationRequestsTest method testGetOrchestrationRequestNoRequestID.

@Test
public void testGetOrchestrationRequestNoRequestID() {
    HttpHeaders headers = new HttpHeaders();
    headers.set("Accept", "application/json; charset=UTF-8");
    headers.set("Content-Type", "application/json; charset=UTF-8");
    HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
    UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v6/"));
    ResponseEntity<GetOrchestrationListResponse> response = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationListResponse.class);
    assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) GetOrchestrationListResponse(org.onap.so.serviceinstancebeans.GetOrchestrationListResponse) HttpEntity(org.springframework.http.HttpEntity) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) Request(org.onap.so.serviceinstancebeans.Request) Test(org.junit.Test)

Aggregations

GetOrchestrationListResponse (org.onap.so.serviceinstancebeans.GetOrchestrationListResponse)4 Request (org.onap.so.serviceinstancebeans.Request)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Test (org.junit.Test)2 InfraActiveRequests (org.onap.so.db.request.beans.InfraActiveRequests)2 HttpEntity (org.springframework.http.HttpEntity)2 HttpHeaders (org.springframework.http.HttpHeaders)2 UriComponentsBuilder (org.springframework.web.util.UriComponentsBuilder)2 JsonParseException (com.fasterxml.jackson.core.JsonParseException)1 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 Operation (io.swagger.v3.oas.annotations.Operation)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Transactional (javax.transaction.Transactional)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1