diff options
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/test')
4 files changed, 114 insertions, 2 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 0beab1bd13..7af92cb8ef 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 @@ -68,7 +68,7 @@ public class WorkflowSpecificationsHandlerTest extends BaseTest { private final String basePath = "onap/so/infra/workflowSpecifications/v1/workflows"; @Test - public void queryWorkflowSpecifications_Test_Success() + public void queryWorkflowSpecificationsByVnfModelUUID_Test_Success() throws ParseException, JSONException, JsonParseException, JsonMappingException, IOException { HttpHeaders headers = new HttpHeaders(); @@ -77,7 +77,7 @@ public class WorkflowSpecificationsHandlerTest extends BaseTest { HttpEntity<String> entity = new HttpEntity<String>(null, headers); wireMockServer.stubFor(get(urlMatching( - "/workflow/search/findWorkflowByModelUUID[?]vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52")) + "/workflow/search/findWorkflowByVnfModelUUID[?]vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBody(getWiremockResponseForCatalogdb("WorkflowSpecificationsQuery_Response.json")) .withStatus(org.apache.http.HttpStatus.SC_OK))); @@ -324,6 +324,52 @@ public class WorkflowSpecificationsHandlerTest extends BaseTest { assertThat(expectedResult, sameBeanAs(workflowSpecifications).ignoring(WorkflowInputParameter.class)); } + @Test + public void queryWorkflowSpecificationsByPnfModelUUID_Test_Success() + throws ParseException, JSONException, JsonParseException, JsonMappingException, IOException { + + 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); + + wireMockServer.stubFor(get(urlMatching( + "/workflow/search/findWorkflowByPnfModelUUID[?]pnfResourceModelUUID=f2d1f2b2-88bb-49da-b716-36ae420ccbff")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb( + "WorkflowSpecificationsForPnfQuery_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + wireMockServer.stubFor(get(urlMatching("/workflow/4/workflowActivitySpecSequence")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("Empty_workflowActivitySpecSequence_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(basePath)) + .queryParam("pnfModelVersionId", "f2d1f2b2-88bb-49da-b716-36ae420ccbff"); + + ResponseEntity<String> response = + restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + WorkflowSpecifications expectedResponse = mapper.readValue( + new String(Files.readAllBytes( + Paths.get("src/test/resources/__files/catalogdb/WorkflowSpecificationsForPnf.json"))), + 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)); + } + private String getWiremockResponseForCatalogdb(String file) { try { File resource = ResourceUtils.getFile("classpath:__files/catalogdb/" + file); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/Empty_workflowActivitySpecSequence_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/Empty_workflowActivitySpecSequence_Response.json new file mode 100644 index 0000000000..89675e8f02 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/Empty_workflowActivitySpecSequence_Response.json @@ -0,0 +1,5 @@ +{ + "_embedded": { + "workflowActivitySpecSequence": [] + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForPnf.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForPnf.json new file mode 100644 index 0000000000..257b9dc843 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForPnf.json @@ -0,0 +1,20 @@ +{ + "workflowSpecificationList": [ + { + "workflowSpecification": { + "artifactInfo": { + "artifactType": "workflow", + "artifactUuid": "b2fd5627-55e4-4f4f-8064-9e6f443e9152", + "artifactName": "DummyPnfWorkflow", + "artifactVersion": "1.0", + "artifactDescription": "Dummy Pnf Workflow to test custom Pnf workflow", + "workflowName": "Dummy Pnf Workflow", + "operationName": "DummyPnfWorkflow", + "workflowSource": "native", + "workflowResourceTarget": "pnf" + }, + "workflowInputParameters": [] + } + } + ] +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForPnfQuery_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForPnfQuery_Response.json new file mode 100644 index 0000000000..a4e1bbcdc5 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForPnfQuery_Response.json @@ -0,0 +1,41 @@ +{ + "_embedded": { + "workflow": [ + { + "artifactChecksum": "MANUAL RECORD", + "artifactName": "DummyPnfWorkflow", + "artifactUUID": "b2fd5627-55e4-4f4f-8064-9e6f443e9152", + "body": null, + "created": "2020-02-18T08:28:15.000+0000", + "description": "Dummy Pnf Workflow to test custom Pnf workflow", + "id": 4, + "name": "Dummy Pnf Workflow", + "operationName": "DummyPnfWorkflow", + "pnfResourceWorkflow": null, + "resourceTarget": "pnf", + "source": "native", + "timeoutMinutes": null, + "version": 1.0, + "_links": { + "self": { + "href": "http://localhost:8090/workflow/search/findWorkflowByPnfModelUUID?pnfResourceModelUUID=f2d1f2b2-88bb-49da-b716-36ae420ccbff" + }, + "workflow": { + "href": "http://localhost:8090/workflow/4" + }, + "workflowActivitySpecSequence": { + "href": "http://localhost:8090/workflow/4/workflowActivitySpecSequence" + } + } + } + ] + }, + "_links": { + "self": { + "href": "http://localhost:8090/workflow/search/findWorkflowByPnfModelUUID?pnfResourceModelUUID=f2d1f2b2-88bb-49da-b716-36ae420ccbff" + }, + "workflowActivitySpecSequence": { + "href": "http://localhost:8090/workflow/4/workflowActivitySpecSequence" + } + } +} |