Search in sources :

Example 6 with ServiceInstancesResponse

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

the class ServiceInstancesTest method updateNetworkInstance.

@Test
public void updateNetworkInstance() 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(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json")).withStatus(HttpStatus.SC_OK)));
    wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(getWiremockResponseForCatalogdb("networkResource_Response.json")).withStatus(HttpStatus.SC_OK)));
    wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" + "modelName=GR-API-DEFAULT&action=updateInstance")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(getWiremockResponseForCatalogdb("networkRecipe_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/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
    ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT, 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 7 with ServiceInstancesResponse

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

the class ServiceInstancesTest method activatePort.

@Test
public void activatePort() 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/activate";
    ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivatePort.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"));
}
Also used : ServiceInstancesResponse(org.onap.so.serviceinstancebeans.ServiceInstancesResponse) RequestReferences(org.onap.so.serviceinstancebeans.RequestReferences) Test(org.junit.Test)

Example 8 with ServiceInstancesResponse

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

the class ServiceInstancesTest method replaceVnfInstance.

@Test
public void replaceVnfInstance() 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(".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002671")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_ReplaceVnf_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
    wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/1/vnfResources")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
    wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=replaceInstance")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_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/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
    ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnf.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"));
}
Also used : ServiceInstancesResponse(org.onap.so.serviceinstancebeans.ServiceInstancesResponse) RequestReferences(org.onap.so.serviceinstancebeans.RequestReferences) Test(org.junit.Test)

Example 9 with ServiceInstancesResponse

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

the class ServiceInstancesTest method addMembers.

@Test
public void addMembers() 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)));
    // expect
    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/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/addMembers";
    ResponseEntity<String> response = sendRequest(inputStream("/AddMembers.json"), uri, HttpMethod.POST, headers);
    // then
    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 10 with ServiceInstancesResponse

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

the class ServiceInstancesTest method deleteServiceInstance.

@Test
public void deleteServiceInstance() throws IOException {
    ServiceRecipe serviceRecipe = new ServiceRecipe();
    serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
    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/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/.*")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
    wireMockServer.stubFor(get(urlMatching(".*/service-design-and-creation/services/service/.*")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBodyFile("/aai/ServiceFromAAI.json").withStatus(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)));
    // 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-0050569a8868/";
    ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDelete.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 : 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

ServiceInstancesResponse (org.onap.so.serviceinstancebeans.ServiceInstancesResponse)71 RequestReferences (org.onap.so.serviceinstancebeans.RequestReferences)65 Test (org.junit.Test)60 Service (org.onap.so.db.catalog.beans.Service)10 ServiceRecipe (org.onap.so.db.catalog.beans.ServiceRecipe)10 InfraActiveRequests (org.onap.so.db.request.beans.InfraActiveRequests)8 ServiceInstancesRequest (org.onap.so.serviceinstancebeans.ServiceInstancesRequest)8 Operation (io.swagger.v3.oas.annotations.Operation)5 Transactional (javax.transaction.Transactional)5 Consumes (javax.ws.rs.Consumes)5 DELETE (javax.ws.rs.DELETE)5 Path (javax.ws.rs.Path)5 Produces (javax.ws.rs.Produces)5 ResponseUpdater (org.onap.so.apihandler.filters.ResponseUpdater)5 Recipe (org.onap.so.db.catalog.beans.Recipe)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 IOException (java.io.IOException)4 ApiException (org.onap.so.apihandlerinfra.exceptions.ApiException)4 ValidateException (org.onap.so.apihandlerinfra.exceptions.ValidateException)4 URL (java.net.URL)3