Search in sources :

Example 11 with RequestDetails

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

the class BBInputSetupTest method test_getGBBMacroNoUserParamsExistingService_forCatalogNetwork.

@Test
public void test_getGBBMacroNoUserParamsExistingService_forCatalogNetwork() 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");
    ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
    executeBB.setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails);
    BuildingBlock buildingBlock = executeBB.getBuildingBlock();
    buildingBlock.setBpmnFlowName("DeleteNetworkBB").setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
    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(aaiNetwork).when(SPY_bbInputSetupUtils).getAAIL3Network(network.getNetworkId());
    doNothing().when(SPY_bbInputSetup).mapCatalogNetwork(any(L3Network.class), any(ModelInfo.class), any(Service.class));
    // when
    SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap, executeBB.getBuildingBlock().getBpmnFlowName(), requestAction, null);
    // then
    verify(SPY_bbInputSetup, times(1)).mapCatalogNetwork(any(L3Network.class), any(ModelInfo.class), any(Service.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) 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) Service(org.onap.so.db.catalog.beans.Service) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) 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)

Example 12 with RequestDetails

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

the class BBInputSetupTest method testGetGBBCMAddMembersAction.

@Test
public void testGetGBBCMAddMembersAction() throws Exception {
    GeneralBuildingBlock expected = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockInstanceGroupExpected.json"), GeneralBuildingBlock.class);
    ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"), ExecuteBuildingBlock.class);
    RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_instanceGroupAddMembers.json"), RequestDetails.class);
    Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
    String requestAction = "addMembers";
    String instanceGroupId = "instance-group-001";
    WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
    workflowResourceIds.setInstanceGroupId(instanceGroupId);
    executeBB.setWorkflowResourceIds(workflowResourceIds);
    lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, instanceGroupId);
    org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = new org.onap.aai.domain.yang.InstanceGroup();
    aaiInstanceGroup.setId(instanceGroupId);
    aaiInstanceGroup.setInstanceGroupName("test instance group 1");
    org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
    aaiServiceInstance.setServiceInstanceId("service-instance-001");
    aaiServiceInstance.setServiceInstanceName("test service instance 1");
    Optional<org.onap.aai.domain.yang.ServiceInstance> optSI = Optional.of(aaiServiceInstance);
    org.onap.aai.domain.yang.GenericVnf vnf1 = new org.onap.aai.domain.yang.GenericVnf();
    vnf1.setVnfId("vnf-001");
    vnf1.setVnfName("test vnf 1");
    org.onap.aai.domain.yang.GenericVnf vnf2 = new org.onap.aai.domain.yang.GenericVnf();
    vnf2.setVnfId("vnf-002");
    vnf2.setVnfName("test vnf 2");
    doReturn(aaiInstanceGroup).when(SPY_bbInputSetupUtils).getAAIInstanceGroup(instanceGroupId);
    doReturn(optSI).when(SPY_bbInputSetupUtils).getRelatedServiceInstanceFromInstanceGroup(instanceGroupId);
    doReturn(vnf1).when(SPY_bbInputSetupUtils).getAAIGenericVnf("vnf-001");
    doReturn(vnf2).when(SPY_bbInputSetupUtils).getAAIGenericVnf("vnf-002");
    GeneralBuildingBlock actual = SPY_bbInputSetup.getGBBCM(executeBB, requestDetails, lookupKeyMap, requestAction, instanceGroupId);
    assertThat(actual, sameBeanAs(expected));
}
Also used : GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) 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) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) File(java.io.File) Test(org.junit.Test)

Example 13 with RequestDetails

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

the class BBInputSetupTest method testgetGBBMacroNoUserParamsOtherException.

@Test(expected = IllegalArgumentException.class)
public void testgetGBBMacroNoUserParamsOtherException() throws Exception {
    GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"), GeneralBuildingBlock.class);
    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);
    org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
    aaiVnf.setModelCustomizationId("modelCustId");
    Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
    lookupKeyMap.put(ResourceKey.NETWORK_ID, "networkId");
    lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
    lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId");
    lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
    lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "serviceInstanceId");
    String resourceId = "123";
    String vnfType = "vnfType";
    Service service = Mockito.mock(Service.class);
    String requestAction = "assignInstance";
    doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap, requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
    doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
    String generatedId = "12131";
    SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
}
Also used : GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) HashMap(java.util.HashMap) Service(org.onap.so.db.catalog.beans.Service) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) File(java.io.File) Test(org.junit.Test)

Example 14 with RequestDetails

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

