Search in sources :

Example 1 with CreateVnfResponse

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

the class MonitorVnfmCreateJobTask method getCurrentOperationStatus.

/**
 * Get the current operation status of instantiation job
 *
 * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
 */
public void getCurrentOperationStatus(final BuildingBlockExecution execution) {
    try {
        LOGGER.debug("Executing getCurrentOperationStatus  ...");
        final CreateVnfResponse vnfInstantiateResponse = execution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME);
        execution.setVariable(OPERATION_STATUS_PARAM_NAME, getOperationStatus(execution, vnfInstantiateResponse.getJobId()));
        LOGGER.debug("Finished executing getCurrentOperationStatus ...");
    } catch (final Exception exception) {
        final String message = "Unable to invoke get current Operation status";
        LOGGER.error(message);
        exceptionUtil.buildAndThrowWorkflowException(execution, 1209, message);
    }
}
Also used : CreateVnfResponse(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfResponse)

Example 2 with CreateVnfResponse

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

the class VnfmAdapterCreateVnfTask method invokeVnfmAdapter.

/**
 * Invoke VNFM adapter to create and instantiate VNF
 *
 * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
 */
public void invokeVnfmAdapter(final BuildingBlockExecution execution) {
    try {
        LOGGER.debug("Executing invokeVnfmAdapter  ...");
        final CreateVnfRequest request = execution.getVariable(CREATE_VNF_REQUEST_PARAM_NAME);
        final GenericVnf vnf = extractPojosForBB.extractByKey(execution, GENERIC_VNF_ID);
        final Optional<CreateVnfResponse> response = vnfmAdapterServiceProvider.invokeCreateInstantiationRequest(vnf.getVnfId(), request);
        if (!response.isPresent()) {
            final String errorMessage = "Unexpected error while processing create and instantiation request";
            LOGGER.error(errorMessage);
            exceptionUtil.buildAndThrowWorkflowException(execution, 1201, errorMessage);
        }
        final CreateVnfResponse vnfResponse = response.get();
        LOGGER.debug("Vnf instantiation response: {}", vnfResponse);
        execution.setVariable(CREATE_VNF_RESPONSE_PARAM_NAME, vnfResponse);
        LOGGER.debug("Finished executing invokeVnfmAdapter ...");
    } catch (final Exception exception) {
        LOGGER.error("Unable to invoke create and instantiation request", exception);
        exceptionUtil.buildAndThrowWorkflowException(execution, 1202, exception);
    }
}
Also used : CreateVnfResponse(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfResponse) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) CreateVnfRequest(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfRequest)

Example 3 with CreateVnfResponse

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

the class VnfmAdapterServiceProviderImplTest method assertWithJobId.

private void assertWithJobId(final String jobId) {
    when(mockedHttpServiceProvider.postHttpRequest(eq(CREATE_VNF_REQUEST), anyString(), eq(CreateVnfResponse.class))).thenReturn(mockedResponseEntity);
    when(mockedResponseEntity.getStatusCode()).thenReturn(HttpStatus.ACCEPTED);
    when(mockedResponseEntity.hasBody()).thenReturn(true);
    final CreateVnfResponse response = getCreateVnfResponse(jobId);
    when(mockedResponseEntity.getBody()).thenReturn(response);
    final VnfmAdapterServiceProvider objUnderTest = new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
    final Optional<CreateVnfResponse> actual = objUnderTest.invokeCreateInstantiationRequest(DUMMY_GENERIC_VND_ID, CREATE_VNF_REQUEST);
    assertFalse(actual.isPresent());
}
Also used : CreateVnfResponse(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfResponse)

Example 4 with CreateVnfResponse

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

the class VnfmAdapterCreateVnfTaskTest method getCreateVnfResponse.

private Optional<CreateVnfResponse> getCreateVnfResponse() {
    final CreateVnfResponse response = new CreateVnfResponse();
    response.setJobId(JOB_ID);
    return Optional.of(response);
}
Also used : CreateVnfResponse(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfResponse)

Example 5 with CreateVnfResponse

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

the class VnfmAdapterServiceProviderImplTest method testInvokeCreateInstantiationRequest_httpServiceProviderReturnsStatusAcceptedWithBody_validResponse.

@Test
public void testInvokeCreateInstantiationRequest_httpServiceProviderReturnsStatusAcceptedWithBody_validResponse() {
    when(mockedHttpServiceProvider.postHttpRequest(eq(CREATE_VNF_REQUEST), anyString(), eq(CreateVnfResponse.class))).thenReturn(mockedResponseEntity);
    when(mockedResponseEntity.getStatusCode()).thenReturn(HttpStatus.ACCEPTED);
    when(mockedResponseEntity.hasBody()).thenReturn(true);
    final CreateVnfResponse response = getCreateVnfResponse(DUMMY_JOB_ID);
    when(mockedResponseEntity.getBody()).thenReturn(response);
    final VnfmAdapterServiceProvider objUnderTest = new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
    final Optional<CreateVnfResponse> actual = objUnderTest.invokeCreateInstantiationRequest(DUMMY_GENERIC_VND_ID, CREATE_VNF_REQUEST);
    assertTrue(actual.isPresent());
    assertEquals(actual.get(), response);
}
Also used : CreateVnfResponse(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfResponse) Test(org.junit.Test)

Aggregations

CreateVnfResponse (org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfResponse)8 Test (org.junit.Test)1 CreateVnfRequest (org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfRequest)1 OperationStateEnum (org.onap.so.adapters.etsisol003adapter.lcm.v1.model.OperationStateEnum)1 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)1 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)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