Search in sources :

Example 96 with Service

use of org.onap.so.db.catalog.beans.Service in project so by onap.

the class BBInputSetupTest method test_getGBBMacroNoUserParamsExistingService_forActivateVnfBB.

@Test
public void test_getGBBMacroNoUserParamsExistingService_forActivateVnfBB() 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");
    ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
    executeBB.setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails);
    BuildingBlock buildingBlock = executeBB.getBuildingBlock();
    buildingBlock.setBpmnFlowName("ActivateVnfBB").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(aaiVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
    doNothing().when(SPY_bbInputSetup).mapCatalogVnf(any(GenericVnf.class), any(ModelInfo.class), any(Service.class));
    // 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));
}
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) 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 97 with Service

use of org.onap.so.db.catalog.beans.Service in project so by onap.

the class BBInputSetupTest method testGetAlaCarteServiceInstanceException.

@Test(expected = Exception.class)
public void testGetAlaCarteServiceInstanceException() throws Exception {
    ServiceInstance expected = mapper.readValue(new File(RESOURCE_PATH + "ServiceInstance_getServiceInstanceNOAAIExpected.json"), ServiceInstance.class);
    RequestDetails requestDetails = new RequestDetails();
    RequestInfo requestInfo = new RequestInfo();
    requestInfo.setInstanceName("SharansInstanceName");
    requestDetails.setRequestInfo(requestInfo);
    Customer customer = new Customer();
    String serviceInstanceId = "SharansInstanceId";
    boolean aLaCarte = true;
    Service service = new Service();
    service.setModelUUID("modelUUID");
    ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
    modelInfoServiceInstance.setModelUuid("modelUUID");
    expected.setModelInfoServiceInstance(modelInfoServiceInstance);
    org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = new org.onap.aai.domain.yang.ServiceInstance();
    serviceInstanceAAI.setModelVersionId("modelUUIDDifferent");
    Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
    String bbName = AssignFlows.SERVICE_INSTANCE.toString();
    Service differentService = new Service();
    differentService.setModelUUID("modelUUIDDifferent");
    doReturn(expected).when(SPY_bbInputSetup).getServiceInstanceHelper(requestDetails, customer, null, null, lookupKeyMap, serviceInstanceId, aLaCarte, service, bbName);
    doReturn(serviceInstanceAAI).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById(serviceInstanceId);
    doReturn(null).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(serviceInstanceAAI.getModelVersionId());
    ServiceInstance actual = SPY_bbInputSetup.getALaCarteServiceInstance(service, requestDetails, customer, null, null, lookupKeyMap, serviceInstanceId, aLaCarte, bbName);
    assertThat(actual, sameBeanAs(expected));
}
Also used : Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) 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) File(java.io.File) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) Test(org.junit.Test)

Example 98 with Service

use of org.onap.so.db.catalog.beans.Service in project so by onap.

the class BBInputSetupTest method testGetServiceProxy.

@Test
public void testGetServiceProxy() {
    ServiceProxy expected = new ServiceProxy();
    expected.setType("TRANSPORT");
    expected.setModelInfoServiceProxy(new ModelInfoServiceProxy());
    expected.getModelInfoServiceProxy().setModelUuid("modelUUID");
    expected.getModelInfoServiceProxy().setModelInstanceName("modelInstanceName");
    expected.setServiceInstance(new ServiceInstance());
    expected.getServiceInstance().setModelInfoServiceInstance(new ModelInfoServiceInstance());
    expected.getServiceInstance().getModelInfoServiceInstance().setModelUuid("modelUUID");
    expected.getServiceInstance().getModelInfoServiceInstance().setServiceType("TRANSPORT");
    Service service = new Service();
    ServiceProxyResourceCustomization serviceProxyCatalog = new ServiceProxyResourceCustomization();
    serviceProxyCatalog.setModelCustomizationUUID("modelCustomizationUUID");
    serviceProxyCatalog.setModelInstanceName("modelInstanceName");
    Service sourceService = new Service();
    sourceService.setModelUUID("modelUUID");
    sourceService.setServiceType("TRANSPORT");
    serviceProxyCatalog.setSourceService(sourceService);
    service.setServiceProxyCustomizations(new ArrayList<ServiceProxyResourceCustomization>());
    service.getServiceProxyCustomizations().add(serviceProxyCatalog);
    ServiceProxy actual = SPY_bbInputSetup.getServiceProxy(service);
    assertThat(actual, sameBeanAs(expected));
}
Also used : ModelInfoServiceProxy(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceProxy) ServiceProxy(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy) ServiceProxyResourceCustomization(org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) Service(org.onap.so.db.catalog.beans.Service) ModelInfoServiceProxy(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceProxy) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) Test(org.junit.Test)

