use of org.onap.so.serviceinstancebeans.ServiceInstancesResponse in project so by onap.
the class ServiceInstancesTest method creatServiceInstanceGRTestApiNoCustomRecipeFound.
@Test
public void creatServiceInstanceGRTestApiNoCustomRecipeFound() 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)));
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(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(".*/serviceRecipe/search.*")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
uri = servInstanceuri + "v7" + "/serviceInstances";
ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceMacro.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"));
}
use of org.onap.so.serviceinstancebeans.ServiceInstancesResponse in project so by onap.
the class Vnf method deleteVnfInstance.
@DELETE
@ResponseUpdater
@Path("/{version:[vV][8]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Operation(description = "Delete a Vnf instance", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ServiceInstancesResponse.class)))))
@Transactional
public Response deleteVnfInstance(@PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws AAIEntityNotFound, JsonProcessingException, WorkflowEngineConnectionException, ValidateException {
String requestId = vnfRestHandler.getRequestId(requestContext);
String requestorId = MDC.get(HttpHeadersConstants.REQUESTOR_ID);
String source = MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME);
String requestURL = requestContext.getUriInfo().getAbsolutePath().toString();
InfraActiveRequests currentRequest = vnfRestHandler.createInfraActiveRequestForDelete(requestId, serviceInstanceId, vnfInstanceId, requestorId, source, requestURL);
ServiceInstancesRequest request = requestBuilder.buildVnfDeleteRequest(vnfInstanceId);
vnfRestHandler.saveInstanceName(request, currentRequest);
vnfRestHandler.checkDuplicateRequest(serviceInstanceId, vnfInstanceId, request.getRequestDetails().getRequestInfo().getInstanceName(), currentRequest.getRequestId());
Recipe recipe = vnfRestHandler.findVnfModuleRecipe(request.getRequestDetails().getModelInfo().getModelCustomizationId(), "vnf", "deleteInstance");
vnfRestHandler.callWorkflowEngine(vnfRestHandler.buildRequestParams(request, vnfRestHandler.getRequestUri(requestContext), requestId, serviceInstanceId, vnfInstanceId), recipe.getOrchestrationUri());
ServiceInstancesResponse response = vnfRestHandler.createResponse(vnfInstanceId, requestId, requestContext);
return Response.status(HttpStatus.ACCEPTED.value()).entity(response).build();
}
use of org.onap.so.serviceinstancebeans.ServiceInstancesResponse in project so by onap.
the class AbstractRestHandler method createResponse.
/**
* @param instanceId
* @param requestId
* @param requestContext
*/
public ServiceInstancesResponse createResponse(String instanceId, String requestId, ContainerRequestContext requestContext) {
ServiceInstancesResponse response = new ServiceInstancesResponse();
RequestReferences requestReferences = new RequestReferences();
requestReferences.setInstanceId(instanceId);
requestReferences.setRequestId(requestId);
Optional<URL> optionalUrl = buildSelfLinkUrl(getRequestUri(requestContext), requestId);
if (optionalUrl.isPresent()) {
requestReferences.setRequestSelfLink(optionalUrl.get());
}
response.setRequestReferences(requestReferences);
return response;
}
use of org.onap.so.serviceinstancebeans.ServiceInstancesResponse in project so by onap.
the class ServiceInstancesTest method deleteInstanceGroup.
@Test
public void deleteInstanceGroup() 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";
ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, 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"));
}
use of org.onap.so.serviceinstancebeans.ServiceInstancesResponse in project so by onap.
the class ServiceInstancesTest method deleteVolumeGroupInstance.
@Test
public void deleteVolumeGroupInstance() 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(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=b4ea86b4-253f-11e7-93ae-92361f002671")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_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("vfModuleVolGroup_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
wireMockServer.stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=deleteInstance")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVolGrp_GRAPI_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/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
ResponseEntity<String> response = sendRequest(inputStream("/DeleteVolumeGroup.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"));
}
Aggregations