use of org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock in project so by onap.
the class BBInputSetupTest method test_getGBBMacroNoUserParamsExistingService_forActivateVnfBB.
@Test
public void test_getGBBMacroNoUserParamsExistingService_forActivateVnfBB() 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("ActivateVnfBB").setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
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 GeneratePayloadForCdsTest method createGeneralBuildingBlock.
private GeneralBuildingBlock createGeneralBuildingBlock() {
GeneralBuildingBlock generalBuildingBlock = new GeneralBuildingBlock();
RequestContext requestContext = new RequestContext();
RequestParameters requestParameters = new RequestParameters();
requestParameters.setUserParams(createRequestUserParams());
requestContext.setRequestParameters(requestParameters);
requestContext.setMsoRequestId(MSO_REQUEST_ID);
generalBuildingBlock.setRequestContext(requestContext);
return generalBuildingBlock;
}
use of org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock in project so by onap.
the class BBInputSetupTest method testPopulateGBBWithSIAndAdditionalInfo.
@Test
public void testPopulateGBBWithSIAndAdditionalInfo() throws Exception {
GeneralBuildingBlock expected = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpectedWUserParamsInfo.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);
RequestContext requestContext = mapper.readValue(new File(RESOURCE_PATH + "RequestContextExpected.json"), RequestContext.class);
ServiceInstance serviceInstance = mapper.readValue(new File(RESOURCE_PATH + "ServiceInstance_getServiceInstanceNOAAIExpected.json"), ServiceInstance.class);
CloudConfiguration cloudConfiguration = new CloudConfiguration();
cloudConfiguration.setTenantId("tenantId");
requestDetails.setCloudConfiguration(cloudConfiguration);
OrchestrationContext orchestrationContext = new OrchestrationContext();
orchestrationContext.setIsRollbackEnabled(false);
CloudRegion cloudRegion = new CloudRegion();
cloudRegion.setCloudOwner("test-owner-name");
cloudRegion.setLcpCloudRegionId("lcpCloudRegionId");
cloudRegion.setComplex("complexName");
cloudRegion.setTenantId("tenantId");
Map<String, String> uriKeys = new HashMap<>();
uriKeys.put(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId, "global-customer-id");
uriKeys.put(AAIFluentTypeBuilder.Types.SERVICE_SUBSCRIPTION.getUriParams().serviceType, "service-type");
Customer customer = new Customer();
ServiceSubscription serviceSubscription = new ServiceSubscription();
serviceSubscription.setServiceType("subscriptionServiceType");
customer.setGlobalCustomerId("globalCustomerId");
customer.setSubscriberName("subscriberName");
customer.setSubscriberType("subscriberType");
customer.setServiceSubscription(serviceSubscription);
org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant tenant = new org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant();
tenant.setTenantContext("tenantContext");
tenant.setTenantId("tenantId");
tenant.setTenantName("tenantName");
org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = Mockito.mock(org.onap.aai.domain.yang.CloudRegion.class);
org.onap.aai.domain.yang.Tenants aaiTenants = Mockito.mock(org.onap.aai.domain.yang.Tenants.class);
org.onap.aai.domain.yang.Tenant aaiTenant = new org.onap.aai.domain.yang.Tenant();
aaiTenant.setTenantId("tenantId");
List<org.onap.aai.domain.yang.Tenant> tenants = new ArrayList<>();
tenants.add(aaiTenant);
String requestAction = "createInstance";
doReturn(uriKeys).when(SPY_bbInputSetupUtils).getURIKeysFromServiceInstance(serviceInstance.getServiceInstanceId());
doReturn(customer).when(SPY_bbInputSetup).mapCustomer(uriKeys.get("global-customer-id"), uriKeys.get("service-type"));
doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration());
doReturn(orchestrationContext).when(bbInputSetupMapperLayer).mapOrchestrationContext(requestDetails);
doReturn(requestContext).when(bbInputSetupMapperLayer).mapRequestContext(requestDetails);
doReturn(cloudRegion).when(bbInputSetupMapperLayer).mapCloudRegion(requestDetails.getCloudConfiguration(), aaiCloudRegion);
doReturn(tenant).when(bbInputSetupMapperLayer).mapTenant(aaiTenant);
doReturn(aaiTenants).when(aaiCloudRegion).getTenants();
doReturn(tenants).when(aaiTenants).getTenant();
BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setServiceInstance(serviceInstance).setRequestDetails(requestDetails).setExecuteBB(executeBB).setRequestAction(requestAction).build();
GeneralBuildingBlock actual = SPY_bbInputSetup.populateGBBWithSIAndAdditionalInfo(parameter);
assertThat(actual, sameBeanAs(expected));
}
use of org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock in project so by onap.
the class BBInputSetupPopulateMethodsTest method test_getGBBMacro_populateVolumeGroup_shouldBeCalled.
@Test
public void test_getGBBMacro_populateVolumeGroup_shouldBeCalled() throws Exception {
// given
GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockWithVnf.json"), GeneralBuildingBlock.class);
RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
GenericVnf aaiVnf = new GenericVnf();
aaiVnf.setModelCustomizationId("modelCustId");
Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"), ExecuteBuildingBlock.class);
BuildingBlock buildingBlock = executeBB.getBuildingBlock();
buildingBlock.setBpmnFlowName(AssignFlows.VOLUME_GROUP.toString()).setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap, requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
doReturn(service).when(bbInputSetupUtils).getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
doReturn("vnfId").when(SPY_bbInputSetup).getVnfId(executeBB, lookupKeyMap);
doReturn(aaiVnf).when(bbInputSetupUtils).getAAIGenericVnf(any(String.class));
// when
SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
// then
verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(any(BBInputSetupParameter.class));
}
use of org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock in project so by onap.
the class BBInputSetupPopulateMethodsTest method test_getGBBMacro_populateVfModule_shouldBeCalled.
@Test
public void test_getGBBMacro_populateVfModule_shouldBeCalled() throws Exception {
// given
GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockWithVnf.json"), GeneralBuildingBlock.class);
RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
GenericVnf aaiVnf = new GenericVnf();
aaiVnf.setModelCustomizationId("modelCustId");
Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"), ExecuteBuildingBlock.class);
executeBB.setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails);
BuildingBlock buildingBlock = executeBB.getBuildingBlock();
buildingBlock.setBpmnFlowName(AssignFlows.VF_MODULE.toString()).setKey("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap, requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
doReturn(service).when(bbInputSetupUtils).getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
doReturn("vnfId").when(SPY_bbInputSetup).getVnfId(executeBB, lookupKeyMap);
doReturn(aaiVnf).when(bbInputSetupUtils).getAAIGenericVnf(any(String.class));
// when
SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
// then
verify(SPY_bbInputSetup, times(1)).populateVfModule(any(BBInputSetupParameter.class));
}
Aggregations