Search in sources :

Example 56 with BuildingBlock

use of org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock in project so by onap.

the class WorkflowActionBBTasksTest method rollbackExecutionRollbackToCreatedNoConfigurationWithFabricTest.

@Test
public void rollbackExecutionRollbackToCreatedNoConfigurationWithFabricTest() {
    execution.setVariable("isRollback", false);
    execution.setVariable("handlingCode", "RollbackToCreatedNoConfiguration");
    execution.setVariable("requestAction", EMPTY_STRING);
    execution.setVariable("resourceName", EMPTY_STRING);
    List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
    BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
    ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
    flowsToExecute.add(ebb1);
    BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB");
    ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
    flowsToExecute.add(ebb2);
    BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
    ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
    flowsToExecute.add(ebb3);
    BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("AddFabricConfigurationBB");
    ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4);
    flowsToExecute.add(ebb4);
    execution.setVariable("flowsToExecute", flowsToExecute);
    execution.setVariable("gCurrentSequence", 4);
    workflowActionBBTasks.rollbackExecutionPath(execution);
    List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
    assertEquals(0, execution.getVariable("gCurrentSequence"));
    assertEquals(1, ebbs.size());
    assertEquals("DeactivateVfModuleBB", ebbs.get(0).getBuildingBlock().getBpmnFlowName());
}
Also used : ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) ArrayList(java.util.ArrayList) List(java.util.List) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) ArrayList(java.util.ArrayList) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 57 with BuildingBlock

use of org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock in project so by onap.

the class WorkflowActionBBTasksTest method select2BBTest.

@Test
public void select2BBTest() {
    String vnfCustomizationUUID = "1234567";
    String modelUuid = "1234567";
    prepareDelegateExecution();
    List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
    BuildingBlock buildingBlock = new BuildingBlock().setBpmnFlowName("ConfigDeployVnfBB").setKey(vnfCustomizationUUID);
    RequestDetails rd = new RequestDetails();
    ModelInfo mi = new ModelInfo();
    mi.setModelUuid(modelUuid);
    rd.setModelInfo(mi);
    ExecuteBuildingBlock ebb = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock).setRequestDetails(rd);
    ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
    flowsToExecute.add(ebb);
    List<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList<>();
    VnfResourceCustomization vrc = new VnfResourceCustomization();
    vrc.setSkipPostInstConf(false);
    vrc.setModelCustomizationUUID(vnfCustomizationUUID);
    vnfResourceCustomizations.add(vrc);
    GenericVnf genericVnf = new GenericVnf();
    genericVnf.setModelCustomizationId(vnfCustomizationUUID);
    doReturn(vnfResourceCustomizations).when(catalogDbClient).getVnfResourceCustomizationByModelUuid(modelUuid);
    doReturn(vrc).when(catalogDbClient).findVnfResourceCustomizationInList(vnfCustomizationUUID, vnfResourceCustomizations);
    flowsToExecute.add(ebb2);
    execution.setVariable("flowsToExecute", flowsToExecute);
    workflowActionBBTasks.selectBB(execution);
    boolean success = (boolean) execution.getVariable("completed");
    int currentSequence = (int) execution.getVariable("gCurrentSequence");
    assertFalse(success);
    assertEquals(1, currentSequence);
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) GenericVnf(org.onap.aai.domain.yang.GenericVnf) ArrayList(java.util.ArrayList) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 58 with BuildingBlock

use of org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock in project so by onap.

the class BBInputSetupTest method test_getGBBMacroNoUserParamsCreate_shouldBeCalled_whenBBhasVirtualLink.

@Test
public void test_getGBBMacroNoUserParamsCreate_shouldBeCalled_whenBBhasVirtualLink() throws Exception {
    // given
    String resourceId = "123";
    String vnfType = "vnfType";
    String requestAction = "createInstance";
    Service service = Mockito.mock(Service.class);
    GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"), GeneralBuildingBlock.class);
    Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
    List<NetworkResourceCustomization> networkCustList = new ArrayList<>();
    NetworkResourceCustomization networkCust = Mockito.mock(NetworkResourceCustomization.class);
    networkCustList.add(networkCust);
    CollectionNetworkResourceCustomization collectionNetworkResourceCust = Mockito.mock(CollectionNetworkResourceCustomization.class);
    org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
    aaiVnf.setModelCustomizationId("modelCustId");
    ModelInfoNetwork modelInfoNetwork = Mockito.mock(ModelInfoNetwork.class);
    NetworkResourceCustomization networkResourceCustomization = Mockito.mock(NetworkResourceCustomization.class);
    ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
    RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
    requestDetails.getRequestParameters().setUserParams(null);
    ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"), ExecuteBuildingBlock.class);
    executeBB.setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails);
    BuildingBlock buildingBlock = executeBB.getBuildingBlock();
    buildingBlock.setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString()).setKey("ab153b6e-c364-44c0-bef6-1f2982117f04").setIsVirtualLink(true);
    doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap, requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
    doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
    doReturn(collectionNetworkResourceCust).when(SPY_bbInputSetupUtils).getCatalogCollectionNetworkResourceCustByID(any(String.class));
    doReturn(networkResourceCustomization).when(bbInputSetupMapperLayer).mapCollectionNetworkResourceCustToNetworkResourceCust(collectionNetworkResourceCust);
    doReturn(modelInfoNetwork).when(bbInputSetupMapperLayer).mapCatalogNetworkToNetwork(networkResourceCustomization);
    // when
    SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
    // then
    verify(SPY_bbInputSetup, times(1)).getGBBMacroNoUserParamsCreate(executeBB, lookupKeyMap, executeBB.getBuildingBlock().getBpmnFlowName(), "ab153b6e-c364-44c0-bef6-1f2982117f04", gBB, service);
}
Also used : GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) ArrayList(java.util.ArrayList) Service(org.onap.so.db.catalog.beans.Service) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ModelInfoNetwork(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork) CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) ConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys) BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.tasks.BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys) CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) NetworkResourceCustomization(org.onap.so.db.catalog.beans.NetworkResourceCustomization) File(java.io.File) Test(org.junit.Test)

