use of org.onap.so.serviceinstancebeans.Service in project so by onap.
the class ConfigureInstanceParamsForPnf method populateInstanceParams.
/**
* Read instance parameters for PNF and put into JsonObject.
*
* @param jsonObject - JsonObject which will hold the payload to send to CDS.
* @param userParamsFromRequest - User parameters.
* @param modelCustomizationUuid - Unique ID for Pnf.
* @throws PayloadGenerationException if it doesn't able to populate instance parameters from SO payload.
*/
public void populateInstanceParams(JsonObject jsonObject, List<Map<String, Object>> userParamsFromRequest, String modelCustomizationUuid) throws PayloadGenerationException {
try {
Optional<Service> service = extractServiceFromUserParameters.getServiceFromRequestUserParams(userParamsFromRequest);
if (service.isPresent()) {
List<Map<String, String>> instanceParamsList = getInstanceParamForPnf(service.get(), modelCustomizationUuid);
applyParamsToObject(instanceParamsList, jsonObject);
}
} catch (Exception exception) {
throw new PayloadGenerationException("Failed to resolve instance parameters", exception);
}
}
use of org.onap.so.serviceinstancebeans.Service in project so by onap.
the class ConfigureInstanceParamsForVfModule method populateInstanceParams.
/**
* Read instance parameters for VF-Module and put into JsonObject.
*
* @param jsonObject- JsonObject which will hold the payload to send to CDS.
* @param userParamsFromRequest - User parameters for a vf-module
* @param vnfCustomizationUuid - Unique ID for vnf.
* @param vfModuleCustomizationUuid - Unique ID for vf-module.
* @throws PayloadGenerationException- If it doesn't able to populate instance parameters from SO payload.
*/
public void populateInstanceParams(JsonObject jsonObject, List<Map<String, Object>> userParamsFromRequest, String vnfCustomizationUuid, String vfModuleCustomizationUuid, String vfModuleInstanceName) throws PayloadGenerationException {
try {
Optional<Service> service = extractServiceFromUserParameters.getServiceFromRequestUserParams(userParamsFromRequest);
if (service.isPresent()) {
List<Map<String, String>> instanceParamsList;
if (StringUtils.isNotBlank(vfModuleInstanceName)) {
instanceParamsList = getInstanceParamsByInstanceNames(service.get(), vfModuleInstanceName);
} else {
instanceParamsList = getInstanceParams(service.get(), vnfCustomizationUuid, vfModuleCustomizationUuid);
}
applyParamsToObject(instanceParamsList, jsonObject);
}
} catch (Exception e) {
throw new PayloadGenerationException("Failed to resolve instance parameters", e);
}
}
use of org.onap.so.serviceinstancebeans.Service in project so by onap.
the class ConfigureInstanceParamsForVfModuleTest method testPopulateInstanceParamsByCustomizationId.
@Test
public void testPopulateInstanceParamsByCustomizationId() throws Exception {
Service service = new Service();
Resources resources = new Resources();
resources.setVnfs(createVnfs());
service.setResources(resources);
when(extractServiceFromUserParameters.getServiceFromRequestUserParams(any())).thenReturn(Optional.of(service));
JsonObject jsonObject = new JsonObject();
// No instance name is passed
configureInstanceParamsForVfModule.populateInstanceParams(jsonObject, new ArrayList<>(), VNF_CUSTOMIZATION_ID, VFMODULE_1_CUSTOMIZATION_ID, null);
assertEquals("xyz", jsonObject.get("param-1").getAsString());
assertEquals("123", jsonObject.get("param-2").getAsString());
assertEquals("CCC", jsonObject.get("param-3").getAsString());
}
use of org.onap.so.serviceinstancebeans.Service in project so by onap.
the class ConfigureInstanceParamsForVnfTest method testPopulateInstanceParamsByCustomizationId.
@Test
public void testPopulateInstanceParamsByCustomizationId() throws Exception {
Service service = new Service();
Resources resources = new Resources();
resources.setVnfs(createVnfs());
service.setResources(resources);
when(extractServiceFromUserParameters.getServiceFromRequestUserParams(any())).thenReturn(Optional.of(service));
JsonObject jsonObject = new JsonObject();
// No instance name is passed
configureInstanceParamsForVnf.populateInstanceParams(jsonObject, new ArrayList<>(), VNF_1_CUSTOMIZATION_ID, null);
assertEquals("xyz", jsonObject.get("param-1").getAsString());
assertEquals("123", jsonObject.get("param-2").getAsString());
assertEquals("CCC", jsonObject.get("param-3").getAsString());
}
use of org.onap.so.serviceinstancebeans.Service in project so by onap.
the class ConfigureInstanceParamsForVnfTest method testPopulateInstanceParamsByInstanceName.
@Test
public void testPopulateInstanceParamsByInstanceName() throws Exception {
Service service = new Service();
Resources resources = new Resources();
resources.setVnfs(createVnfs());
service.setResources(resources);
when(extractServiceFromUserParameters.getServiceFromRequestUserParams(any())).thenReturn(Optional.of(service));
JsonObject jsonObject = new JsonObject();
configureInstanceParamsForVnf.populateInstanceParams(jsonObject, new ArrayList<>(), VNF_2_CUSTOMIZATION_ID, VNF_2_INSTANCE_NAME);
assertEquals("abc", jsonObject.get("param-1").getAsString());
assertEquals("999", jsonObject.get("param-2").getAsString());
assertEquals("AAA", jsonObject.get("param-3").getAsString());
}
Aggregations