Search in sources :

Example 36 with Resource

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());
}
Also used : GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) ArrayList(java.util.ArrayList) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) Pair(org.javatuples.Pair) Test(org.junit.Test)

Example 37 with Resource

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"));
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) Test(org.junit.Test)

Example 38 with Resource

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();
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) Test(org.junit.Test)

Example 39 with Resource

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));
}
Also used : NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) WorkflowType(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowType) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) ConfigurationResource(org.onap.so.db.catalog.beans.ConfigurationResource) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 40 with Resource

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));
}
Also used : WorkflowType(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowType) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) ConfigurationResource(org.onap.so.db.catalog.beans.ConfigurationResource) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Aggregations

Resource (org.onap.so.bpmn.infrastructure.workflow.tasks.Resource)40 Test (org.junit.Test)14 ArrayList (java.util.ArrayList)10 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)9 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)8 CollectionResource (org.onap.so.db.catalog.beans.CollectionResource)7 ServiceInstancesRequest (org.onap.so.serviceinstancebeans.ServiceInstancesRequest)6 Pair (org.javatuples.Pair)5 Service (org.onap.so.db.catalog.beans.Service)5 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 BuildingBlockExecution (org.onap.so.bpmn.common.BuildingBlockExecution)4 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)4 VnfResourceCustomization (org.onap.so.db.catalog.beans.VnfResourceCustomization)4 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)4 Mockito.anyString (org.mockito.Mockito.anyString)3 Relationship (org.onap.aai.domain.yang.Relationship)3 Configuration (org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration)3 VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)3 ConfigurationResource (org.onap.so.db.catalog.beans.ConfigurationResource)3 VfModuleCustomization (org.onap.so.db.catalog.beans.VfModuleCustomization)3