Search in sources :

Example 1 with DeleteVnfResponse

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

the class MonitorVnfmDeleteJobTask method checkIfOperationWasSuccessful.

/**
 * Check the final status of delete throw exception if not completed successfully
 *
 * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
 */
public void checkIfOperationWasSuccessful(final BuildingBlockExecution execution) {
    LOGGER.debug("Executing checkIfOperationWasSuccessful  ...");
    final Optional<OperationStateEnum> operationStatusOption = execution.getVariable(OPERATION_STATUS_PARAM_NAME);
    final DeleteVnfResponse deleteVnfResponse = execution.getVariable(DELETE_VNF_RESPONSE_PARAM_NAME);
    if (operationStatusOption == null || !operationStatusOption.isPresent()) {
        final String message = "Unable to delete jobId: " + (deleteVnfResponse != null ? deleteVnfResponse.getJobId() : "null") + "Unable to retrieve OperationStatus";
        LOGGER.error(message);
        exceptionUtil.buildAndThrowWorkflowException(execution, 1214, message);
    } else if (operationStatusOption != null && operationStatusOption.isPresent()) {
        final OperationStateEnum operationStatus = operationStatusOption.get();
        if (operationStatus != OperationStateEnum.COMPLETED) {
            final String message = "Unable to Delete jobId: " + (deleteVnfResponse != null ? deleteVnfResponse.getJobId() : "null") + " OperationStatus: " + operationStatus;
            LOGGER.error(message);
            exceptionUtil.buildAndThrowWorkflowException(execution, 1215, message);
        }
        LOGGER.debug("Successfully completed Deletion of job {}", deleteVnfResponse);
    }
}
Also used : OperationStateEnum(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.OperationStateEnum) DeleteVnfResponse(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.DeleteVnfResponse)

Example 2 with DeleteVnfResponse

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

the class MonitorVnfmDeleteJobTaskTest method getDeleteVnfResponse.

private DeleteVnfResponse getDeleteVnfResponse() {
    final DeleteVnfResponse response = new DeleteVnfResponse();
    response.setJobId(JOB_ID);
    return response;
}
Also used : DeleteVnfResponse(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.DeleteVnfResponse)

Example 3 with DeleteVnfResponse

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

the class VnfmAdapterServiceProviderImplTest method testInvokeDeleteRequest.

@Test
public void testInvokeDeleteRequest() {
    when(mockedHttpServiceProvider.deleteHttpRequest(anyString(), eq(DeleteVnfResponse.class))).thenReturn(deleteVnfResponse);
    when(deleteVnfResponse.getStatusCode()).thenReturn(HttpStatus.ACCEPTED);
    when(deleteVnfResponse.hasBody()).thenReturn(true);
    final DeleteVnfResponse response = getDeleteVnfResponse(DUMMY_JOB_ID);
    when(deleteVnfResponse.getBody()).thenReturn(response);
    final VnfmAdapterServiceProvider objUnderTest = new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
    final Optional<DeleteVnfResponse> actual = objUnderTest.invokeDeleteRequest(DUMMY_GENERIC_VND_ID);
    assertTrue(actual.isPresent());
}
Also used : DeleteVnfResponse(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.DeleteVnfResponse) Test(org.junit.Test)

Example 4 with DeleteVnfResponse

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

the class VnfmAdapterServiceProviderImplTest method testInvokeDeleteRequestNoJobId.

@Test
public void testInvokeDeleteRequestNoJobId() {
    when(mockedHttpServiceProvider.deleteHttpRequest(anyString(), eq(DeleteVnfResponse.class))).thenReturn(deleteVnfResponse);
    when(deleteVnfResponse.getStatusCode()).thenReturn(HttpStatus.ACCEPTED);
    when(deleteVnfResponse.hasBody()).thenReturn(true);
    final DeleteVnfResponse response = getDeleteVnfResponse("");
    when(deleteVnfResponse.getBody()).thenReturn(response);
    final VnfmAdapterServiceProvider objUnderTest = new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
    final Optional<DeleteVnfResponse> actual = objUnderTest.invokeDeleteRequest(DUMMY_GENERIC_VND_ID);
    assertFalse(actual.isPresent());
}
Also used : DeleteVnfResponse(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.DeleteVnfResponse) Test(org.junit.Test)

Example 5 with DeleteVnfResponse

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

the class VnfmAdapterServiceProviderImplTest method getDeleteVnfResponse.

private DeleteVnfResponse getDeleteVnfResponse(final String jobId) {
    final DeleteVnfResponse response = new DeleteVnfResponse();
    response.setJobId(jobId);
    return response;
}
Also used : DeleteVnfResponse(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.DeleteVnfResponse)

Aggregations

DeleteVnfResponse (org.onap.so.adapters.etsisol003adapter.lcm.v1.model.DeleteVnfResponse)9 Test (org.junit.Test)2 OperationStateEnum (org.onap.so.adapters.etsisol003adapter.lcm.v1.model.OperationStateEnum)1 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)1 InvalidRestRequestException (org.onap.so.rest.exceptions.InvalidRestRequestException)1 RestProcessingException (org.onap.so.rest.exceptions.RestProcessingException)1 HttpStatus (org.springframework.http.HttpStatus)1