the class BBInputSetupTest method testGetGBBMacroExistingServiceUpgrade.

@Test
public void testGetGBBMacroExistingServiceUpgrade() throws Exception {
    String requestAction = "upgradeInstance";
    GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"), GeneralBuildingBlock.class);
    ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"), ExecuteBuildingBlock.class);
    RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceUpgrade.json"), RequestDetails.class);
    Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
    executeBB.setRequestDetails(requestDetails);
    doReturn(new Service()).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(requestDetails.getModelInfo().getModelVersionId());
    doReturn(new org.onap.aai.domain.yang.ServiceInstance()).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById(lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
    doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(any(BBInputSetupParameter.class));
    SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap, executeBB.getBuildingBlock().getBpmnFlowName(), requestAction, null);
    verify(SPY_bbInputSetupUtils, times(1)).getCatalogServiceByModelUUID(requestDetails.getModelInfo().getModelVersionId());
}
Also used : GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) Service(org.onap.so.db.catalog.beans.Service) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) File(java.io.File) Test(org.junit.Test)

Example 15 with RequestDetails

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

the class BBInputSetupTest method testPopulateVolumeGroup.

@Test
public void testPopulateVolumeGroup() throws Exception {
    RequestDetails requestDetails = new RequestDetails();
    RelatedInstanceList ril = new RelatedInstanceList();
    RelatedInstance ri = new RelatedInstance();
    ModelInfo mi = new ModelInfo();
    mi.setModelType(ModelType.vnf);
    mi.setModelCustomizationUuid("vnfModelCustomizationUUID");
    mi.setModelCustomizationId("vnfModelCustomizationUUID");
    ri.setModelInfo(mi);
    ril.setRelatedInstance(ri);
    requestDetails.setRelatedInstanceList(new RelatedInstanceList[] { ril });
    ModelInfo modelInfo = new ModelInfo();
    modelInfo.setModelCustomizationId("volumeGroupCustId");
    RequestInfo reqInfo = new RequestInfo();
    reqInfo.setInstanceName("volumeGroupName");
    requestDetails.setModelInfo(modelInfo);
    requestDetails.setRequestInfo(reqInfo);
    ServiceInstance serviceInstance = new ServiceInstance();
    GenericVnf vnf = new GenericVnf();
    vnf.setVnfId("genericVnfId");
    VolumeGroup vg = new VolumeGroup();
    vg.setVolumeGroupName("volumeGroupName");
    vg.setVolumeGroupId("volumeGroupId");
    vg.setModelInfoVfModule(new ModelInfoVfModule());
    vg.getModelInfoVfModule().setModelCustomizationUUID("volumeGroupCustId");
    vnf.getVolumeGroups().add(vg);
    serviceInstance.getVnfs().add(vnf);
    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");
    ServiceModel serviceModel = new ServiceModel();
    serviceModel.setCurrentService(service);
    String bbName = AssignFlows.VOLUME_GROUP.toString();
    String resourceId = "123";
    doNothing().when(SPY_bbInputSetup).mapCatalogVolumeGroup(isA(VolumeGroup.class), eq(modelInfo), eq(service), eq("vnfModelCustomizationUUID"));
    org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = new org.onap.aai.domain.yang.GenericVnf();
    aaiGenericVnf.setModelCustomizationId("vnfModelCustomizationUUID");
    doReturn(aaiGenericVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
    lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
    BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setRequestId(REQUEST_ID).setModelInfo(modelInfo).setService(service).setBbName(bbName).setServiceInstance(serviceInstance).setLookupKeyMap(lookupKeyMap).setResourceId(resourceId).setRequestDetails(requestDetails).setInstanceName(reqInfo.getInstanceName()).setServiceModel(serviceModel).build();
    SPY_bbInputSetup.populateVolumeGroup(parameter);
    verify(SPY_bbInputSetup, times(1)).mapCatalogVolumeGroup(eq(vg), isA(ModelInfo.class), eq(service), eq("vnfModelCustomizationUUID"));
    vnf.getVolumeGroups().clear();
    SPY_bbInputSetup.populateVolumeGroup(parameter);
    verify(SPY_bbInputSetup, times(1)).mapCatalogVolumeGroup(vnf.getVolumeGroups().get(0), modelInfo, service, "vnfModelCustomizationUUID");
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) 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) RequestInfo(org.onap.so.serviceinstancebeans.RequestInfo) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) ServiceModel(org.onap.so.bpmn.servicedecomposition.entities.ServiceModel) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) 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