Skip to content

Commit

Permalink
feat: fit bff project to UI (#2)
Browse files Browse the repository at this point in the history
* feat: init setup

* feat: test added

* feat: update swagger AnnouncementSearchCriteriaDTO

* feat: update pom

* feat: update properties

* feat: helm settings

* fix: change search return PageResult

* fix: update method error response

* feat: update openapi validation

* fix: helm files changes

* fix: log level delete

* fix: delete response mapper
  • Loading branch information
jsteenke authored Jan 17, 2024
1 parent c81b526 commit 0071b00
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 91 deletions.
2 changes: 1 addition & 1 deletion src/main/helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: v1
apiVersion: v2
name: onecx-announcement-bff
version: 0.0.0
appVersion: 0.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import gen.io.github.onecx.announcement.bff.clients.api.AnnouncementInternalApi;
import gen.io.github.onecx.announcement.bff.clients.model.*;
import gen.io.github.onecx.announcement.bff.clients.model.ProblemDetailResponse;
import gen.io.github.onecx.announcement.bff.rs.internal.AnnouncementInternalApiService;
import gen.io.github.onecx.announcement.bff.rs.internal.model.*;
import io.github.onecx.announcement.bff.rs.mappers.AnnouncementMapper;
Expand All @@ -40,7 +39,7 @@ public class AnnouncementRestController implements AnnouncementInternalApiServic
ExceptionMapper exceptionMapper;

@Override
public Response addAnnouncement(CreateAnnouncementRequestDTO createAnnouncementRequestDTO) {
public Response createAnnouncement(CreateAnnouncementRequestDTO createAnnouncementRequestDTO) {

try (Response response = client
.createAnnouncement(announcementMapper.mapCreateAnnouncement(createAnnouncementRequestDTO))) {
Expand Down Expand Up @@ -97,11 +96,6 @@ public Response updateAnnouncementById(String id, UpdateAnnouncementRequestDTO u
Announcement announcement = response.readEntity(Announcement.class);
AnnouncementDTO announcementDTO = announcementMapper.mapAnnouncementToAnnouncementDTO(announcement);
return Response.status(response.getStatus()).entity(announcementDTO).build();
} catch (WebApplicationException ex) {
return Response.status(ex.getResponse().getStatus())
.entity(problemDetailMapper
.mapProblemDetailResponse(ex.getResponse().readEntity(ProblemDetailResponse.class)))
.build();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public interface AnnouncementMapper {

AnnouncementSearchCriteria mapAnnouncementSearchCriteria(AnnouncementSearchCriteriaDTO searchAnnouncementRequestDTO);

@Mapping(target = "version", ignore = true)
AnnouncementDTO mapAnnouncementToAnnouncementDTO(Announcement announcement);

@Mapping(target = "removeStreamItem", ignore = true)
Expand Down

This file was deleted.

70 changes: 12 additions & 58 deletions src/main/openapi/openapi-announcement-bff.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ paths:
post:
tags:
- AnnouncementInternal
summary: Add announcement
operationId: addAnnouncement
summary: Create announcement
operationId: createAnnouncement
requestBody:
required: true
content:
Expand Down Expand Up @@ -112,12 +112,6 @@ paths:
responses:
"204":
description: No content
"400":
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/ProblemDetailResponse'
put:
tags:
- AnnouncementInternal
Expand All @@ -130,6 +124,7 @@ paths:
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
Expand Down Expand Up @@ -158,6 +153,9 @@ components:
type: string
CreateAnnouncementRequest:
type: object
required:
- title
- startDate
properties:
title:
type: string
Expand All @@ -175,23 +173,9 @@ components:
$ref: '#/components/schemas/OffsetDateTime'
appId:
type: string
SearchAnnouncementRequest:
AnnouncementSearchCriteria:
type: object
properties:
creationDateFrom:
$ref: '#/components/schemas/OffsetDateTime'
creationDateTo:
$ref: '#/components/schemas/OffsetDateTime'
creationUser:
type: string
modificationDateFrom:
$ref: '#/components/schemas/OffsetDateTime'
modificationDateTo:
$ref: '#/components/schemas/OffsetDateTime'
modificationUser:
type: string
id:
type: string
title:
type: string
content:
Expand Down Expand Up @@ -224,6 +208,9 @@ components:
type: integer
UpdateAnnouncementRequest:
type: object
required:
- title
- startDate
properties:
title:
type: string
Expand All @@ -244,7 +231,7 @@ components:
Announcement:
type: object
properties:
version:
modificationCount:
format: int32
type: integer
creationDate:
Expand Down Expand Up @@ -342,37 +329,4 @@ components:
name:
type: string
message:
type: string
AnnouncementSearchCriteria:
type: object
properties:
title:
type: string
content:
type: string
type:
$ref: '#/components/schemas/AnnouncementType'
priority:
$ref: '#/components/schemas/AnnouncementPriorityType'
status:
$ref: '#/components/schemas/AnnouncementStatus'
startDateFrom:
$ref: '#/components/schemas/OffsetDateTime'
startDateTo:
$ref: '#/components/schemas/OffsetDateTime'
endDateFrom:
$ref: '#/components/schemas/OffsetDateTime'
endDateTo:
$ref: '#/components/schemas/OffsetDateTime'
appId:
type: string
pageNumber:
format: int32
description: The number of page.
default: 0
type: integer
pageSize:
format: int32
description: The size of page
default: 100
type: integer
type: string
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static org.mockserver.model.HttpRequest.request;
import static org.mockserver.model.HttpResponse.response;

import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -17,6 +18,7 @@
import org.mockserver.client.MockServerClient;
import org.mockserver.model.JsonBody;
import org.mockserver.model.MediaType;
import org.tkit.quarkus.rs.mappers.OffsetDateTimeMapper;

import gen.io.github.onecx.announcement.bff.clients.model.*;
import gen.io.github.onecx.announcement.bff.rs.internal.model.*;
Expand All @@ -40,12 +42,16 @@ void resetMockserver() {
}

@Test
void addAnnouncement_shouldReturnAnnouncement() {
void createAnnouncement_shouldReturnAnnouncement() {
var offsetDateTime = OffsetDateTime.parse("2023-11-30T13:53:03.688710200+01:00");
OffsetDateTimeMapper offsetDateTimeMapper = new OffsetDateTimeMapper();

// Request data to svc
Announcement data = new Announcement();
data.setAppId("appId");
data.setContent("AnnouncmentContent");
data.setTitle("announcementTitle");
data.startDate(offsetDateTime);

// svc call prepare mock endpoint
mockServerClient
Expand All @@ -59,6 +65,8 @@ void addAnnouncement_shouldReturnAnnouncement() {
// bff call input
CreateAnnouncementRequestDTO input = new CreateAnnouncementRequestDTO();
input.setAppId("appId1");
input.setTitle("announcementTitle");
input.startDate(offsetDateTime);

// bff call
var response = given()
Expand All @@ -79,6 +87,7 @@ void addAnnouncement_shouldReturnAnnouncement() {

@Test
void getAnnouncements_shouldReturnAnnouncementPageResults() {

Announcement announcement = new Announcement();
announcement.setAppId("appId");
announcement.setContent("AnnouncmentContent");
Expand Down Expand Up @@ -252,6 +261,9 @@ void deleteAnnouncementById() {

@Test
void updateAnnouncementById() {
var offsetDateTime = OffsetDateTime.parse("2023-11-30T13:53:03.688710200+01:00");
OffsetDateTimeMapper offsetDateTimeMapper = new OffsetDateTimeMapper();

String updateId = "updateId_NO_CONTENT";
Announcement data = new Announcement();
data.setAppId("appIdTest1");
Expand All @@ -267,6 +279,8 @@ void updateAnnouncementById() {
.withBody(JsonBody.json(data)));

UpdateAnnouncementRequestDTO input = new UpdateAnnouncementRequestDTO();
input.setStartDate(offsetDateTime);
input.setTitle("appTitle");
// bff call
given()
.when()
Expand Down Expand Up @@ -309,7 +323,7 @@ void updateAnnouncementById_shouldReturnBadRequest() {
}

@Test
void addAnnouncements_shouldReturnBadRequest_whenRunningIntoValidationConstraints() {
void createAnnouncement_shouldReturnBadRequest_whenRunningIntoValidationConstraints() {

ProblemDetailResponse data = new ProblemDetailResponse();
data.setErrorCode("CONSTRAINT_VIOLATIONS");
Expand Down

0 comments on commit 0071b00

Please sign in to comment.