use of org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock 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.ExecuteBuildingBlock 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.ExecuteBuildingBlock 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));
}
use of org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock in project so by onap.
the class ExecuteBuildingBlockRainyDayTest method queryRainyDayTableRollbackToCreatedNoConfiguration.
@Test
public void queryRainyDayTableRollbackToCreatedNoConfiguration() throws Exception {
customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
serviceInstance.getModelInfoServiceInstance().setServiceType("st1");
vnf.setVnfType("vnft1");
BuildingBlock buildingBlock = new BuildingBlock().setBpmnFlowName("AddFabricConfigurationBB");
ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock);
delegateExecution.setVariable("buildingBlock", executeBuildingBlock);
delegateExecution.setVariable("aLaCarte", true);
delegateExecution.setVariable("suppressRollback", false);
delegateExecution.setVariable("WorkflowExceptionCode", "7000");
RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus();
rainyDayHandlerStatus.setErrorCode("7000");
rainyDayHandlerStatus.setFlowName("AddFabricConfigurationBB");
rainyDayHandlerStatus.setServiceType("st1");
rainyDayHandlerStatus.setVnfType("vnft1");
rainyDayHandlerStatus.setPolicy("RollbackToCreatedNoConfiguration");
rainyDayHandlerStatus.setWorkStep(ASTERISK);
rainyDayHandlerStatus.setSecondaryPolicy("Abort");
doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatus("AddFabricConfigurationBB", "st1", "vnft1", "7000", "*", "errorMessage", "*");
executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true);
assertEquals("RollbackToCreatedNoConfiguration", delegateExecution.getVariable("handlingCode"));
assertEquals(Status.ROLLED_BACK_TO_CREATED.toString(), delegateExecution.getVariable("rollbackTargetState"));
}
use of org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock in project so by onap.
the class ExecuteBuildingBlockRainyDayTest method before.
@Before
public void before() {
serviceInstance = setServiceInstance();
customer = setCustomer();
vnf = setGenericVnf();
BuildingBlock buildingBlock = new BuildingBlock().setBpmnFlowName("AssignServiceInstanceBB");
ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock);
delegateExecution.setVariable("gBBInput", gBBInput);
delegateExecution.setVariable("WorkflowException", new WorkflowException("", 7000, ""));
delegateExecution.setVariable("buildingBlock", executeBuildingBlock);
delegateExecution.setVariable("lookupKeyMap", lookupKeyMap);
delegateExecution.setVariable("WorkflowException", new WorkflowException("processKey", 7000, "errorMessage"));
}
Aggregations