Search in sources :

Example 1 with ResourceKey

use of org.onap.so.bpmn.servicedecomposition.entities.ResourceKey in project so by onap.

the class SerializationTest method testSerializationOfAllPojos.

@Test
public void testSerializationOfAllPojos() throws IOException {
    GeneralBuildingBlock gbb = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"), GeneralBuildingBlock.class);
    Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
    DelegateExecution execution = new ExecutionImpl();
    execution.setVariable(FLOW_VAR_NAME, "AssignServiceInstanceBB");
    execution.setVariable(GBB_INPUT_VAR_NAME, gbb);
    execution.setVariable(LOOKUP_KEY_MAP_VAR_NAME, lookupKeyMap);
    System.out.println(execution.getVariables());
    BuildingBlockExecution gBuildingBlockExecution = new DelegateExecutionImpl(execution);
    boolean isSerializable = SerializationTest.isSerializable(gBuildingBlockExecution);
    assertEquals(true, isSerializable);
}
Also used : GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) HashMap(java.util.HashMap) ExecutionImpl(org.camunda.bpm.engine.impl.pvm.runtime.ExecutionImpl) DelegateExecutionImpl(org.onap.so.bpmn.common.DelegateExecutionImpl) DelegateExecutionImpl(org.onap.so.bpmn.common.DelegateExecutionImpl) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) File(java.io.File) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) Test(org.junit.Test)

Example 2 with ResourceKey

use of org.onap.so.bpmn.servicedecomposition.entities.ResourceKey in project so by onap.

the class BBInputSetupTest method testGetGBBALaCarteNonServiceWithoutRelatedInstances.

@Test
public void testGetGBBALaCarteNonServiceWithoutRelatedInstances() throws Exception {
    GeneralBuildingBlock expected = 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_withoutRelatedInstanceList.json"), RequestDetails.class);
    Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
    String requestAction = "createInstance";
    Service service = Mockito.mock(Service.class);
    ServiceModel serviceModel = new ServiceModel();
    serviceModel.setCurrentService(service);
    String resourceId = "123";
    ServiceInstance serviceInstance = Mockito.mock(ServiceInstance.class);
    org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
    aaiServiceInstance.setModelVersionId("modelVersionId");
    org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = Mockito.mock(org.onap.aai.domain.yang.CloudRegion.class);
    String vnfType = "vnfType";
    lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "instanceId");
    doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
    doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("instanceId");
    doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(any(BBInputSetupParameter.class));
    doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance);
    doReturn(expected).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(any(BBInputSetupParameter.class));
    GeneralBuildingBlock actual = SPY_bbInputSetup.getGBBALaCarteNonService(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
    assertThat(actual, sameBeanAs(expected));
}
Also used : GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) 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) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ServiceModel(org.onap.so.bpmn.servicedecomposition.entities.ServiceModel) File(java.io.File) Test(org.junit.Test)

Example 3 with ResourceKey

use of org.onap.so.bpmn.servicedecomposition.entities.ResourceKey in project so by onap.

the class BBInputSetupTest method testPopulateObjectsOnAssignAndCreateFlows.

