Search in sources :

Example 26 with OrchestrationContext

use of org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext 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 27 with OrchestrationContext

use of org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext in project so by onap.

the class NetworkAdapterCreateTasksTest method createNetworkTest.

@Test
public void createNetworkTest() {
    String cloudRegionPo = "cloudRegionPo";
    CreateNetworkRequest createNetworkRequest = new CreateNetworkRequest();
    execution.setVariable("cloudRegionPo", cloudRegionPo);
    doReturn(createNetworkRequest).when(networkAdapterObjectMapper).createNetworkRequestMapper(isA(RequestContext.class), isA(CloudRegion.class), isA(OrchestrationContext.class), isA(ServiceInstance.class), isA(L3Network.class), isA(Map.class), isA(String.class), isA(Customer.class));
    networkAdapterCreateTasks.createNetwork(execution);
    verify(networkAdapterObjectMapper, times(1)).createNetworkRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer);
    assertEquals(createNetworkRequest.toXmlString(), execution.getVariable("networkAdapterRequest"));
}
Also used : CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) CreateNetworkRequest(org.onap.so.adapters.nwrest.CreateNetworkRequest) Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) Map(java.util.Map) OrchestrationContext(org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext) Test(org.junit.Test)

Example 28 with OrchestrationContext

use of org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext in project so by onap.

the class VnfAdapterCreateTasksTest method test_createVolumeGroupRequest_for_alaCarte_flow.

@Test
public void test_createVolumeGroupRequest_for_alaCarte_flow() throws Exception {
    RequestContext requestContext = setRequestContext();
    ServiceInstance serviceInstance = setServiceInstance();
    GenericVnf genericVnf = setGenericVnf();
    VolumeGroup volumeGroup = setVolumeGroup();
    volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
    VfModule vfModule = setVfModule();
    vfModule.setSelflink("vfModuleSelfLink");
    CloudRegion cloudRegion = setCloudRegion();
    OrchestrationContext orchestrationContext = setOrchestrationContext();
    orchestrationContext.setIsRollbackEnabled(true);
    CreateVolumeGroupRequest request = new CreateVolumeGroupRequest();
    request.setVolumeGroupId("volumeGroupStackId");
    when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
    when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID))).thenReturn(volumeGroup);
    when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
    doReturn(request).when(vnfAdapterVolumeGroupResources).createVolumeGroupRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, null);
    vnfAdapterCreateTasks.createVolumeGroupRequest(execution);
    verify(vnfAdapterVolumeGroupResources, times(1)).createVolumeGroupRequest(any(RequestContext.class), any(CloudRegion.class), any(OrchestrationContext.class), eq(serviceInstance), eq(genericVnf), eq(volumeGroup), ArgumentMatchers.isNull());
    assertEquals(request.toXmlString(), execution.getVariable("VNFREST_Request"));
}
Also used : CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) CreateVolumeGroupRequest(org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) OrchestrationContext(org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext) Test(org.junit.Test)

Example 29 with OrchestrationContext

use of org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext in project so by onap.

the class VnfAdapterCreateTasksTest method test_createVfModuleWithVolumeGroup.

@Test
public void test_createVfModuleWithVolumeGroup() throws Exception {
    RequestContext requestContext = setRequestContext();
    ServiceInstance serviceInstance = setServiceInstance();
    GenericVnf genericVnf = setGenericVnf();
    VfModule vfModule = setVfModule();
    VolumeGroup volumeGroup = setVolumeGroup();
    CloudRegion cloudRegion = setCloudRegion();
    OrchestrationContext orchestrationContext = setOrchestrationContext();
    orchestrationContext.setIsRollbackEnabled(true);
    CreateVfModuleRequest modRequest = new CreateVfModuleRequest();
    modRequest.setVfModuleId(vfModule.getVfModuleId());
    modRequest.setBaseVfModuleStackId("baseVfModuleStackId");
    modRequest.setVfModuleName(vfModule.getVfModuleName());
    CreateVfModuleRequest createVfModuleRequest = modRequest;
    String sdncVfModuleQueryResponse = "{someJson}";
    execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), sdncVfModuleQueryResponse);
    String sdncVnfQueryResponse = "{someJson}";
    execution.setVariable("SDNCQueryResponse_" + genericVnf.getVnfId(), sdncVnfQueryResponse);
    when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
    when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID))).thenReturn(volumeGroup);
    when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
    doReturn(createVfModuleRequest).when(vnfAdapterVfModuleResources).createVfModuleRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, vfModule, volumeGroup, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
    vnfAdapterCreateTasks.createVfModule(execution);
    verify(vnfAdapterVfModuleResources, times(1)).createVfModuleRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, vfModule, volumeGroup, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
    assertEquals(execution.getVariable("VNFREST_Request"), createVfModuleRequest.toXmlString());
}
Also used : CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) CreateVfModuleRequest(org.onap.so.adapters.vnfrest.CreateVfModuleRequest) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) OrchestrationContext(org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext) Test(org.junit.Test)

Aggregations

OrchestrationContext (org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext)29 Test (org.junit.Test)25 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)25 RequestContext (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext)25 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)24 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)18 VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)16 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)14 HashMap (java.util.HashMap)13 CreateVfModuleRequest (org.onap.so.adapters.vnfrest.CreateVfModuleRequest)13 ModelInfoVfModule (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule)13 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)11 VolumeGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup)7 Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)6 Map (java.util.Map)5 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)5 CreateVolumeGroupRequest (org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest)4 File (java.io.File)3 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)3 MsoRequest (org.onap.so.entity.MsoRequest)3