Search in sources :

Example 61 with ServiceInstancesRequest

use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest 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 62 with ServiceInstancesRequest

use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.

the class CustomWorkflowValidationTest method testCustomWorkflowValidation.

@Test
public void testCustomWorkflowValidation() throws IOException, ValidationException {
    String requestJson = new String(Files.readAllBytes(Paths.get("src/test/resources/MsoRequestTest/SuccessfulValidation/v1ExecuteCustomWorkflow.json")));
    ObjectMapper mapper = new ObjectMapper();
    ServiceInstancesRequest sir = mapper.readValue(requestJson, ServiceInstancesRequest.class);
    ValidationInformation info = new ValidationInformation(sir, new HashMap<String, String>(), Action.inPlaceSoftwareUpdate, 1, false, sir.getRequestDetails().getRequestParameters());
    info.setRequestScope("vnf");
    CustomWorkflowValidation validation = new CustomWorkflowValidation();
    validation.validate(info);
    assertEquals(info.getSir().getRequestDetails().getCloudConfiguration().getCloudOwner(), "att-aic");
}
Also used : ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) BaseTest(org.onap.so.apihandlerinfra.BaseTest) Test(org.junit.Test)

Example 63 with ServiceInstancesRequest

use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.

the class RequestParametersValidationTest method testVfModuleWithNoALaCarte.

@Test
public void testVfModuleWithNoALaCarte() throws IOException, ValidationException {
    String requestJson = new String(Files.readAllBytes(Paths.get("src/test/resources/MsoRequestTest/RequestParameters/VfModuleRequestParametersNoALaCarte.json")));
    ObjectMapper mapper = new ObjectMapper();
    ServiceInstancesRequest sir = mapper.readValue(requestJson, ServiceInstancesRequest.class);
    ValidationInformation info = new ValidationInformation(sir, new HashMap<String, String>(), Action.createInstance, 6, false, sir.getRequestDetails().getRequestParameters());
    info.setRequestScope("vfModule");
    sir.setServiceInstanceId("0fd90c0c-0e3a-46e2-abb5-4c4820d5985b");
    RequestParametersValidation validation = new RequestParametersValidation();
    validation.validate(info);
    assertTrue(sir.getRequestDetails().getRequestParameters().getUsePreload());
    assertTrue(info.getReqParameters().getUsePreload());
}
Also used : ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) BaseTest(org.onap.so.apihandlerinfra.BaseTest) Test(org.junit.Test)

Example 64 with ServiceInstancesRequest

use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.

the class RequestParametersValidationTest method testVfModuleWithTrueALaCarte.

@Test
public void testVfModuleWithTrueALaCarte() throws IOException, ValidationException {
    String requestJson = new String(Files.readAllBytes(Paths.get("src/test/resources/MsoRequestTest/RequestParameters/VfModuleRequestParametersIsALaCarte.json")));
    ObjectMapper mapper = new ObjectMapper();
    ServiceInstancesRequest sir = mapper.readValue(requestJson, ServiceInstancesRequest.class);
    sir.getRequestDetails().getRequestParameters().setUsePreload(null);
    ValidationInformation info = new ValidationInformation(sir, new HashMap<String, String>(), Action.createInstance, 6, true, sir.getRequestDetails().getRequestParameters());
    info.setRequestScope("vfModule");
    sir.setServiceInstanceId("0fd90c0c-0e3a-46e2-abb5-4c4820d5985b");
    RequestParametersValidation validation = new RequestParametersValidation();
    validation.validate(info);
    assertTrue(sir.getRequestDetails().getRequestParameters().getUsePreload());
    assertTrue(info.getReqParameters().getUsePreload());
}
Also used : ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) BaseTest(org.onap.so.apihandlerinfra.BaseTest) Test(org.junit.Test)

Example 65 with ServiceInstancesRequest

use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.

the class RequestParametersValidationTest method testServiceWithTrueALaCarte.

@Test
public void testServiceWithTrueALaCarte() throws IOException, ValidationException {
    String requestJson = new String(Files.readAllBytes(Paths.get("src/test/resources/MsoRequestTest/RequestParameters/VfModuleRequestParametersIsALaCarte.json")));
    ObjectMapper mapper = new ObjectMapper();
    ServiceInstancesRequest sir = mapper.readValue(requestJson, ServiceInstancesRequest.class);
    sir.getRequestDetails().getRequestParameters().setUsePreload(null);
    ValidationInformation info = new ValidationInformation(sir, new HashMap<String, String>(), Action.createInstance, 6, true, sir.getRequestDetails().getRequestParameters());
    sir.setServiceInstanceId("0fd90c0c-0e3a-46e2-abb5-4c4820d5985b");
    info.setRequestScope("service");
    RequestParametersValidation validation = new RequestParametersValidation();
    validation.validate(info);
    assertTrue(sir.getRequestDetails().getRequestParameters().getUsePreload());
    assertTrue(info.getReqParameters().getUsePreload());
}
Also used : ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) BaseTest(org.onap.so.apihandlerinfra.BaseTest) Test(org.junit.Test)

Aggregations

ServiceInstancesRequest (org.onap.so.serviceinstancebeans.ServiceInstancesRequest)100 Test (org.junit.Test)58 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)36 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)33 InfraActiveRequests (org.onap.so.db.request.beans.InfraActiveRequests)17 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)15 RequestInfo (org.onap.so.serviceinstancebeans.RequestInfo)15 IOException (java.io.IOException)11 BaseTest (org.onap.so.apihandlerinfra.BaseTest)11 CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)11 ValidationException (org.onap.so.exceptions.ValidationException)10 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)8 ValidateException (org.onap.so.apihandlerinfra.exceptions.ValidateException)8 CloudConfigurationNotFoundException (org.onap.so.apihandlerinfra.infra.rest.exception.CloudConfigurationNotFoundException)8 Service (org.onap.so.db.catalog.beans.Service)8 ArrayList (java.util.ArrayList)7 RequestClientParameter (org.onap.so.apihandler.common.RequestClientParameter)7 ApiException (org.onap.so.apihandlerinfra.exceptions.ApiException)7 ServiceInstancesResponse (org.onap.so.serviceinstancebeans.ServiceInstancesResponse)7 GenericVnf (org.onap.aai.domain.yang.GenericVnf)6