Example 99 with Service

use of org.onap.so.db.catalog.beans.Service in project so by onap.

the class BBInputSetupTest method testGetServiceInstanceHelperCreateScenarioExistingNoNameButWithId.

@Test
public void testGetServiceInstanceHelperCreateScenarioExistingNoNameButWithId() throws Exception {
    RequestDetails requestDetails = new RequestDetails();
    RequestInfo requestInfo = new RequestInfo();
    requestInfo.setInstanceName("SharansInstanceName");
    requestDetails.setRequestInfo(requestInfo);
    Customer customer = new Customer();
    String serviceInstanceId = "SharansInstanceId";
    boolean aLaCarte = true;
    Service service = new Service();
    service.setModelUUID("modelUUID");
    ServiceInstance expected = new ServiceInstance();
    org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = new org.onap.aai.domain.yang.ServiceInstance();
    serviceInstanceAAI.setModelVersionId("modelUUID");
    Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
    String bbName = "ActivateServiceInstanceBB";
    doReturn(serviceInstanceAAI).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById(serviceInstanceId);
    doReturn(expected).when(SPY_bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
    ServiceInstance actual = SPY_bbInputSetup.getServiceInstanceHelper(requestDetails, customer, null, null, lookupKeyMap, serviceInstanceId, aLaCarte, service, bbName);
    assertThat(actual, sameBeanAs(expected));
}
Also used : Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) HashMap(java.util.HashMap) Service(org.onap.so.db.catalog.beans.Service) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) RequestInfo(org.onap.so.serviceinstancebeans.RequestInfo) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) Test(org.junit.Test)

Example 100 with Service

use of org.onap.so.db.catalog.beans.Service in project so by onap.

the class BBInputSetupTest method testGetServiceInstanceHelperCreateScenarioExistingWithName.

@Test
public void testGetServiceInstanceHelperCreateScenarioExistingWithName() throws Exception {
    RequestDetails requestDetails = new RequestDetails();
    RequestInfo requestInfo = new RequestInfo();
    requestDetails.setRequestInfo(requestInfo);
    ServiceSubscription serviceSub = new ServiceSubscription();
    Customer customer = new Customer();
    customer.setServiceSubscription(serviceSub);
    ServiceInstance expected = new ServiceInstance();
    expected.setServiceInstanceId("serviceInstanceId");
    org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = new org.onap.aai.domain.yang.ServiceInstance();
    serviceInstanceAAI.setServiceInstanceId("serviceInstanceId");
    doReturn(serviceInstanceAAI).when(SPY_bbInputSetupUtils).getAAIServiceInstanceByIdAndCustomer(Mockito.any(), Mockito.any(), Mockito.any());
    ServiceInstance actual = SPY_bbInputSetup.getServiceInstanceHelper(requestDetails, customer, null, null, new HashMap<>(), "SharansInstanceId", false, new Service(), "ActivateServiceInstanceBB");
    assertThat(actual, sameBeanAs(expected));
}
Also used : Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) 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) ServiceSubscription(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription) Test(org.junit.Test)

Aggregations

Service (org.onap.so.db.catalog.beans.Service)171 Test (org.junit.Test)135 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)57 File (java.io.File)48 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)47 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)46 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)40 ArrayList (java.util.ArrayList)39 HashMap (java.util.HashMap)37 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)37 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)36 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)29 ServiceRecipe (org.onap.so.db.catalog.beans.ServiceRecipe)24 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)22 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)19 BuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock)18 ConfigurationResourceKeys (org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys)18 NetworkResourceCustomization (org.onap.so.db.catalog.beans.NetworkResourceCustomization)18 VnfResourceCustomization (org.onap.so.db.catalog.beans.VnfResourceCustomization)18 CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)18