diff --git a/src/main/java/org/tkit/onecx/help/bff/rs/controller/HelpRestController.java b/src/main/java/org/tkit/onecx/help/bff/rs/controller/HelpRestController.java index 41a4682..3499ace 100644 --- a/src/main/java/org/tkit/onecx/help/bff/rs/controller/HelpRestController.java +++ b/src/main/java/org/tkit/onecx/help/bff/rs/controller/HelpRestController.java @@ -84,6 +84,15 @@ public Response getHelpById(String id) { } } + @Override + public Response getHelpByProductNameItemId(String productName, String helpItemId) { + try (Response response = client.getHelpByProductNameItemId(productName, helpItemId)) { + Help help = response.readEntity(Help.class); + HelpDTO helpDTO = helpMapper.mapHelp(help); + return Response.ok(helpDTO).build(); + } + } + @Override public Response searchHelps(HelpSearchCriteriaDTO helpSearchCriteriaDTO) { diff --git a/src/main/openapi/openapi-bff.yaml b/src/main/openapi/openapi-bff.yaml index 7184a5f..a3e112f 100644 --- a/src/main/openapi/openapi-bff.yaml +++ b/src/main/openapi/openapi-bff.yaml @@ -192,6 +192,38 @@ paths: application/json: schema: $ref: '#/components/schemas/HelpPageResult' + /helps/{productName}/{helpItemId}: + get: + x-onecx: + permissions: + help: + - read + tags: + - helpsInternal + description: search help item by product name and item id + operationId: getHelpByProductNameItemId + parameters: + - name: productName + in: path + required: true + description: product name + schema: + type: string + - name: helpItemId + in: path + required: true + description: help item ID + schema: + type: string + responses: + 200: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/Help' + 404: + description: Help not found components: schemas: HelpSearchCriteria: diff --git a/src/test/java/org/tkit/onecx/help/bff/rs/HelpRestControllerTest.java b/src/test/java/org/tkit/onecx/help/bff/rs/HelpRestControllerTest.java index 175b5a6..17aac0b 100644 --- a/src/test/java/org/tkit/onecx/help/bff/rs/HelpRestControllerTest.java +++ b/src/test/java/org/tkit/onecx/help/bff/rs/HelpRestControllerTest.java @@ -466,6 +466,43 @@ void getAllProductsTest() { mockServerClient.clear(MOCK_ID); } + @Test + void getProductNameItemIdTest() { + + var offsetDateTime = OffsetDateTime.parse("2023-11-30T13:53:03.688710200+01:00"); + Help data = createHelp("p1", + "i1", + "testContext", + offsetDateTime, + "http://localhost:8080/mfe", + "testUser", + "itemId1"); + + mockServerClient + .when(request().withPath(HELP_SVC_INTERNAL_API_BASE_PATH + "/p1/i1") + .withMethod(HttpMethod.GET)) + .withPriority(100) + .withId(MOCK_ID) + .respond(httpRequest -> response().withStatusCode(Response.Status.OK.getStatusCode()) + .withContentType(MediaType.APPLICATION_JSON) + .withBody(JsonBody.json(data))); + + // bff call + var response = given() + .when() + .auth().oauth2(keycloakClient.getAccessToken(ADMIN)) + .header(APM_HEADER_PARAM, ADMIN) + .contentType(APPLICATION_JSON) + .get("/p1/i1") + .then() + .statusCode(Response.Status.OK.getStatusCode()) + .extract().as(HelpDTO.class); + + Assertions.assertNotNull(response); + Assertions.assertEquals(data.getItemId(), response.getItemId()); + Assertions.assertEquals(data.getProductName(), response.getProductName()); + } + @Test void errorSecurityTest() { String id = "82689h23-9624-2234-c50b-8749d073c287";