use of org.onap.so.serviceinstancebeans.Service in project so by onap.
the class UserParamsValidationTest method setupValidationInformation.
public ValidationInformation setupValidationInformation(String path) throws IOException {
String jsonInput = new String(Files.readAllBytes(Paths.get(path)));
ObjectMapper mapper = new ObjectMapper();
ServiceInstancesRequest sir = mapper.readValue(jsonInput, ServiceInstancesRequest.class);
ValidationInformation info = new ValidationInformation(sir, null, Action.createInstance, 7, false, sir.getRequestDetails().getRequestParameters());
for (Map<String, Object> params : sir.getRequestDetails().getRequestParameters().getUserParams()) {
ObjectMapper obj = new ObjectMapper();
String input = obj.writeValueAsString(params.get("service"));
Service validate = obj.readValue(input, Service.class);
info.setUserParams(validate);
break;
}
info.setRequestInfo(sir.getRequestDetails().getRequestInfo());
return info;
}
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());
}
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());
}
Aggregations