summaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src/test
diff options
context:
space:
mode:
authorrameshiyer27 <ramesh.murugan.iyer@est.tech>2020-06-24 13:51:28 +0100
committerrameshiyer27 <ramesh.murugan.iyer@est.tech>2020-07-08 15:35:41 +0100
commit76e89e2d541404b074f28865fd8ca1f426f9ce07 (patch)
tree2fa0f52fb3b257ea1117faf113ce7953f518929b /mso-api-handlers/mso-api-handler-infra/src/test
parentcf5b7493eb7dffdeb211af056ce8459ede89292a (diff)
Service level workflow retrieving API
This commit implements the below API in SO. Get /workflowSpecifications/v1/workflows?resourceTarget={service} It adds functionality to query the workflows using resourceTarget as query param - Modified existing workflow API to accommodate resourceTarget queryParam Issue-ID: SO-2929 Signed-off-by: zrrmmua <ramesh.murugan.iyer@est.tech> Change-Id: I785cdd588b6094387906edb495e53b01596f5046
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/test')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandlerTest.java53
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForService.json20
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForServiceWorkflows_Response.json41
3 files changed, 110 insertions, 4 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandlerTest.java
index 4ab88f40f6..1fa71cefc2 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandlerTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandlerTest.java
@@ -58,6 +58,9 @@ public class WorkflowSpecificationsHandlerTest extends BaseTest {
@Autowired
WorkflowSpecificationsHandler workflowSpecificationsHandler;
+ @Autowired
+ ObjectMapper mapper;
+
@Value("${wiremock.server.port}")
private String wiremockPort;
@@ -152,7 +155,6 @@ public class WorkflowSpecificationsHandlerTest extends BaseTest {
assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
WorkflowSpecifications expectedResponse = mapper.readValue(
@@ -306,7 +308,6 @@ public class WorkflowSpecificationsHandlerTest extends BaseTest {
WorkflowSpecifications workflowSpecifications =
workflowSpecificationsHandler.mapWorkflowsToWorkflowSpecifications(workflows);
- ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
String workflowSpecificationsJson = mapper.writeValueAsString(workflowSpecifications);
@@ -349,7 +350,6 @@ public class WorkflowSpecificationsHandlerTest extends BaseTest {
assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
WorkflowSpecifications expectedResponse = mapper.readValue(
@@ -367,6 +367,52 @@ public class WorkflowSpecificationsHandlerTest extends BaseTest {
}
@Test
+ public void queryWorkflowSpecificationsByResourceTarget_Test_Success() throws JSONException, IOException {
+
+ String URL_PATH = basePath + "/v1/workflows";
+ HttpHeaders headers = new HttpHeaders();
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ HttpEntity<String> entity = new HttpEntity<String>(null, headers);
+ String WORKFLOW_QUERY = "/workflow/search/findByResourceTarget[?]resourceTarget=service";
+ String WORKFLOW_SPEC_QUERY = "/workflow/5/workflowActivitySpecSequence";
+ String JSON_FILE_PATH = "src/test/resources/__files/catalogdb/WorkflowSpecificationsForService.json";
+ String MOCK_RESP_FILE = "WorkflowSpecificationsForServiceWorkflows_Response.json";
+ String MOCK_RESP_SPEC_FILE = "Empty_workflowActivitySpecSequence_Response.json";
+
+ wireMockServer.stubFor(get(urlMatching(WORKFLOW_QUERY))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(getWiremockResponseForCatalogdb(MOCK_RESP_FILE))
+ .withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ wireMockServer.stubFor(get(urlMatching(WORKFLOW_SPEC_QUERY))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(getWiremockResponseForCatalogdb(MOCK_RESP_SPEC_FILE))
+ .withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ UriComponentsBuilder builder =
+ UriComponentsBuilder.fromHttpUrl(createURLWithPort(URL_PATH)).queryParam("resourceTarget", "service");
+
+ ResponseEntity<String> response =
+ restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
+
+ assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
+
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ WorkflowSpecifications expectedResponse = mapper
+ .readValue(new String(Files.readAllBytes(Paths.get(JSON_FILE_PATH))), WorkflowSpecifications.class);
+ WorkflowSpecifications realResponse = mapper.readValue(response.getBody(), WorkflowSpecifications.class);
+
+ assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
+ assertThat(expectedResponse, sameBeanAs(realResponse));
+ assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
+ assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
+ assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
+ assertEquals("1.0.0", response.getHeaders().get("X-LatestVersion").get(0));
+ }
+
+ @Test
public void testWorkflowSpecificationsForPnf_Success() throws JSONException, IOException {
final String urlPath = basePath + "/v1/pnfWorkflows";
@@ -397,7 +443,6 @@ public class WorkflowSpecificationsHandlerTest extends BaseTest {
assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
WorkflowSpecifications expectedResponse = mapper.readValue(
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForService.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForService.json
new file mode 100644
index 0000000000..aaaad17470
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForService.json
@@ -0,0 +1,20 @@
+{
+ "workflowSpecificationList": [
+ {
+ "workflowSpecification": {
+ "artifactInfo": {
+ "artifactType": "workflow",
+ "artifactUuid": "a1fe8726-66d5-3e7f-2212-7e5h662e9255",
+ "artifactName": "DummyServiceWorkflow",
+ "artifactVersion": "1.0",
+ "artifactDescription": "Dummy Service Workflow to test custom Service workflow",
+ "workflowName": "Dummy Service Workflow",
+ "operationName": "DummyServiceWorkflow",
+ "workflowSource": "native",
+ "workflowResourceTarget": "service"
+ },
+ "workflowInputParameters": []
+ }
+ }
+ ]
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForServiceWorkflows_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForServiceWorkflows_Response.json
new file mode 100644
index 0000000000..9a836e033b
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForServiceWorkflows_Response.json
@@ -0,0 +1,41 @@
+{
+ "_embedded": {
+ "workflow": [
+ {
+ "artifactChecksum": "MANUAL RECORD",
+ "artifactName": "DummyServiceWorkflow",
+ "artifactUUID": "a1fe8726-66d5-3e7f-2212-7e5h662e9255",
+ "body": null,
+ "created": "2020-06-29T08:28:15.000+0000",
+ "description": "Dummy Service Workflow to test custom Service workflow",
+ "id": 4,
+ "name": "Dummy Service Workflow",
+ "operationName": "DummyServiceWorkflow",
+ "pnfResourceWorkflow": null,
+ "resourceTarget": "service",
+ "source": "native",
+ "timeoutMinutes": null,
+ "version": 1.0,
+ "_links": {
+ "self": {
+ "href": "http://localhost:8090/workflow/search/findByResourceTarget?resourceTarget=service"
+ },
+ "workflow": {
+ "href": "http://localhost:8090/workflow/5"
+ },
+ "workflowActivitySpecSequence": {
+ "href": "http://localhost:8090/workflow/5/workflowActivitySpecSequence"
+ }
+ }
+ }
+ ]
+ },
+ "_links": {
+ "self": {
+ "href": "http://localhost:8090/workflow/search/findByResourceTarget?resourceTarget=service"
+ },
+ "workflowActivitySpecSequence": {
+ "href": "http://localhost:8090/workflow/5/workflowActivitySpecSequence"
+ }
+ }
+} \ No newline at end of file