Search in sources :

Example 6 with RequestDetails

use of org.onap.so.serviceinstancebeans.RequestDetails in project so by onap.

the class BBInputSetupTest method testGetServiceSubscription.

@Test
public void testGetServiceSubscription() throws IOException {
    ServiceSubscription expected = new ServiceSubscription();
    RequestDetails requestDetails = new RequestDetails();
    RequestParameters params = new RequestParameters();
    params.setSubscriptionServiceType("subscriptionServiceType");
    requestDetails.setRequestParameters(params);
    org.onap.aai.domain.yang.ServiceSubscription aaiServiceSubscription = new org.onap.aai.domain.yang.ServiceSubscription();
    Customer customer = new Customer();
    customer.setGlobalCustomerId("globalCustomerId");
    doReturn(aaiServiceSubscription).when(SPY_bbInputSetupUtils).getAAIServiceSubscription(customer.getGlobalCustomerId(), requestDetails.getRequestParameters().getSubscriptionServiceType());
    doReturn(expected).when(bbInputSetupMapperLayer).mapAAIServiceSubscription(aaiServiceSubscription);
    ServiceSubscription actual = SPY_bbInputSetup.getServiceSubscription(requestDetails, customer);
    assertThat(actual, sameBeanAs(expected));
}
Also used : ServiceSubscription(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription) Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) RequestParameters(org.onap.so.serviceinstancebeans.RequestParameters) Test(org.junit.Test)

Example 7 with RequestDetails

use of org.onap.so.serviceinstancebeans.RequestDetails in project so by onap.

the class BBInputSetupTest method testPopulateGenericVnfReplace.

@Test
public void testPopulateGenericVnfReplace() throws JsonParseException, JsonMappingException, IOException {
    org.onap.so.serviceinstancebeans.Platform platform = new org.onap.so.serviceinstancebeans.Platform();
    org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness = new org.onap.so.serviceinstancebeans.LineOfBusiness();
    String instanceName = "vnfName";
    ModelInfo modelInfo = new ModelInfo();
    modelInfo.setModelType(ModelType.vnf);
    ServiceInstance serviceInstance = new ServiceInstance();
    GenericVnf vnf = new GenericVnf();
    vnf.setVnfId("genericVnfId");
    vnf.setVnfName("vnfName");
    serviceInstance.getVnfs().add(vnf);
    String vnfType = "vnfType";
    String applicationId = "applicationId";
    RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetails_CreateVnf.json"), RequestDetails.class);
    Service service = mapper.readValue(new File(RESOURCE_PATH + "CatalogDBService_getServiceInstanceNOAAIInput.json"), Service.class);
    Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
    lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "genericVnfId");
    String bbName = AssignFlows.VNF.toString();
    String resourceId = "123";
    org.onap.aai.domain.yang.GenericVnf vnfAAI = new org.onap.aai.domain.yang.GenericVnf();
    vnfAAI.setModelCustomizationId("modelCustId");
    doReturn(vnfAAI).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
    doNothing().when(SPY_bbInputSetup).mapCatalogVnf(vnf, modelInfo, service);
    org.onap.aai.domain.yang.InstanceGroup instanceGroupAAI = new org.onap.aai.domain.yang.InstanceGroup();
    doReturn(instanceGroupAAI).when(SPY_bbInputSetupUtils).getAAIInstanceGroup(any());
    org.onap.so.db.catalog.beans.InstanceGroup catalogInstanceGroup = new org.onap.so.db.catalog.beans.InstanceGroup();
    doReturn(catalogInstanceGroup).when(SPY_bbInputSetupUtils).getCatalogInstanceGroup(any());
    BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setModelInfo(modelInfo).setInstanceName(instanceName).setPlatform(platform).setLineOfBusiness(lineOfBusiness).setService(service).setBbName(bbName).setServiceInstance(serviceInstance).setLookupKeyMap(lookupKeyMap).setRelatedInstanceList(requestDetails.getRelatedInstanceList()).setResourceId(resourceId).setVnfType(vnfType).setProductFamilyId(requestDetails.getRequestInfo().getProductFamilyId()).setApplicationId(applicationId).setIsReplace(true).build();
    SPY_bbInputSetup.populateGenericVnf(parameter);
    assertEquals("my-test-uuid", modelInfo.getModelCustomizationUuid());
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) Platform(org.onap.so.bpmn.servicedecomposition.bbobjects.Platform) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) HashMap(java.util.HashMap) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) Service(org.onap.so.db.catalog.beans.Service) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup) LineOfBusiness(org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness) File(java.io.File) Test(org.junit.Test)

Example 8 with RequestDetails

use of org.onap.so.serviceinstancebeans.RequestDetails in project so by onap.

the class BBInputSetupTest method testgetGBBMacroException.

@Test(expected = Exception.class)
public void testgetGBBMacroException() throws Exception {
    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);
    Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
    String resourceId = "123";
    String vnfType = "vnfType";
    String requestAction = "createInstance";
    BuildingBlock buildingBlock = executeBB.getBuildingBlock();
    buildingBlock.setBpmnFlowName("Network").setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
    SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
}
Also used : 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) HashMap(java.util.HashMap) File(java.io.File) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) Test(org.junit.Test)

