Search in sources :

Example 11 with Request

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

the class OrchestrationRequestsUnitTest method mapRequestStatusNoTaskInfoTest.

@Test
public void mapRequestStatusNoTaskInfoTest() throws ApiException {
    InstanceReferences instanceReferences = new InstanceReferences();
    instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID);
    RequestStatus requestStatus = new RequestStatus();
    requestStatus.setRequestState(iar.getRequestStatus());
    requestStatus.setStatusMessage("FLOW STATUS: FlowStatus RETRY STATUS: RetryStatusMessage ROLLBACK STATUS: RollbackStatusMessage RESOURCE STATUS: The vf module already exist");
    Request expected = new Request();
    expected.setRequestId(REQUEST_ID);
    expected.setInstanceReferences(instanceReferences);
    expected.setRequestStatus(requestStatus);
    expected.setRequestScope(SERVICE);
    expected.setStartTime(new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(startTime) + " GMT");
    includeCloudRequest = false;
    Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, OrchestrationRequestFormat.SIMPLENOTASKINFO.toString(), "v7");
    assertThat(expected, sameBeanAs(actual));
}
Also used : InstanceReferences(org.onap.so.serviceinstancebeans.InstanceReferences) Request(org.onap.so.serviceinstancebeans.Request) SimpleDateFormat(java.text.SimpleDateFormat) RequestStatus(org.onap.so.serviceinstancebeans.RequestStatus) Test(org.junit.Test)

Example 12 with Request

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

the class OrchestrationRequestsUnitTest method mapRequestStatusAndExtSysErrSrcToRequestFlowStatusSuccessfulCompletionTest.

@Test
public void mapRequestStatusAndExtSysErrSrcToRequestFlowStatusSuccessfulCompletionTest() throws ApiException {
    InstanceReferences instanceReferences = new InstanceReferences();
    instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID);
    RequestStatus requestStatus = new RequestStatus();
    requestStatus.setRequestState(iar.getRequestStatus());
    requestStatus.setStatusMessage(String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s RESOURCE STATUS: %s", "Successfully completed all Building Blocks", RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE, "The vf module already exist"));
    Request expected = new Request();
    expected.setRequestId(REQUEST_ID);
    expected.setInstanceReferences(instanceReferences);
    expected.setRequestStatus(requestStatus);
    expected.setRequestScope(SERVICE);
    expected.setStartTime(new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(startTime) + " GMT");
    includeCloudRequest = false;
    iar.setFlowStatus("Successfully completed all Building Blocks");
    Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, OrchestrationRequestFormat.DETAIL.toString(), "v7");
    assertThat(actual, sameBeanAs(expected));
}
Also used : InstanceReferences(org.onap.so.serviceinstancebeans.InstanceReferences) Request(org.onap.so.serviceinstancebeans.Request) SimpleDateFormat(java.text.SimpleDateFormat) RequestStatus(org.onap.so.serviceinstancebeans.RequestStatus) Test(org.junit.Test)

Example 13 with Request

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

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

the class OrchestrationRequestsTest method testGetOrchestrationRequestInstanceGroup.

@Test
public void testGetOrchestrationRequestInstanceGroup() throws Exception {
    setupTestGetOrchestrationRequestInstanceGroup();
    // TEST VALID REQUEST
    GetOrchestrationResponse testResponse = new GetOrchestrationResponse();
    Request request = ORCHESTRATION_LIST.getRequestList().get(8).getRequest();
    testResponse.setRequest(request);
    testResponse.getRequest().setRequestProcessingData(new ArrayList<RequestProcessingData>());
    RequestProcessingData e = new RequestProcessingData();
    e.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca714");
    List<HashMap<String, String>> data = new ArrayList<HashMap<String, String>>();
    HashMap<String, String> data1 = new HashMap<String, String>();
    data1.put("requestAction", "assign");
    data.add(data1);
    e.setDataPairs(data);
    testResponse.getRequest().getRequestProcessingData().add(e);
    String testRequestId = request.getRequestId();
    HttpHeaders headers = new HttpHeaders();
    headers.set("Accept", MediaType.APPLICATION_JSON);
    headers.set("Content-Type", MediaType.APPLICATION_JSON);
    HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
    UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v7/" + testRequestId));
    ResponseEntity<GetOrchestrationResponse> response = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationResponse.class);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
    assertThat(response.getBody(), sameBeanAs(testResponse).ignoring("request.startTime").ignoring("request.finishTime").ignoring("request.requestStatus.timeStamp"));
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) HttpEntity(org.springframework.http.HttpEntity) HashMap(java.util.HashMap) Request(org.onap.so.serviceinstancebeans.Request) ArrayList(java.util.ArrayList) GetOrchestrationResponse(org.onap.so.serviceinstancebeans.GetOrchestrationResponse) RequestProcessingData(org.onap.so.serviceinstancebeans.RequestProcessingData) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) Test(org.junit.Test)

Example 15 with Request

use of org.onap.so.serviceinstancebeans.Request 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

Request (org.onap.so.serviceinstancebeans.Request)25 Test (org.junit.Test)22 InstanceReferences (org.onap.so.serviceinstancebeans.InstanceReferences)15 SimpleDateFormat (java.text.SimpleDateFormat)14 RequestStatus (org.onap.so.serviceinstancebeans.RequestStatus)14 HttpEntity (org.springframework.http.HttpEntity)8 HttpHeaders (org.springframework.http.HttpHeaders)8 UriComponentsBuilder (org.springframework.web.util.UriComponentsBuilder)8 GetOrchestrationResponse (org.onap.so.serviceinstancebeans.GetOrchestrationResponse)6 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 ValidateException (org.onap.so.apihandlerinfra.exceptions.ValidateException)3 InfraActiveRequests (org.onap.so.db.request.beans.InfraActiveRequests)3 ValidationException (org.onap.so.exceptions.ValidationException)3 GetOrchestrationListResponse (org.onap.so.serviceinstancebeans.GetOrchestrationListResponse)3 RequestProcessingData (org.onap.so.serviceinstancebeans.RequestProcessingData)3 ServiceInstancesRequest (org.onap.so.serviceinstancebeans.ServiceInstancesRequest)3 Operation (io.swagger.v3.oas.annotations.Operation)2 IOException (java.io.IOException)2