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