Example 59 with BuildingBlock

use of org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock in project so by onap.

the class BBInputSetupTest method testgetGBBMacroWithEmptyUserParams.

@Test
public void testgetGBBMacroWithEmptyUserParams() throws Exception {
    String resourceId = "123";
    String vnfType = "vnfType";
    String requestAction = "createInstance";
    Service service = Mockito.mock(Service.class);
    GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"), GeneralBuildingBlock.class);
    ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"), ExecuteBuildingBlock.class);
    RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
    requestDetails.getRequestParameters().getUserParams().clear();
    org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
    aaiVnf.setModelCustomizationId("modelCustId");
    Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
    BuildingBlock buildingBlock = executeBB.getBuildingBlock();
    buildingBlock.setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString()).setKey("ab153b6e-c364-44c0-bef6-1f2982117f04").setIsVirtualLink(false);
    doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap, requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
    doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
    SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
    verify(SPY_bbInputSetup, times(1)).getGBBMacroNoUserParamsCreate(any(ExecuteBuildingBlock.class), any(), any(String.class), any(String.class), any(GeneralBuildingBlock.class), any(Service.class));
}
Also used : GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) Service(org.onap.so.db.catalog.beans.Service) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) File(java.io.File) Test(org.junit.Test)

Example 60 with BuildingBlock

use of org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock in project so by onap.

the class BBInputSetupTest method test_getGBBMacroNoUserParamsCreate_shouldBeCalled.

@Test
public void test_getGBBMacroNoUserParamsCreate_shouldBeCalled() throws Exception {
    // given
    String resourceId = "123";
    String vnfType = "vnfType";
    String requestAction = "createInstance";
    Service service = Mockito.mock(Service.class);
    GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"), GeneralBuildingBlock.class);
    Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
    List<NetworkResourceCustomization> networkCustList = new ArrayList<>();
    NetworkResourceCustomization networkCust = Mockito.mock(NetworkResourceCustomization.class);
    networkCustList.add(networkCust);
    ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
    RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
    requestDetails.getRequestParameters().setUserParams(null);
    ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"), ExecuteBuildingBlock.class);
    executeBB.setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails);
    BuildingBlock buildingBlock = executeBB.getBuildingBlock();
    buildingBlock.setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString()).setKey("ab153b6e-c364-44c0-bef6-1f2982117f04").setIsVirtualLink(false);
    doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap, requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
    doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
    doReturn(networkCustList).when(service).getNetworkCustomizations();
    doReturn("ab153b6e-c364-44c0-bef6-1f2982117f04").when(networkCust).getModelCustomizationUUID();
    doNothing().when(SPY_bbInputSetup).populateL3Network(any(BBInputSetupParameter.class));
    // when
    SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
    // then
    verify(SPY_bbInputSetup, times(1)).getGBBMacroNoUserParamsCreate(executeBB, lookupKeyMap, executeBB.getBuildingBlock().getBpmnFlowName(), "ab153b6e-c364-44c0-bef6-1f2982117f04", gBB, service);
}
Also used : GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) ArrayList(java.util.ArrayList) Service(org.onap.so.db.catalog.beans.Service) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys) BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.tasks.BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys) CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) NetworkResourceCustomization(org.onap.so.db.catalog.beans.NetworkResourceCustomization) File(java.io.File) Test(org.junit.Test)

Aggregations

BuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock)66 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)64 Test (org.junit.Test)51 ArrayList (java.util.ArrayList)30 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)30 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)28 File (java.io.File)24 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)22 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)22 ConfigurationResourceKeys (org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys)19 List (java.util.List)18 Service (org.onap.so.db.catalog.beans.Service)18 BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys (org.onap.so.bpmn.servicedecomposition.tasks.BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys)15 RelatedInstanceList (org.onap.so.serviceinstancebeans.RelatedInstanceList)15 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)12 GenericVnf (org.onap.aai.domain.yang.GenericVnf)11 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)11 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)11 DelegateExecution (org.camunda.bpm.engine.delegate.DelegateExecution)10 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)10