Example 9 with RequestDetails

use of org.onap.so.serviceinstancebeans.RequestDetails in project so by onap.

the class BBInputSetupTest method testPopulateConfigurationReplace.

@Test
public void testPopulateConfigurationReplace() throws JsonParseException, JsonMappingException, IOException {
    String instanceName = "configurationName";
    ModelInfo modelInfo = new ModelInfo();
    modelInfo.setModelCustomizationUuid("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
    ServiceInstance serviceInstance = new ServiceInstance();
    Configuration configuration = new Configuration();
    configuration.setConfigurationId("configurationId");
    configuration.setConfigurationName("configurationName");
    serviceInstance.getConfigurations().add(configuration);
    String resourceId = "configurationId";
    String vnfcName = "vnfcName";
    // Mock service
    Service service = mapper.readValue(new File(RESOURCE_PATH + "CatalogDBService_getServiceInstanceNOAAIInput.json"), Service.class);
    ConfigurationResourceCustomization configurationCust = new ConfigurationResourceCustomization();
    configurationCust.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
    service.getConfigurationCustomizations().add(configurationCust);
    Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
    lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId");
    String bbName = AssignFlows.FABRIC_CONFIGURATION.toString();
    ServiceModel serviceModel = new ServiceModel();
    serviceModel.setNewService(service);
    ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
    configResourceKeys.setVnfcName(vnfcName);
    Vnfc vnfc = new Vnfc();
    vnfc.setVnfcName(vnfcName);
    RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_withRelatedInstanceList.json"), RequestDetails.class);
    doNothing().when(SPY_bbInputSetup).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys);
    doReturn(vnfc).when(SPY_bbInputSetup).getVnfcToConfiguration(vnfcName);
    BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setRequestId(REQUEST_ID).setModelInfo(modelInfo).setService(service).setBbName(bbName).setServiceInstance(serviceInstance).setLookupKeyMap(lookupKeyMap).setResourceId(resourceId).setInstanceName(instanceName).setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails).setServiceModel(serviceModel).setIsReplace(true).build();
    SPY_bbInputSetup.populateConfiguration(parameter);
    configResourceKeys.setVnfResourceCustomizationUUID("my-test-uuid");
    verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys);
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) HashMap(java.util.HashMap) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) Service(org.onap.so.db.catalog.beans.Service) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) ServiceModel(org.onap.so.bpmn.servicedecomposition.entities.ServiceModel) ConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys) BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.tasks.BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys) File(java.io.File) Vnfc(org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc) ConfigurationResourceCustomization(org.onap.so.db.catalog.beans.ConfigurationResourceCustomization) Test(org.junit.Test)

Example 10 with RequestDetails

use of org.onap.so.serviceinstancebeans.RequestDetails in project so by onap.

the class BBInputSetupTest method test_getGBBMacroNoUserParamsExistingService_forControllerExecutionBB_VFModule.

@Test
public void test_getGBBMacroNoUserParamsExistingService_forControllerExecutionBB_VFModule() 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");
    VfModule vfModule = new VfModule();
    vfModule.setVfModuleId("vfModuleId");
    gBB.getServiceInstance().getVnfs().get(0).getVfModules().add(vfModule);
    org.onap.aai.domain.yang.VfModule aaiVfModule = new org.onap.aai.domain.yang.VfModule();
    aaiVfModule.setModelCustomizationId("modelCustId");
    ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
    executeBB.setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails);
    BuildingBlock buildingBlock = executeBB.getBuildingBlock();
    buildingBlock.setBpmnFlowName("ControllerExecutionBB").setKey("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
    buildingBlock.setBpmnScope("VfModule");
    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));
    doReturn(aaiVfModule).when(SPY_bbInputSetupUtils).getAAIVfModule(vnf.getVnfId(), vfModule.getVfModuleId());
    // 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));
    verify(SPY_bbInputSetup, times(1)).mapCatalogVfModule(any(VfModule.class), any(ModelInfo.class), any(Service.class), any(String.class));
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) Service(org.onap.so.db.catalog.beans.Service) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) ConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys) BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.tasks.BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys) File(java.io.File) Test(org.junit.Test)

Aggregations

RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)163 Test (org.junit.Test)126 Service (org.onap.so.db.catalog.beans.Service)55 File (java.io.File)52 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)51 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)47 WorkflowResourceIds (org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds)43 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)42 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)38 HashMap (java.util.HashMap)37 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)36 ServiceInstancesRequest (org.onap.so.serviceinstancebeans.ServiceInstancesRequest)36 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)35 BuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock)27 RequestInfo (org.onap.so.serviceinstancebeans.RequestInfo)27 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)23 ConfigurationResourceKeys (org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys)21 CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)20 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)19 GenericVnf (org.onap.aai.domain.yang.GenericVnf)18