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);
}
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);
}
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);
}
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;
}
}
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();
}
Aggregations