Skip to content

Commit

Permalink
feat: aligned to api changes (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
JordenReuter authored Jul 31, 2024
1 parent 44dafcc commit 2b3f760
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,32 +47,32 @@ h| Version
| tkit-quarkus-log-cdi
| https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-log-cdi.html[Link]
| https://github.com/1000kit/tkit-quarkus/blob/2.27.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-cdi.adoc[Link]
| 2.27.0
| https://github.com/1000kit/tkit-quarkus/blob/2.28.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-cdi.adoc[Link]
| 2.28.0
| tkit-quarkus-log-rs
| https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-log-rs.html[Link]
| https://github.com/1000kit/tkit-quarkus/blob/2.27.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-rs.adoc[Link]
| 2.27.0
| https://github.com/1000kit/tkit-quarkus/blob/2.28.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-rs.adoc[Link]
| 2.28.0
| tkit-quarkus-log-json
| https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-log-json.html[Link]
| https://github.com/1000kit/tkit-quarkus/blob/2.27.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-json.adoc[Link]
| 2.27.0
| https://github.com/1000kit/tkit-quarkus/blob/2.28.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-json.adoc[Link]
| 2.28.0
| tkit-quarkus-rest
| https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-rest.html[Link]
| https://github.com/1000kit/tkit-quarkus/blob/2.27.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-rest.adoc[Link]
| 2.27.0
| https://github.com/1000kit/tkit-quarkus/blob/2.28.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-rest.adoc[Link]
| 2.28.0
| tkit-quarkus-rest-context
| https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-rest-context.html[Link]
| https://github.com/1000kit/tkit-quarkus/blob/2.27.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-rest-context.adoc[Link]
| 2.27.0
| https://github.com/1000kit/tkit-quarkus/blob/2.28.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-rest-context.adoc[Link]
| 2.28.0
| quarkus-hibernate-validator
Expand All @@ -95,8 +95,8 @@ h| Version
| onecx-permissions
| https://onecx.github.io/docs/onecx-quarkus/current/onecx-quarkus/onecx-permissions.html[Link]
| https://github.com/onecx/onecx-quarkus/blob/0.22.0/docs/modules/onecx-quarkus/pages/includes/onecx-permissions.adoc[Link]
| 0.22.0
| https://github.com/onecx/onecx-quarkus/blob/0.24.0/docs/modules/onecx-quarkus/pages/includes/onecx-permissions.adoc[Link]
| 0.24.0
| quarkus-oidc
Expand All @@ -113,14 +113,14 @@ h| Version
| tkit-quarkus-security
| https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-security.html[Link]
| https://github.com/1000kit/tkit-quarkus/blob/2.27.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-security.adoc[Link]
| 2.27.0
| https://github.com/1000kit/tkit-quarkus/blob/2.28.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-security.adoc[Link]
| 2.28.0
| onecx-core
| https://onecx.github.io/docs/onecx-quarkus/current/onecx-quarkus/onecx-core.html[Link]
|
| 0.22.0
| 0.24.0
| quarkus-arc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,18 @@ public Response searchActiveAnnouncements(ActiveAnnouncementsSearchCriteriaDTO a
}
}

@Override
public Response searchAnnouncementBanners(AnnouncementBannerSearchCriteriaDTO announcementBannerSearchCriteriaDTO) {
try (Response response = client
.searchAnnouncementBanners(
announcementMapper.mapAnnouncementBannerSearchCriteria(announcementBannerSearchCriteriaDTO))) {
AnnouncementPageResult announcementPageResult = response.readEntity(AnnouncementPageResult.class);
AnnouncementPageResultDTO announcementPageResultDTO = announcementMapper
.mapAnnouncementPageResultToAnnouncementPageResultDTO(announcementPageResult);
return Response.status(response.getStatus()).entity(announcementPageResultDTO).build();
}
}

