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