Search in sources :

Example 1 with InfraActiveRequests

use of org.onap.so.db.request.beans.InfraActiveRequests in project so by onap.

the class OrchestrationRequestsUnitTest method taskNameLookup.

@Test
public void taskNameLookup() throws ContactCamundaException {
    InfraActiveRequests req = new InfraActiveRequests();
    req.setRequestId("70debc2a-d6bc-4795-87ba-38a94d9b0b99");
    Instant startInstant = Instant.now().minus(1, ChronoUnit.DAYS);
    req.setStartTime(Timestamp.from(startInstant));
    when(env.getProperty("mso.camundaCleanupInterval")).thenReturn(null);
    when(camundaRequestHandler.getTaskName("70debc2a-d6bc-4795-87ba-38a94d9b0b99")).thenReturn("taskName");
    RequestStatus requestStatus = new RequestStatus();
    req.setFlowStatus("Building blocks 1 of 3 completed.");
    orchestrationRequests.mapRequestStatusAndExtSysErrSrcToRequest(req, requestStatus, null, "v7");
    assertEquals("FLOW STATUS: Building blocks 1 of 3 completed. TASK INFORMATION: taskName", requestStatus.getStatusMessage());
}
Also used : Instant(java.time.Instant) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) RequestStatus(org.onap.so.serviceinstancebeans.RequestStatus) Test(org.junit.Test)

Example 2 with InfraActiveRequests

use of org.onap.so.db.request.beans.InfraActiveRequests in project so by onap.

the class OrchestrationRequestsUnitTest method setup.

@Before
public void setup() {
    iar = new InfraActiveRequests();
    iar.setRequestScope(SERVICE);
    iar.setRequestId(REQUEST_ID);
    iar.setServiceInstanceId(SERVICE_INSTANCE_ID);
    iar.setExtSystemErrorSource(EXT_SYSTEM_ERROR_SOURCE);
    iar.setRollbackExtSystemErrorSource(ROLLBACK_EXT_SYSTEM_ERROR_SOURCE);
    iar.setFlowStatus(FLOW_STATUS);
    iar.setRollbackStatusMessage(ROLLBACK_STATUS_MESSAGE);
    iar.setRetryStatusMessage(RETRY_STATUS_MESSAGE);
    iar.setResourceStatusMessage("The vf module already exist");
    iar.setStartTime(startTime);
}
Also used : InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) Before(org.junit.Before)

Example 3 with InfraActiveRequests

use of org.onap.so.db.request.beans.InfraActiveRequests in project so by onap.

the class OrchestrationRequestsUnitTest method noCamundaLookupAfterInterval.

@Test
public void noCamundaLookupAfterInterval() throws ContactCamundaException {
    InfraActiveRequests req = new InfraActiveRequests();
    req.setRequestId("70debc2a-d6bc-4795-87ba-38a94d9b0b99");
    Instant startInstant = Instant.now().minus(36, ChronoUnit.DAYS);
    req.setStartTime(Timestamp.from(startInstant));
    when(env.getProperty("mso.camundaCleanupInterval")).thenReturn("35");
    RequestStatus requestStatus = new RequestStatus();
    req.setFlowStatus("Building blocks 1 of 3 completed.");
    orchestrationRequests.mapRequestStatusAndExtSysErrSrcToRequest(req, requestStatus, null, "v7");
    assertEquals("FLOW STATUS: Building blocks 1 of 3 completed.", requestStatus.getStatusMessage());
}
Also used : Instant(java.time.Instant) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) RequestStatus(org.onap.so.serviceinstancebeans.RequestStatus) Test(org.junit.Test)

Example 4 with InfraActiveRequests

use of org.onap.so.db.request.beans.InfraActiveRequests in project so by onap.

the class RequestHandlerUtilsTest method camundaHistoryCheckNoneFoundTest.

@Test
public void camundaHistoryCheckNoneFoundTest() throws ContactCamundaException, RequestDbFailureException {
    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).withBody("[]").withStatus(org.apache.http.HttpStatus.SC_OK)));
    InfraActiveRequests duplicateRecord = new InfraActiveRequests();
    duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
    boolean inProgress = false;
    inProgress = requestHandlerUtils.camundaHistoryCheck(duplicateRecord, null);
    assertFalse(inProgress);
}
Also used : InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) Test(org.junit.Test)

Example 5 with InfraActiveRequests

use of org.onap.so.db.request.beans.InfraActiveRequests in project so by onap.

the class ServiceInstancesTest method convertJsonToServiceInstanceRequestFail.

@Test
public void convertJsonToServiceInstanceRequestFail() throws IOException {
    // ExpectedRecord
    InfraActiveRequests expectedRecord = new InfraActiveRequests();
    expectedRecord.setRequestStatus("FAILED");
    expectedRecord.setStatusMessage("Error mapping request: ");
    expectedRecord.setProgress(100L);
    expectedRecord.setRequestBody(inputStream("/ConvertRequestFail.json"));
    expectedRecord.setLastModifiedBy("APIH");
    expectedRecord.setRequestScope("network");
    expectedRecord.setRequestAction("deleteInstance");
    expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
    uri = servInstanceuri + "v6" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
    ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.DELETE, headers);
    // ActualRecord
    assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
}
Also used : InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) Test(org.junit.Test)

Aggregations

InfraActiveRequests (org.onap.so.db.request.beans.InfraActiveRequests)214 Test (org.junit.Test)119 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)29 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)26 Timestamp (java.sql.Timestamp)23 HttpEntity (org.springframework.http.HttpEntity)21 IOException (java.io.IOException)20 HashMap (java.util.HashMap)20 ApiException (org.onap.so.apihandlerinfra.exceptions.ApiException)20 ValidateException (org.onap.so.apihandlerinfra.exceptions.ValidateException)19 ServiceInstancesRequest (org.onap.so.serviceinstancebeans.ServiceInstancesRequest)19 BaseTest (org.onap.so.apihandlerinfra.BaseTest)18 ErrorLoggerInfo (org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo)18 ArrayList (java.util.ArrayList)16 ValidationException (org.onap.so.exceptions.ValidationException)15 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)13 Transactional (javax.transaction.Transactional)13 UriComponentsBuilder (org.springframework.web.util.UriComponentsBuilder)12 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)11 ResponseBuilder (org.onap.so.apihandler.common.ResponseBuilder)11