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));
}
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"));
}
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"));
}
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());
}
Aggregations