Search in sources :

Example 81 with ExecuteBuildingBlock

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));
}
Also used : GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) HashMap(java.util.HashMap) Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) ArrayList(java.util.ArrayList) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) ServiceSubscription(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) OrchestrationContext(org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) File(java.io.File) Test(org.junit.Test)

Example 82 with ExecuteBuildingBlock

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));
}
Also used : GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) GenericVnf(org.onap.aai.domain.yang.GenericVnf) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) File(java.io.File) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) Test(org.junit.Test)

Example 83 with ExecuteBuildingBlock

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));
}
Also used : GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) GenericVnf(org.onap.aai.domain.yang.GenericVnf) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.tasks.BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys) ConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys) File(java.io.File) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) Test(org.junit.Test)

Example 84 with ExecuteBuildingBlock

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"));
}
Also used : BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) RainyDayHandlerStatus(org.onap.so.db.catalog.beans.macro.RainyDayHandlerStatus) Test(org.junit.Test) BaseTest(org.onap.so.BaseTest)

Example 85 with ExecuteBuildingBlock

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"));
}
Also used : BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) WorkflowException(org.onap.so.bpmn.core.WorkflowException) Before(org.junit.Before)

Aggregations

ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)147 Test (org.junit.Test)107 ArrayList (java.util.ArrayList)86 List (java.util.List)65 BuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock)63 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)61 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)49 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)45 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)45 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)41 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)40 NorthBoundRequest (org.onap.so.db.catalog.beans.macro.NorthBoundRequest)40 File (java.io.File)38 ArgumentMatchers.anyList (org.mockito.ArgumentMatchers.anyList)38 RelationshipList (org.onap.aai.domain.yang.RelationshipList)38 OrchestrationFlow (org.onap.so.db.catalog.beans.macro.OrchestrationFlow)37 Service (org.onap.so.db.catalog.beans.Service)35 HashMap (java.util.HashMap)27 VfModule (org.onap.aai.domain.yang.VfModule)25 RelatedInstanceList (org.onap.so.serviceinstancebeans.RelatedInstanceList)24