Search in sources :

Example 61 with RequestReferences

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

the class ServiceInstancesTest method scaleOutVfModule.

@Test
public void scaleOutVfModule() throws IOException {
    wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
    wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=cb82ffd8-252a-11e7-93ae-92361f002671")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
    wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(getWiremockResponseForCatalogdb("vfModule_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
    wireMockServer.stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(getWiremockResponseForCatalogdb("vfModule_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
    wireMockServer.stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=scaleOut")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVfModuleScaleOut_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
    wireMockServer.stubFor(get(urlMatching(".*/vfModule/search/findByModelInvariantUUIDOrderByModelVersionDesc[?]modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(getWiremockResponseForCatalogdb("vfModulesListByInvariantId_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
    // expected response
    ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
    RequestReferences requestReferences = new RequestReferences();
    requestReferences.setInstanceId("1882939");
    requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
    expectedResponse.setRequestReferences(requestReferences);
    uri = servInstanceuri + "v7" + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules/scaleOut";
    ResponseEntity<String> response = sendRequest(inputStream("/ScaleOutRequest.json"), uri, HttpMethod.POST, headers);
    assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
    ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
    assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
    assertTrue(response.getBody().contains("1882939"));
}
Also used : ServiceInstancesResponse(org.onap.so.serviceinstancebeans.ServiceInstancesResponse) RequestReferences(org.onap.so.serviceinstancebeans.RequestReferences) Test(org.junit.Test)

Example 62 with RequestReferences

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

the class ServiceInstancesTest method createPortConfiguration.

@Test
public void createPortConfiguration() throws IOException {
    wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
    // expected response
    ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
    RequestReferences requestReferences = new RequestReferences();
    requestReferences.setInstanceId("1882939");
    requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
    expectedResponse.setRequestReferences(requestReferences);
    uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
    ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
    assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
    ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
    assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
    assertTrue(response.getBody().contains("1882939"));
}
Also used : ServiceInstancesResponse(org.onap.so.serviceinstancebeans.ServiceInstancesResponse) RequestReferences(org.onap.so.serviceinstancebeans.RequestReferences) Test(org.junit.Test)

Example 63 with RequestReferences

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

the class ServiceInstancesTest method createVnfInstance.

@Test
public void createVnfInstance() throws IOException {
    wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
    wireMockServer.stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(getWiremockResponseForCatalogdb("serviceVnf_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
    wireMockServer.stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672/vnfCustomizations")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationsList_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
    wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672/vnfResources")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(getWiremockResponseForCatalogdb("vnfResourcesCreateVnf_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
    wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(getWiremockResponseForCatalogdb("vnfRecipeCreateInstance_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
    // expected response
    ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
    RequestReferences requestReferences = new RequestReferences();
    requestReferences.setInstanceId("1882939");
    requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
    expectedResponse.setRequestReferences(requestReferences);
    uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
    ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstance.json"), uri, HttpMethod.POST, headers);
    assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
    ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
    assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
    assertTrue(response.getBody().contains("1882939"));
}
Also used : ServiceInstancesResponse(org.onap.so.serviceinstancebeans.ServiceInstancesResponse) RequestReferences(org.onap.so.serviceinstancebeans.RequestReferences) Test(org.junit.Test)

Example 64 with RequestReferences

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

the class ServiceInstancesTest method deletePortConfiguration.

@Test
public void deletePortConfiguration() throws IOException {
    wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
    // expected response
    ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
    RequestReferences requestReferences = new RequestReferences();
    requestReferences.setInstanceId("1882939");
    requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
    expectedResponse.setRequestReferences(requestReferences);
    uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970";
    ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstance.json"), uri, HttpMethod.DELETE, headers);
    assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
    ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
    assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
}
Also used : ServiceInstancesResponse(org.onap.so.serviceinstancebeans.ServiceInstancesResponse) RequestReferences(org.onap.so.serviceinstancebeans.RequestReferences) Test(org.junit.Test)

Example 65 with RequestReferences

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

the class ServiceInstancesTest method createServiceInstanceServiceInstancesUri.

@Test
public void createServiceInstanceServiceInstancesUri() throws IOException {
    ServiceRecipe serviceRecipe = new ServiceRecipe();
    serviceRecipe.setOrchestrationUri("/mso/async/services/CreateGenericALaCarteServiceInstance");
    serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
    serviceRecipe.setAction(Action.createInstance.toString());
    serviceRecipe.setId(1);
    serviceRecipe.setRecipeTimeout(180);
    Service defaultService = new Service();
    defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
    wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateGenericALaCarteServiceInstance")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
    wireMockServer.stubFor(get(urlMatching(".*/service/search/.*")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
    wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
    // expect
    ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
    RequestReferences requestReferences = new RequestReferences();
    requestReferences.setInstanceId("1882939");
    requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
    expectedResponse.setRequestReferences(requestReferences);
    uri = servInstanceuri + "v5";
    ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev7.json"), uri, HttpMethod.POST, headers);
    // then
    assertEquals(404, response.getStatusCode().value());
    ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
}
Also used : Service(org.onap.so.db.catalog.beans.Service) ServiceRecipe(org.onap.so.db.catalog.beans.ServiceRecipe) ServiceInstancesResponse(org.onap.so.serviceinstancebeans.ServiceInstancesResponse) RequestReferences(org.onap.so.serviceinstancebeans.RequestReferences) Test(org.junit.Test)

Aggregations

RequestReferences (org.onap.so.serviceinstancebeans.RequestReferences)65 ServiceInstancesResponse (org.onap.so.serviceinstancebeans.ServiceInstancesResponse)65 Test (org.junit.Test)60 Service (org.onap.so.db.catalog.beans.Service)10 ServiceRecipe (org.onap.so.db.catalog.beans.ServiceRecipe)10 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 IOException (java.io.IOException)3 RequestClientParameter (org.onap.so.apihandler.common.RequestClientParameter)3 ApiException (org.onap.so.apihandlerinfra.exceptions.ApiException)3 RequestDbFailureException (org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException)3 ValidateException (org.onap.so.apihandlerinfra.exceptions.ValidateException)3 BpmnRequestBuilder (org.onap.so.apihandlerinfra.infra.rest.BpmnRequestBuilder)3 CloudConfigurationNotFoundException (org.onap.so.apihandlerinfra.infra.rest.exception.CloudConfigurationNotFoundException)3 ErrorLoggerInfo (org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo)3 InfraActiveRequests (org.onap.so.db.request.beans.InfraActiveRequests)3 ValidationException (org.onap.so.exceptions.ValidationException)3 ServiceInstancesRequest (org.onap.so.serviceinstancebeans.ServiceInstancesRequest)3 URL (java.net.URL)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 WorkflowCallbackResponse (org.onap.so.bpmn.common.workflow.context.WorkflowCallbackResponse)1