Search in sources :

Example 16 with Service

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;
}
Also used : Service(org.onap.so.serviceinstancebeans.Service) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest)

Example 17 with Service

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());
}
Also used : Service(org.onap.so.serviceinstancebeans.Service) JsonObject(com.google.gson.JsonObject) Resources(org.onap.so.serviceinstancebeans.Resources) Test(org.junit.Test)

Example 18 with Service

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());
}
Also used : Service(org.onap.so.serviceinstancebeans.Service) JsonObject(com.google.gson.JsonObject) Resources(org.onap.so.serviceinstancebeans.Resources) Test(org.junit.Test)

Example 19 with Service

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());
}
Also used : Service(org.onap.so.serviceinstancebeans.Service) JsonObject(com.google.gson.JsonObject) Resources(org.onap.so.serviceinstancebeans.Resources) Test(org.junit.Test)

Aggregations

Service (org.onap.so.serviceinstancebeans.Service)19 Resources (org.onap.so.serviceinstancebeans.Resources)7 JsonObject (com.google.gson.JsonObject)4 Map (java.util.Map)4 Test (org.junit.Test)4 PayloadGenerationException (org.onap.so.client.exception.PayloadGenerationException)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 Networks (org.onap.so.serviceinstancebeans.Networks)3 VfModules (org.onap.so.serviceinstancebeans.VfModules)3 Vnfs (org.onap.so.serviceinstancebeans.Vnfs)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 RequestParameters (org.onap.so.serviceinstancebeans.RequestParameters)2 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Actions (org.onap.so.apihandlerinfra.Actions)1 ApplyUpdatedConfigValidation (org.onap.so.apihandlerinfra.validation.ApplyUpdatedConfigValidation)1 CloudConfigurationValidation (org.onap.so.apihandlerinfra.validation.CloudConfigurationValidation)1 ConfigurationParametersValidation (org.onap.so.apihandlerinfra.validation.ConfigurationParametersValidation)1 CustomWorkflowValidation (org.onap.so.apihandlerinfra.validation.CustomWorkflowValidation)1