use of org.onap.so.bpmn.infrastructure.workflow.tasks.Resource in project so by onap.
the class VnfEBBLoaderTest method traverseAAIVnf_should_add_vnfs_and_vfmodules.
@Test
public void traverseAAIVnf_should_add_vnfs_and_vfmodules() throws Exception {
List<Resource> resourceList = new ArrayList<>();
List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
GenericVnf genericVnf = mock(GenericVnf.class);
doReturn(vnfId).when(genericVnf).getVnfId();
org.onap.aai.domain.yang.GenericVnf aaiVnf = mock(org.onap.aai.domain.yang.GenericVnf.class);
doReturn(aaiVnf).when(bbInputSetupUtils).getAAIGenericVnf(vnfId);
VfModule vfModule = mock(VfModule.class);
doReturn(vfModuleId).when(vfModule).getVfModuleId();
ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
modelInfoVfModule.setIsBaseBoolean(true);
doReturn(modelInfoVfModule).when(vfModule).getModelInfoVfModule();
org.onap.aai.domain.yang.VfModule aaiVfModule = new org.onap.aai.domain.yang.VfModule();
aaiVfModule.setIsBaseVfModule(true);
doReturn(aaiVfModule).when(bbInputSetupUtils).getAAIVfModule(vnfId, vfModuleId);
doReturn(serviceInstanceAAI).when(bbInputSetupUtils).getAAIServiceInstanceById(serviceId);
doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
doReturn(List.of(genericVnf)).when(serviceInstanceMSO).getVnfs();
doReturn(List.of(vfModule)).when(genericVnf).getVfModules();
cut = new VnfEBBLoader(bbInputSetupUtils, bbInputSetup, workflowActionUtils, exceptionBuilder);
cut.traverseAAIVnf(delegateExecution, resourceList, serviceId, vnfId, aaiResourceIds);
assertEquals(3, resourceList.size());
assertEquals(WorkflowType.VNF, resourceList.get(1).getResourceType());
assertEquals(WorkflowType.VFMODULE, resourceList.get(2).getResourceType());
assertTrue(resourceList.get(2).isBaseVfModule());
}
use of org.onap.so.bpmn.infrastructure.workflow.tasks.Resource in project so by onap.
the class UpgradePreWorkflowValidatorTest method validateModelInvariantMismatch.
@Test
public void validateModelInvariantMismatch() throws JsonProcessingException {
ServiceInstancesRequest sir = new ServiceInstancesRequest();
sir.setRequestDetails(new RequestDetails());
sir.getRequestDetails().setModelInfo(new ModelInfo());
sir.getRequestDetails().getModelInfo().setModelInvariantId(UUID.randomUUID().toString());
Resource serviceResource = new Resource(WorkflowType.SERVICE, "", false, null);
String aaiModelInvariantId = UUID.randomUUID().toString();
serviceResource.setModelInvariantId(aaiModelInvariantId);
BuildingBlockExecution execution = createExecution(sir, Arrays.asList(serviceResource));
Optional<String> message = validator.validate(execution);
assertTrue(message.isPresent());
assertTrue(message.get().startsWith("Request service modelInvariantId"));
}
use of org.onap.so.bpmn.infrastructure.workflow.tasks.Resource in project so by onap.
the class UpgradePreWorkflowValidatorTest method validateNoVnfsInAAI.
@Test
public void validateNoVnfsInAAI() throws JsonProcessingException {
ServiceInstancesRequest sir = new ServiceInstancesRequest();
sir.setRequestDetails(new RequestDetails());
sir.getRequestDetails().setModelInfo(new ModelInfo());
String modelInvariantId = UUID.randomUUID().toString();
sir.getRequestDetails().getModelInfo().setModelInvariantId(modelInvariantId);
Resource serviceResource = new Resource(WorkflowType.SERVICE, "", false, null);
serviceResource.setModelInvariantId(modelInvariantId);
BuildingBlockExecution execution = createExecution(sir, Arrays.asList(serviceResource));
Optional<String> message = validator.validate(execution);
assertThat(message).isEmpty();
}
use of org.onap.so.bpmn.infrastructure.workflow.tasks.Resource in project so by onap.
the class UserParamsServiceTraversalTest method getResourceListFromUserParamsForNetworks.
@Test
public void getResourceListFromUserParamsForNetworks() throws Exception {
requestAction = "createInstance";
initExecution(requestAction, readBpmnRequestFromFile(NETWORK_COLLECTION_JSON), false);
Mockito.doReturn(getCvnfcCustomizations()).when(mockCatalogDbClient).getCvnfcCustomization(anyString(), anyString(), anyString());
Mockito.doReturn(getService()).when(mockCatalogDbClient).getServiceByID(anyString());
Mockito.doReturn(new NetworkCollectionResourceCustomization()).when(mockCatalogDbClient).getNetworkCollectionResourceCustomizationByID(anyString());
List<Resource> resourceListFromUserParams = userParamsServiceTraversal.getResourceListFromUserParams(execution, getUserParams(), serviceInstanceId, requestAction);
List<WorkflowType> expected = List.of(WorkflowType.SERVICE, WorkflowType.NETWORK, WorkflowType.NETWORK, WorkflowType.NETWORKCOLLECTION);
List<WorkflowType> result = resourceListFromUserParams.stream().map(Resource::getResourceType).collect(Collectors.toList());
assertEquals(4, resourceListFromUserParams.size());
assertThat(expected, is(result));
}
use of org.onap.so.bpmn.infrastructure.workflow.tasks.Resource in project so by onap.
the class UserParamsServiceTraversalTest method getResourceListFromUserParamsBuildAndThrowExceptionWhenVfModuleAreEmpty.
@Test
public void getResourceListFromUserParamsBuildAndThrowExceptionWhenVfModuleAreEmpty() throws Exception {
initExecution(requestAction, readBpmnRequestFromFile(MACRO_ASSIGN_JSON), false);
VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
vfModuleCustomization.setVfModule(null);
Mockito.doReturn(vfModuleCustomization).when(mockCatalogDbClient).getVfModuleCustomizationByModelCuztomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
List<Resource> resourceListFromUserParams = userParamsServiceTraversal.getResourceListFromUserParams(execution, getUserParams(), serviceInstanceId, requestAction);
List<WorkflowType> expected = List.of(WorkflowType.SERVICE, WorkflowType.VNF);
List<WorkflowType> result = resourceListFromUserParams.stream().map(Resource::getResourceType).collect(Collectors.toList());
assertEquals(2, resourceListFromUserParams.size());
assertThat(expected, is(result));
}
Aggregations