Search in sources :

Example 6 with ServiceInstancesRequest

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

the class RequestHandlerUtilsTest method getServiceInstanceIdForValidationErrorInstanceGroupTest.

@Test
public void getServiceInstanceIdForValidationErrorInstanceGroupTest() throws Exception {
    ServiceInstancesRequest sir = mapper.readValue(inputStream("/CreateInstanceGroup.json"), ServiceInstancesRequest.class);
    String requestScope = "instanceGroup";
    String serviceInstanceId = requestHandlerUtils.getServiceInstanceIdForValidationError(sir, null, requestScope).get();
    assertEquals("ddcbbf3d-f2c1-4ca0-8852-76a807285efc", serviceInstanceId);
}
Also used : ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) Test(org.junit.Test)

Example 7 with ServiceInstancesRequest

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

the class RequestHandlerUtilsTest method setServiceTypeTestDefault.

@Test
public void setServiceTypeTestDefault() throws JsonProcessingException {
    String requestScope = ModelType.service.toString();
    Boolean aLaCarteFlag = false;
    ServiceInstancesRequest sir = new ServiceInstancesRequest();
    RequestDetails requestDetails = new RequestDetails();
    RequestInfo requestInfo = new RequestInfo();
    ModelInfo modelInfo = new ModelInfo();
    modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
    requestInfo.setSource("VID");
    requestDetails.setModelInfo(modelInfo);
    requestDetails.setRequestInfo(requestInfo);
    sir.setRequestDetails(requestDetails);
    Service defaultService = new Service();
    defaultService.setServiceType("testServiceType");
    wireMockServer.stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_NOT_FOUND)));
    wireMockServer.stubFor(get(urlMatching(".*/service/search/.*")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
    String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
    assertEquals(serviceType, "testServiceType");
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) Service(org.onap.so.db.catalog.beans.Service) RequestInfo(org.onap.so.serviceinstancebeans.RequestInfo) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) Test(org.junit.Test)

Example 8 with ServiceInstancesRequest

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

the class RequestHandlerUtilsTest method setServiceTypeTest.

@Test
public void setServiceTypeTest() throws JsonProcessingException {
    String requestScope = ModelType.service.toString();
    Boolean aLaCarteFlag = false;
    ServiceInstancesRequest sir = new ServiceInstancesRequest();
    RequestDetails requestDetails = new RequestDetails();
    RequestInfo requestInfo = new RequestInfo();
    ModelInfo modelInfo = new ModelInfo();
    modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
    requestInfo.setSource("VID");
    requestDetails.setModelInfo(modelInfo);
    requestDetails.setRequestInfo(requestInfo);
    sir.setRequestDetails(requestDetails);
    Service defaultService = new Service();
    defaultService.setServiceType("testServiceType");
    wireMockServer.stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
    String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
    assertEquals(serviceType, "testServiceType");
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) Service(org.onap.so.db.catalog.beans.Service) RequestInfo(org.onap.so.serviceinstancebeans.RequestInfo) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) Test(org.junit.Test)

Example 9 with ServiceInstancesRequest

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

the class ServiceInstancesTest method handleReplaceInstance_Test.

@Test
public void handleReplaceInstance_Test() throws JsonParseException, JsonMappingException, IOException {
    String replaceVfModule = inputStream("/ReplaceVfModule.json");
    ObjectMapper mapper = new ObjectMapper();
    ServiceInstancesRequest sir = mapper.readValue(replaceVfModule, ServiceInstancesRequest.class);
    Actions action = servInstances.handleReplaceInstance(Action.replaceInstance, sir);
    assertEquals(Action.replaceInstance, action);
}
Also used : ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) Test(org.junit.Test)

Example 10 with ServiceInstancesRequest

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

the class ServiceInstancesTest method setServiceTypeTestALaCarte.

@Test
public void setServiceTypeTestALaCarte() throws JsonProcessingException {
    String requestScope = ModelType.service.toString();
    Boolean aLaCarteFlag = true;
    ServiceInstancesRequest sir = new ServiceInstancesRequest();
    RequestDetails requestDetails = new RequestDetails();
    RequestInfo requestInfo = new RequestInfo();
    requestInfo.setSource("VID");
    requestDetails.setRequestInfo(requestInfo);
    sir.setRequestDetails(requestDetails);
    Service defaultService = new Service();
    defaultService.setServiceType("testServiceTypeALaCarte");
    wireMockServer.stubFor(get(urlMatching(".*/service/search/.*")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
    String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
    assertEquals(serviceType, "testServiceTypeALaCarte");
}
Also used : Service(org.onap.so.db.catalog.beans.Service) RequestInfo(org.onap.so.serviceinstancebeans.RequestInfo) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) 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