Search in sources :

Example 16 with ServiceInstancesResponse

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

the class ServiceInstancesTest method deleteVfModuleNoModelInvariantId.

@Test
public void deleteVfModuleNoModelInvariantId() 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(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" + "[?]vfModuleModelUUID=VNF-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_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/196b4a84-0858-4317-a1f6-497e2e52ae43/vnfs/36e4f902-ec32-451e-8d53-e3edc19e40a4/vfModules/09f3a38d-933f-450a-8784-9e6c4dec3f72";
    ResponseEntity<String> response = sendRequest(inputStream("/DeleteVfModuleNoModelInvariantId.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 17 with ServiceInstancesResponse

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

the class ServiceInstancesTest method deleteNetworkInstanceNoCustomizationEntry.

@Test
public void deleteNetworkInstanceNoCustomizationEntry() 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).withStatus(HttpStatus.SC_NOT_FOUND)));
    wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" + "modelName=VNF-API-DEFAULT&action=deleteInstance")).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("/NetworkInstance.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 18 with ServiceInstancesResponse

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

the class ServiceInstancesTest method deleteVnfInstanceV5.

@Test
public void deleteVnfInstanceV5() 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(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" + "[?]nfRole=GR-API-DEFAULT&action=deleteInstance")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(getWiremockResponseForCatalogdb("vnfRecipeDelete_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("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
    expectedResponse.setRequestReferences(requestReferences);
    uri = servInstanceuri + "v5" + "/serviceInstances/e446b97d-9c35-437a-95a2-6b4c542c4507/vnfs/49befbfe-fccb-421d-bb4c-0734a43f5ea0";
    ResponseEntity<String> response = sendRequest(inputStream("/DeleteVnfV5.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 19 with ServiceInstancesResponse

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

the class ServiceInstancesTest method createNetworkInstanceTestApiIncorrectUsePropertiesDefault.

@Test
public void createNetworkInstanceTestApiIncorrectUsePropertiesDefault() 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)));
    uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
    ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiIncorrect.json"), uri, HttpMethod.POST);
    // expected response
    ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
    RequestReferences requestReferences = new RequestReferences();
    requestReferences.setInstanceId("1882939");
    expectedResponse.setRequestReferences(requestReferences);
    assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
}
Also used : ServiceInstancesResponse(org.onap.so.serviceinstancebeans.ServiceInstancesResponse) RequestReferences(org.onap.so.serviceinstancebeans.RequestReferences) Test(org.junit.Test)

Example 20 with ServiceInstancesResponse

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

the class ServiceInstancesTest method createNetworkInstanceTestApiUndefinedUsePropertiesDefault.

@Test
public void createNetworkInstanceTestApiUndefinedUsePropertiesDefault() 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=createInstance")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
    uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
    ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateAlternateInstanceName.json"), uri, HttpMethod.POST, headers);
    // 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);
    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)

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