Search in sources :

Example 1 with QueryJobResponse

use of org.onap.so.adapters.etsisol003adapter.lcm.v1.model.QueryJobResponse in project so by onap.

the class VnfmAdapterServiceProviderImplTest method testGetInstantiateOperationJobStatus_httpServiceProviderReturnsStatusOkWithBody_validResponse.

@Test
public void testGetInstantiateOperationJobStatus_httpServiceProviderReturnsStatusOkWithBody_validResponse() {
    when(mockedQueryJobResponseResponseEntity.getStatusCode()).thenReturn(HttpStatus.OK);
    when(mockedQueryJobResponseResponseEntity.hasBody()).thenReturn(true);
    when(mockedQueryJobResponseResponseEntity.getBody()).thenReturn(getQueryJobResponse());
    when(mockedHttpServiceProvider.getHttpResponse(eq(TestConstants.JOB_STATUS_EXPECTED_URL), eq(QueryJobResponse.class))).thenReturn(mockedQueryJobResponseResponseEntity);
    final VnfmAdapterServiceProvider objUnderTest = new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
    final Optional<QueryJobResponse> actual = objUnderTest.getInstantiateOperationJobStatus(DUMMY_JOB_ID);
    assertTrue(actual.isPresent());
    final QueryJobResponse actualQueryJobResponse = actual.get();
    assertNotNull(actualQueryJobResponse);
}
Also used : QueryJobResponse(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.QueryJobResponse) Test(org.junit.Test)

Example 2 with QueryJobResponse

use of org.onap.so.adapters.etsisol003adapter.lcm.v1.model.QueryJobResponse in project so by onap.

the class MonitorVnfmCreateJobTaskTest method getQueryJobResponse.

private Optional<QueryJobResponse> getQueryJobResponse() {
    final QueryJobResponse queryJobResponse = new QueryJobResponse();
    queryJobResponse.setId(JOB_ID);
    return Optional.of(queryJobResponse);
}
Also used : QueryJobResponse(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.QueryJobResponse)

Example 3 with QueryJobResponse

use of org.onap.so.adapters.etsisol003adapter.lcm.v1.model.QueryJobResponse in project so by onap.

the class MonitorVnfmDeleteJobTaskTest method getQueryJobResponse.

private Optional<QueryJobResponse> getQueryJobResponse() {
    final QueryJobResponse queryJobResponse = new QueryJobResponse();
    queryJobResponse.setId(JOB_ID);
    return Optional.of(queryJobResponse);
}
Also used : QueryJobResponse(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.QueryJobResponse)

Example 4 with QueryJobResponse

use of org.onap.so.adapters.etsisol003adapter.lcm.v1.model.QueryJobResponse in project so by onap.

the class VnfmAdapterServiceProviderImpl method getInstantiateOperationJobStatus.

@Override
public Optional<QueryJobResponse> getInstantiateOperationJobStatus(final String jobId) {
    try {
        final String url = urlProvider.getJobStatusUrl(jobId);
        final ResponseEntity<QueryJobResponse> response = httpServiceProvider.getHttpResponse(url, QueryJobResponse.class);
        final HttpStatus httpStatus = response.getStatusCode();
        if (!(httpStatus.equals(HttpStatus.ACCEPTED)) && !(httpStatus.equals(HttpStatus.OK))) {
            LOGGER.error("Unable to invoke HTTP GET using URL: {}, Response Code: ", url, httpStatus.value());
            return Optional.absent();
        }
        if (!response.hasBody()) {
            LOGGER.error(RECEIVED_RESPONSE_WITHOUT_BODY, response);
            return Optional.absent();
        }
        return Optional.of(response.getBody());
    } catch (final RestProcessingException | InvalidRestRequestException | HttpResouceNotFoundException httpInvocationException) {
        LOGGER.error("Unexpected error while processing job request", httpInvocationException);
        throw httpInvocationException;
    }
}
Also used : QueryJobResponse(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.QueryJobResponse) HttpStatus(org.springframework.http.HttpStatus) InvalidRestRequestException(org.onap.so.rest.exceptions.InvalidRestRequestException) HttpResouceNotFoundException(org.onap.so.rest.exceptions.HttpResouceNotFoundException) RestProcessingException(org.onap.so.rest.exceptions.RestProcessingException)

Example 5 with QueryJobResponse

use of org.onap.so.adapters.etsisol003adapter.lcm.v1.model.QueryJobResponse in project so by onap.

the class MonitorVnfmJobTask method getOperationStatus.

/**
 * This method calls the Vnfm adapter and gets the Operation status of the job
 *
 * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
 * @param jobId unique job id
 * @return Operation State
 */
protected Optional<OperationStateEnum> getOperationStatus(final BuildingBlockExecution execution, final String jobId) {
    final Optional<QueryJobResponse> instantiateOperationJobStatus = vnfmAdapterServiceProvider.getInstantiateOperationJobStatus(jobId);
    if (instantiateOperationJobStatus.isPresent()) {
        final QueryJobResponse queryJobResponse = instantiateOperationJobStatus.get();
        if (!OPERATION_RETRIEVAL_STATES.contains(queryJobResponse.getOperationStatusRetrievalStatus())) {
            final String message = "Recevied invalid operation reterivel state: " + queryJobResponse.getOperationStatusRetrievalStatus();
            LOGGER.error(message);
            exceptionUtil.buildAndThrowWorkflowException(execution, 1203, message);
        }
        if (queryJobResponse.getOperationState() != null) {
            final OperationStateEnum operationStatus = queryJobResponse.getOperationState();
            LOGGER.debug("Operation {} with {} and operation retrieval status : {}", queryJobResponse.getId(), operationStatus, queryJobResponse.getOperationStatusRetrievalStatus());
            return Optional.of(queryJobResponse.getOperationState());
        }
        LOGGER.debug("Operation {} without operationStatus and operation retrieval status :{}", queryJobResponse.getId(), queryJobResponse.getOperationStatusRetrievalStatus());
    }
    return Optional.absent();
}
Also used : QueryJobResponse(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.QueryJobResponse) OperationStateEnum(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.OperationStateEnum)

Aggregations

QueryJobResponse (org.onap.so.adapters.etsisol003adapter.lcm.v1.model.QueryJobResponse)5 Test (org.junit.Test)1 OperationStateEnum (org.onap.so.adapters.etsisol003adapter.lcm.v1.model.OperationStateEnum)1 HttpResouceNotFoundException (org.onap.so.rest.exceptions.HttpResouceNotFoundException)1 InvalidRestRequestException (org.onap.so.rest.exceptions.InvalidRestRequestException)1 RestProcessingException (org.onap.so.rest.exceptions.RestProcessingException)1 HttpStatus (org.springframework.http.HttpStatus)1