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