@Override
public Response searchAnnouncements(AnnouncementSearchCriteriaDTO announcementSearchCriteriaDTO) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,7 @@ default ActiveAnnouncementsPageResultDTO filterAndSort(ActiveAnnouncementsPageRe
@Mapping(target = "removeWorkspaceNamesItem", ignore = true)
@Mapping(target = "removeProductNamesItem", ignore = true)
AnnouncementAssignmentsDTO map(AnnouncementProducts announcementProducts);

AnnouncementBannerSearchCriteria mapAnnouncementBannerSearchCriteria(
AnnouncementBannerSearchCriteriaDTO announcementBannerSearchCriteriaDTO);
}
53 changes: 53 additions & 0 deletions src/main/openapi/openapi-bff.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,37 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/ProblemDetailResponse'
/announcements/banner/search:
post:
x-onecx:
permissions:
announcement:
- read
tags:
- AnnouncementInternal
summary: Find announcements by criteria
operationId: searchAnnouncementBanners
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/AnnouncementBannerSearchCriteria'
responses:
"200":
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/AnnouncementPageResult'
"400":
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/ProblemDetailResponse'
/announcements/active/search:
post:
x-onecx:
Expand Down Expand Up @@ -357,6 +388,28 @@ components:
default: 100
maximum: 1000
type: integer
AnnouncementBannerSearchCriteria:
type: object
required:
- currentDate
properties:
currentDate:
$ref: '#/components/schemas/OffsetDateTime'
productName:
type: string
workspaceName:
type: string
pageNumber:
format: int32
description: The number of page.
default: 0
type: integer
pageSize:
format: int32
description: The size of page
default: 100
maximum: 1000
type: integer
UpdateAnnouncementRequest:
type: object
required:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,6 @@ void getAnnouncements_shouldReturnAnnouncementPageResults() {

// Request data to svc
AnnouncementPageResult data = new AnnouncementPageResult();
data.setSize(5);
data.setTotalPages(1L);
data.setNumber(2);
data.setStream(announcements);

// svc call prepare mock endpoint
Expand Down Expand Up @@ -156,6 +153,57 @@ void getAnnouncements_shouldReturnAnnouncementPageResults() {
Assertions.assertEquals(data.getStream().get(0), announcement);
}

@Test
void getAnnouncementBanners_shouldReturnAnnouncementPageResults() {

Announcement announcement = new Announcement();
announcement.setProductName("productName");
announcement.setContent("AnnouncementContent");
List<Announcement> announcements = new ArrayList<>();
announcements.add(announcement);

// Request data to svc
AnnouncementPageResult data = new AnnouncementPageResult();
data.setStream(announcements);

AnnouncementBannerSearchCriteria criteria = new AnnouncementBannerSearchCriteria();
var dateTime = OffsetDateTime.parse("2023-11-30T13:53:03.688710200+01:00");
criteria.setCurrentDate(dateTime);

// svc call prepare mock endpoint
mockServerClient
.when(request().withPath(ANNOUNCEMENT_SVC_INTERNAL_API_BASE_PATH + "/banner/search")
.withMethod(HttpMethod.POST))
.withId(MOCK_ID)
.respond(httpRequest -> response().withStatusCode(Response.Status.OK.getStatusCode())
.withContentType(MediaType.APPLICATION_JSON)
.withBody(JsonBody.json(data)));

// bff call input
AnnouncementBannerSearchCriteriaDTO input = new AnnouncementBannerSearchCriteriaDTO();
input.setCurrentDate(dateTime);

// bff call
var response = given()
.when()
.auth().oauth2(keycloakClient.getAccessToken(ADMIN))
.header(APM_HEADER_PARAM, ADMIN)
.contentType(APPLICATION_JSON)
.body(input)
.post("/banner/search")
.then()
.statusCode(Response.Status.OK.getStatusCode())
.contentType(APPLICATION_JSON)
.extract().as(AnnouncementPageResultDTO.class);

// Assertions
Assertions.assertNotNull(response);
Assertions.assertEquals(data.getNumber(), response.getNumber());
Assertions.assertEquals(data.getSize(), response.getSize());
Assertions.assertEquals(1, data.getStream().size());
Assertions.assertEquals(data.getStream().get(0), announcement);
}

@Test
void getAnnouncementById_shouldReturnAnnouncement() {
// Request data to svc
Expand Down

0 comments on commit 2b3f760

Please sign in to comment.