use of org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock 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.GeneralBuildingBlock 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.GeneralBuildingBlock 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);
}
use of org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock in project so by onap.
the class BBInputSetupTest method test_getGBBMacroNoUserParamsExistingService_forControllerExecutionBB.
@Test
public void test_getGBBMacroNoUserParamsExistingService_forControllerExecutionBB() throws Exception {
// given
String requestAction = "unassignInstance";
GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"), GeneralBuildingBlock.class);
L3Network network = new L3Network();
network.setNetworkId("networkId");
gBB.getServiceInstance().getNetworks().add(network);
ServiceInstance serviceInstance = gBB.getServiceInstance();
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().setUserParams(null);
Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
Service service = Mockito.mock(Service.class);
CloudConfiguration cloudConfiguration = new CloudConfiguration();
cloudConfiguration.setLcpCloudRegionId("cloudRegionId");
org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
org.onap.aai.domain.yang.L3Network aaiNetwork = new org.onap.aai.domain.yang.L3Network();
aaiNetwork.setModelCustomizationId("modelCustId");
GenericVnf vnf = new GenericVnf();
vnf.setVnfId("vnfId");
gBB.getServiceInstance().getVnfs().add(vnf);
org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
aaiVnf.setModelCustomizationId("modelCustId");
ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
executeBB.setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails);
BuildingBlock buildingBlock = executeBB.getBuildingBlock();
buildingBlock.setBpmnFlowName("ControllerExecutionBB").setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
buildingBlock.setBpmnScope("VNF");
aaiServiceInstance.setModelVersionId("modelVersionId");
doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById(lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance);
doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(any(BBInputSetupParameter.class));
doReturn(aaiVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
doNothing().when(SPY_bbInputSetup).mapCatalogVnf(any(GenericVnf.class), any(ModelInfo.class), any(Service.class));
// when
SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap, executeBB.getBuildingBlock().getBpmnFlowName(), requestAction, cloudConfiguration);
// then
verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(any(GenericVnf.class), any(ModelInfo.class), any(Service.class));
}
use of org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock in project so by onap.
the class BBInputSetupTest method testGetGBBALaCarteNonService.
@Test
public void testGetGBBALaCarteNonService() throws Exception {
GeneralBuildingBlock expected = 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_withRelatedInstanceList.json"), RequestDetails.class);
Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
String requestAction = "createInstance";
Service service = Mockito.mock(Service.class);
ServiceModel serviceModel = new ServiceModel();
serviceModel.setCurrentService(service);
ServiceInstance serviceInstance = Mockito.mock(ServiceInstance.class);
String resourceId = "123";
String vnfType = "vnfType";
org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
aaiServiceInstance.setModelVersionId("modelVersionId");
org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = Mockito.mock(org.onap.aai.domain.yang.CloudRegion.class);
lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "instanceId");
doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("instanceId");
doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(any(BBInputSetupParameter.class));
doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance);
doReturn(expected).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(any(BBInputSetupParameter.class));
GeneralBuildingBlock actual = SPY_bbInputSetup.getGBBALaCarteNonService(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
assertThat(actual, sameBeanAs(expected));
}
Aggregations