use of org.onap.so.db.catalog.beans.ServiceRecipe in project so by onap.
the class ServiceInstancesTest method createServiceInstanceBadResponse.
@Test
public void createServiceInstanceBadResponse() 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/TestBadResponse.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(".*/serviceRecipe/search.*")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
uri = servInstanceuri + "v5/serviceInstances";
ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
assertEquals("Exception caught mapping Camunda JSON response to object", realResponse.getServiceException().getText());
}
use of org.onap.so.db.catalog.beans.ServiceRecipe in project so by onap.
the class ServiceInstancesTest method invalidBPELResponse2.
@Test
public void invalidBPELResponse2() 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/TestResponseInvalid.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(".*/serviceRecipe/search.*")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
uri = servInstanceuri + "v5/serviceInstances";
ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
assertTrue(realResponse.getServiceException().getText().contains("<aetgt:ErrorMessage>Exception in create execution list 500"));
}
use of org.onap.so.db.catalog.beans.ServiceRecipe in project so by onap.
the class ServiceInstancesTest method assignServiceInstance.
@Test
public void assignServiceInstance() 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/assign";
ResponseEntity<String> response = sendRequest(inputStream("/ServiceAssign.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"));
}
use of org.onap.so.db.catalog.beans.ServiceRecipe in project so by onap.
the class ServiceInstancesTest method activateServiceInstanceRequestStatus.
@Test
public void activateServiceInstanceRequestStatus() 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(".*/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" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7999/activate";
ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev8.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"));
}
use of org.onap.so.db.catalog.beans.ServiceRecipe in project so by onap.
the class ServiceInstancesTest method activateServiceInstance.
@Test
public void activateServiceInstance() 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/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-0050569a7968/activate";
ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivate.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"));
}
Aggregations