Search in sources :

Example 1 with Vnfc

use of org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc 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 2 with Vnfc

use of org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc in project so by onap.

the class BBInputSetupTest method testPopulateFabricConfiguration.

@Test
public void testPopulateFabricConfiguration() 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");
    configuration.setConfigurationSubType("Fabric Config");
    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);
    Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
    lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId");
    String bbName = AssignFlows.FABRIC_CONFIGURATION.toString();
    ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
    configResourceKeys.setVnfcName(vnfcName);
    Vnfc vnfc = new Vnfc();
    vnfc.setVnfcName(vnfcName);
    RequestDetails requestDetails = new RequestDetails();
    ServiceModel serviceModel = new ServiceModel();
    serviceModel.setCurrentService(service);
    CvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = new CvnfcConfigurationCustomization();
    ConfigurationResource configurationResource = new ConfigurationResource();
    configurationResource.setModelUUID("modelUUID");
    configurationResource.setModelInvariantUUID("modelInvariantUUID");
    vnfVfmoduleCvnfcConfigurationCustomization.setConfigurationResource(configurationResource);
    doReturn(null).when(SPY_bbInputSetup).findConfigurationResourceCustomization(modelInfo, service);
    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).build();
    SPY_bbInputSetup.populateConfiguration(parameter);
    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) AAIFluentTypeBuilder(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) Service(org.onap.so.db.catalog.beans.Service) ConfigurationResource(org.onap.so.db.catalog.beans.ConfigurationResource) 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) CvnfcConfigurationCustomization(org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization) File(java.io.File) Vnfc(org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc) Test(org.junit.Test)

Example 3 with Vnfc

use of org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc in project so by onap.

the class BBInputSetup method populateConfiguration.

protected void populateConfiguration(BBInputSetupParameter parameter) {
    Configuration configuration = null;
    String replaceVnfModelCustomizationUUID = "";
    if (parameter.getRelatedInstanceList() != null) {
        for (RelatedInstanceList relatedInstList : parameter.getRelatedInstanceList()) {
            RelatedInstance relatedInstance = relatedInstList.getRelatedInstance();
            if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf)) {
                if (parameter.getIsReplace()) {
                    replaceVnfModelCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationId();
                }
            }
        }
    }
    for (Configuration configurationTemp : parameter.getServiceInstance().getConfigurations()) {
        if (parameter.getLookupKeyMap().get(ResourceKey.CONFIGURATION_ID) != null && configurationTemp.getConfigurationId().equalsIgnoreCase(parameter.getLookupKeyMap().get(ResourceKey.CONFIGURATION_ID))) {
            configuration = configurationTemp;
            org.onap.aai.domain.yang.Configuration aaiConfiguration = bbInputSetupUtils.getAAIConfiguration(configuration.getConfigurationId());
            if (aaiConfiguration != null) {
                parameter.getModelInfo().setModelCustomizationUuid(aaiConfiguration.getModelCustomizationId());
            }
        }
    }
    if (configuration == null && (parameter.getBbName().equalsIgnoreCase(AssignFlows.FABRIC_CONFIGURATION.toString()) || parameter.getBbName().equalsIgnoreCase(AssignFlows.VRF_CONFIGURATION.toString()))) {
        configuration = this.createConfiguration(parameter.getLookupKeyMap(), parameter.getInstanceName(), parameter.getResourceId());
        parameter.getServiceInstance().getConfigurations().add(configuration);
    }
    if (configuration != null && parameter.getBbName().contains("Fabric")) {
        Vnfc vnfc = getVnfcToConfiguration(parameter.getConfigurationResourceKeys().getVnfcName());
        configuration.setVnfc(vnfc);
        if (!parameter.getBbName().contains("Delete")) {
            if (parameter.getIsReplace()) {
                parameter.getConfigurationResourceKeys().setVnfResourceCustomizationUUID(replaceVnfModelCustomizationUUID);
                mapCatalogConfiguration(configuration, parameter.getModelInfo(), parameter.getServiceModel().getNewService(), parameter.getConfigurationResourceKeys());
            } else {
                mapCatalogConfiguration(configuration, parameter.getModelInfo(), parameter.getServiceModel().getCurrentService(), parameter.getConfigurationResourceKeys());
            }
        }
    } else if (configuration != null && parameter.getBbName().contains("Vrf")) {
        configuration.setModelInfoConfiguration(mapperLayer.mapCatalogConfigurationToConfiguration(findConfigurationResourceCustomization(parameter.getModelInfo(), parameter.getService()), null));
        configuration.setConfigurationType(configuration.getModelInfoConfiguration().getConfigurationType());
        configuration.setConfigurationSubType(configuration.getModelInfoConfiguration().getConfigurationRole());
    }
}
Also used : CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) Vnfc(org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc)

Example 4 with Vnfc

use of org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc in project so by onap.

the class BBInputSetup method getVnfcToConfiguration.

protected Vnfc getVnfcToConfiguration(String vnfcName) {
    AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().vnfc(vnfcName));
    Optional<org.onap.aai.domain.yang.Vnfc> vnfcOp = bbInputSetupUtils.getAAIResourceDepthOne(uri).asBean(org.onap.aai.domain.yang.Vnfc.class);
    if (vnfcOp.isPresent()) {
        org.onap.aai.domain.yang.Vnfc vnfcAAI = vnfcOp.get();
        return this.mapperLayer.mapAAIVnfc(vnfcAAI);
    } else {
        return null;
    }
}
Also used : AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) Vnfc(org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc)

Example 5 with Vnfc

use of org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc in project so by onap.

the class BBInputSetupTest method testPopulateConfiguration.

@Test
public void testPopulateConfiguration() 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.setCurrentService(service);
    ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
    configResourceKeys.setVnfcName(vnfcName);
    Vnfc vnfc = new Vnfc();
    vnfc.setVnfcName(vnfcName);
    RequestDetails requestDetails = new RequestDetails();
    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).build();
    SPY_bbInputSetup.populateConfiguration(parameter);
    verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys);
    lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, null);
    SPY_bbInputSetup.populateConfiguration(parameter);
    verify(SPY_bbInputSetup, times(2)).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys);
    instanceName = "configurationName2";
    resourceId = "resourceId2";
    lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId2");
    parameter.setInstanceName(instanceName);
    parameter.setResourceId(resourceId);
    Configuration configuration2 = SPY_bbInputSetup.createConfiguration(lookupKeyMap, instanceName, resourceId);
    doReturn(configuration2).when(SPY_bbInputSetup).createConfiguration(lookupKeyMap, instanceName, resourceId);
    doNothing().when(SPY_bbInputSetup).mapCatalogConfiguration(configuration2, modelInfo, service, configResourceKeys);
    SPY_bbInputSetup.populateConfiguration(parameter);
    verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(configuration2, 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) AAIFluentTypeBuilder(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder) 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)

Aggregations

Vnfc (org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc)6 Configuration (org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration)5 CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)5 Test (org.junit.Test)4 File (java.io.File)3 HashMap (java.util.HashMap)3 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)3 ConfigurationResourceKeys (org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys)3 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)3 ServiceModel (org.onap.so.bpmn.servicedecomposition.entities.ServiceModel)3 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)3 BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys (org.onap.so.bpmn.servicedecomposition.tasks.BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys)3 Service (org.onap.so.db.catalog.beans.Service)3 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)3 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)3 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)2 AAIFluentTypeBuilder (org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder)2 ConfigurationResourceCustomization (org.onap.so.db.catalog.beans.ConfigurationResourceCustomization)2 AAICommonObjectMapperProvider (org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider)1 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)1