@Test
public void testPopulateObjectsOnAssignAndCreateFlows() throws Exception {
    String bbName = AssignFlows.SERVICE_INSTANCE.toString();
    String instanceName = "instanceName";
    String vnfType = "vnfType";
    String resourceId = "networkId";
    String productFamilyId = "productFamilyId";
    String applicationId = "applicationId";
    Service service = Mockito.mock(Service.class);
    ServiceModel serviceModel = new ServiceModel();
    serviceModel.setCurrentService(service);
    ServiceInstance serviceInstance = Mockito.mock(ServiceInstance.class);
    RequestDetails requestDetails = Mockito.mock(RequestDetails.class);
    ModelInfo modelInfo = Mockito.mock(ModelInfo.class);
    RequestInfo requestInfo = Mockito.mock(RequestInfo.class);
    RelatedInstanceList[] relatedInstanceList = new RelatedInstanceList[] {};
    CloudConfiguration cloudConfiguration = new CloudConfiguration();
    org.onap.so.serviceinstancebeans.Platform platform = Mockito.mock(org.onap.so.serviceinstancebeans.Platform.class);
    org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness = Mockito.mock(org.onap.so.serviceinstancebeans.LineOfBusiness.class);
    Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
    doReturn(modelInfo).when(requestDetails).getModelInfo();
    doReturn(productFamilyId).when(requestInfo).getProductFamilyId();
    doReturn(requestInfo).when(requestDetails).getRequestInfo();
    doReturn(instanceName).when(requestInfo).getInstanceName();
    doReturn(platform).when(requestDetails).getPlatform();
    doReturn(lineOfBusiness).when(requestDetails).getLineOfBusiness();
    doReturn(relatedInstanceList).when(requestDetails).getRelatedInstanceList();
    doReturn(cloudConfiguration).when(requestDetails).getCloudConfiguration();
    doReturn(applicationId).when(requestInfo).getApplicationId();
    doReturn(ModelType.network).when(modelInfo).getModelType();
    BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setRequestId(REQUEST_ID).setRequestDetails(requestDetails).setService(service).setBbName(bbName).setServiceInstance(serviceInstance).setLookupKeyMap(lookupKeyMap).setResourceId(resourceId).setVnfType(vnfType).setIsReplace(false).setApplicationId(applicationId).build();
    doNothing().when(SPY_bbInputSetup).populateL3Network(parameter);
    SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(parameter);
    parameter.setInstanceName(instanceName);
    parameter.setModelInfo(modelInfo);
    verify(SPY_bbInputSetup, times(1)).populateL3Network(parameter);
    assertEquals("NetworkId populated", true, lookupKeyMap.get(ResourceKey.NETWORK_ID).equalsIgnoreCase(resourceId));
    doReturn(ModelType.vnf).when(modelInfo).getModelType();
    resourceId = "vnfId";
    doNothing().when(SPY_bbInputSetup).populateGenericVnf(parameter);
    parameter.setResourceId(resourceId);
    SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(parameter);
    verify(SPY_bbInputSetup, times(1)).populateGenericVnf(parameter);
    assertEquals("VnfId populated", true, lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID).equalsIgnoreCase(resourceId));
    doReturn(ModelType.volumeGroup).when(modelInfo).getModelType();
    resourceId = "volumeGroupId";
    parameter.setResourceId(resourceId);
    doNothing().when(SPY_bbInputSetup).populateVolumeGroup(parameter);
    SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(parameter);
    verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(parameter);
    assertEquals("VolumeGroupId populated", true, lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID).equalsIgnoreCase(resourceId));
    doReturn(ModelType.vfModule).when(modelInfo).getModelType();
    resourceId = "vfModuleId";
    parameter.setResourceId(resourceId);
    doNothing().when(SPY_bbInputSetup).populateVfModule(parameter);
    SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(parameter);
    verify(SPY_bbInputSetup, times(1)).populateVfModule(parameter);
    assertEquals("VfModuleId populated", true, lookupKeyMap.get(ResourceKey.VF_MODULE_ID).equalsIgnoreCase(resourceId));
    String bbNameAssignVolume = AssignFlows.VOLUME_GROUP.toString();
    doReturn(ModelType.vfModule).when(modelInfo).getModelType();
    resourceId = "vfModuleId";
    parameter.setResourceId(resourceId);
    parameter.setBbName(bbNameAssignVolume);
    doNothing().when(SPY_bbInputSetup).populateVolumeGroup(parameter);
    SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(parameter);
    verify(SPY_bbInputSetup, times(2)).populateVolumeGroup(parameter);
    assertEquals(resourceId, lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID));
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) 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) ServiceModel(org.onap.so.bpmn.servicedecomposition.entities.ServiceModel) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) Test(org.junit.Test)

Example 4 with ResourceKey

use of org.onap.so.bpmn.servicedecomposition.entities.ResourceKey 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 5 with ResourceKey

use of org.onap.so.bpmn.servicedecomposition.entities.ResourceKey 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)

Aggregations

ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)72 Test (org.junit.Test)66 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)51 File (java.io.File)50 HashMap (java.util.HashMap)48 Service (org.onap.so.db.catalog.beans.Service)45 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)41 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)41 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)41 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)39 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)25 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)23 BuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock)22 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)22 ConfigurationResourceKeys (org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys)19 CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)19 BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys (org.onap.so.bpmn.servicedecomposition.tasks.BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys)18 ServiceModel (org.onap.so.bpmn.servicedecomposition.entities.ServiceModel)13 Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)11 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)11