From 54f3f6f35bfb20ae39e19e83f10acdb02f180ed4 Mon Sep 17 00:00:00 2001 From: Jannik Steenken Date: Fri, 5 Jan 2024 16:33:08 +0100 Subject: [PATCH 01/12] feat: init setup --- .github/changelog.yaml | 13 + .github/dependabot.yaml | 8 + .github/workflows/build-branch.yml | 13 + .github/workflows/build-pr.yml | 9 + .github/workflows/build-release.yml | 9 + .github/workflows/build.yml | 23 ++ .github/workflows/create-fix-branch.yml | 7 + .github/workflows/create-release.yml | 7 + .github/workflows/documentation.yml | 10 + .github/workflows/sonar-pr.yml | 12 + .gitignore | 44 +++ index.html | 17 + pom.xml | 163 +++++++++ src/main/docker/Dockerfile.jvm | 13 + src/main/docker/Dockerfile.native | 11 + src/main/helm/Chart.yaml | 17 + src/main/helm/values.yaml | 6 + .../AnnouncementRestController.java | 119 ++++++ .../bff/rs/mappers/AnnouncementMapper.java | 25 ++ .../bff/rs/mappers/ExceptionMapper.java | 61 ++++ .../bff/rs/mappers/ProblemDetailMapper.java | 15 + .../bff/rs/mappers/ResponseMapper.java | 22 ++ .../openapi/openapi-announcement-bff.yaml | 345 ++++++++++++++++++ src/main/resources/application.properties | 20 + .../announcement/bff/rs/AbstractTest.java | 26 ++ .../rs/AnnouncementRestControllerTest.java | 310 ++++++++++++++++ src/test/resources/mockserver.properties | 16 + src/test/resources/mockserver/internal.json | 0 28 files changed, 1341 insertions(+) create mode 100644 .github/changelog.yaml create mode 100644 .github/dependabot.yaml create mode 100644 .github/workflows/build-branch.yml create mode 100644 .github/workflows/build-pr.yml create mode 100644 .github/workflows/build-release.yml create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/create-fix-branch.yml create mode 100644 .github/workflows/create-release.yml create mode 100644 .github/workflows/documentation.yml create mode 100644 .github/workflows/sonar-pr.yml create mode 100644 .gitignore create mode 100644 index.html create mode 100644 pom.xml create mode 100644 src/main/docker/Dockerfile.jvm create mode 100644 src/main/docker/Dockerfile.native create mode 100644 src/main/helm/Chart.yaml create mode 100644 src/main/helm/values.yaml create mode 100644 src/main/java/io/github/onecx/announcement/bff/rs/controller/AnnouncementRestController.java create mode 100644 src/main/java/io/github/onecx/announcement/bff/rs/mappers/AnnouncementMapper.java create mode 100644 src/main/java/io/github/onecx/announcement/bff/rs/mappers/ExceptionMapper.java create mode 100644 src/main/java/io/github/onecx/announcement/bff/rs/mappers/ProblemDetailMapper.java create mode 100644 src/main/java/io/github/onecx/announcement/bff/rs/mappers/ResponseMapper.java create mode 100644 src/main/openapi/openapi-announcement-bff.yaml create mode 100644 src/main/resources/application.properties create mode 100644 src/test/java/io/github/onecx/announcement/bff/rs/AbstractTest.java create mode 100644 src/test/java/io/github/onecx/announcement/bff/rs/AnnouncementRestControllerTest.java create mode 100644 src/test/resources/mockserver.properties create mode 100644 src/test/resources/mockserver/internal.json diff --git a/.github/changelog.yaml b/.github/changelog.yaml new file mode 100644 index 0000000..0a5526e --- /dev/null +++ b/.github/changelog.yaml @@ -0,0 +1,13 @@ +sections: + - title: Major changes + labels: + - "release/super-feature" + - title: Complete changelog + labels: + - "bug" + - "enhancement" + - "dependencies" +template: | + {{ range $section := .Sections }}{{ if $section.Items }}### {{ $section.GetTitle }}{{ range $item := $section.Items }} + * [#{{ $item.GetID }}]({{ $item.GetURL }}) - {{ $item.GetTitle }}{{ end }}{{ end }} + {{ end }} \ No newline at end of file diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml new file mode 100644 index 0000000..64412da --- /dev/null +++ b/.github/dependabot.yaml @@ -0,0 +1,8 @@ +version: 2 +updates: + - package-ecosystem: maven + directory: "/" + schedule: + interval: daily + labels: + - dependencies \ No newline at end of file diff --git a/.github/workflows/build-branch.yml b/.github/workflows/build-branch.yml new file mode 100644 index 0000000..7270213 --- /dev/null +++ b/.github/workflows/build-branch.yml @@ -0,0 +1,13 @@ +name: Build Feature Branch + +on: + push: + branches: + - '**' + - '!main' + - '!fix/[0-9]+.[0-9]+.x' + +jobs: + branch: + uses: onecx/ci-quarkus/.github/workflows/build-branch.yml@v1 + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml new file mode 100644 index 0000000..acff155 --- /dev/null +++ b/.github/workflows/build-pr.yml @@ -0,0 +1,9 @@ +name: Build Pull Request + +on: + pull_request: + +jobs: + pr: + uses: onecx/ci-quarkus/.github/workflows/build-pr.yml@v1 + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml new file mode 100644 index 0000000..b04a59a --- /dev/null +++ b/.github/workflows/build-release.yml @@ -0,0 +1,9 @@ +name: Build Release +on: + push: + tags: + - '**' +jobs: + release: + uses: onecx/ci-quarkus/.github/workflows/build-release.yml@v1 + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..d4cd036 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,23 @@ +name: Build + +on: + workflow_dispatch: + push: + branches: + - 'main' + - 'fix/[0-9]+.[0-9]+.x' + paths-ignore: + - '.gitignore' + - 'CODEOWNERS' + - 'LICENSE' + - '*.md' + - '*.adoc' + - '*.txt' + - '.all-contributorsrc' + +jobs: + build: + uses: onecx/ci-quarkus/.github/workflows/build.yml@v1 + secrets: inherit + with: + helmEventTargetRepository: onecx/onecx-theme \ No newline at end of file diff --git a/.github/workflows/create-fix-branch.yml b/.github/workflows/create-fix-branch.yml new file mode 100644 index 0000000..92af624 --- /dev/null +++ b/.github/workflows/create-fix-branch.yml @@ -0,0 +1,7 @@ +name: Create Fix Branch +on: + workflow_dispatch: +jobs: + fix: + uses: onecx/ci-common/.github/workflows/create-fix-branch.yml@v1 + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml new file mode 100644 index 0000000..c97eb42 --- /dev/null +++ b/.github/workflows/create-release.yml @@ -0,0 +1,7 @@ +name: Create Release Version +on: + workflow_dispatch: +jobs: + release: + uses: onecx/ci-common/.github/workflows/create-release.yml@v1 + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml new file mode 100644 index 0000000..3d17922 --- /dev/null +++ b/.github/workflows/documentation.yml @@ -0,0 +1,10 @@ +name: Update documentation +on: + push: + branches: [ main ] + paths: + - 'docs/**' +jobs: + release: + uses: onecx/ci-common/.github/workflows/documentation.yml@v1 + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/sonar-pr.yml b/.github/workflows/sonar-pr.yml new file mode 100644 index 0000000..02c3e1e --- /dev/null +++ b/.github/workflows/sonar-pr.yml @@ -0,0 +1,12 @@ +name: Sonar Pull Request + +on: + workflow_run: + workflows: ["Build Pull Request"] + types: + - completed + +jobs: + pr: + uses: onecx/ci-quarkus/.github/workflows/quarkus-pr-sonar.yml@v1 + secrets: inherit \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b2b2d1f --- /dev/null +++ b/.gitignore @@ -0,0 +1,44 @@ +#Maven +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +release.properties +.flattened-pom.xml + +# Eclipse +.project +.classpath +.settings/ +bin/ + +# IntelliJ +.idea +*.ipr +*.iml +*.iws + +# NetBeans +nb-configuration.xml + +# Visual Studio Code +.vscode +.factorypath + +# OSX +.DS_Store + +# Vim +*.swp +*.swo + +# patch +*.orig +*.rej + +# Local environment +.env + +# Plugin directory +/.quarkus/cli/plugins/ + diff --git a/index.html b/index.html new file mode 100644 index 0000000..1638783 --- /dev/null +++ b/index.html @@ -0,0 +1,17 @@ +Google



 

Erweiterte Suche

© 2024 - Datenschutzerklärung - Nutzungsbedingungen

\ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..ad407cc --- /dev/null +++ b/pom.xml @@ -0,0 +1,163 @@ + + + 4.0.0 + + + io.github.onecx + onecx-quarkus3-parent + 0.25.0 + + + onecx-announcement-bff + 999-SNAPSHOT + + + io.quarkus + quarkus-resteasy-reactive + + + io.quarkus + quarkus-smallrye-openapi + + + io.quarkus + quarkus-resteasy-reactive-jackson + + + io.quarkus + quarkus-smallrye-health + + + io.quarkiverse.openapi.generator + quarkus-openapi-generator + + + io.quarkus + quarkus-rest-client-reactive-jackson + + + + org.tkit.quarkus.lib + tkit-quarkus-log-cdi + + + org.tkit.quarkus.lib + tkit-quarkus-log-rs + + + org.tkit.quarkus.lib + tkit-quarkus-log-json + + + org.tkit.quarkus.lib + tkit-quarkus-rest + + + org.tkit.quarkus.lib + tkit-quarkus-jpa + + + org.mapstruct + mapstruct + + + io.quarkus + quarkus-hibernate-validator + + + + io.quarkiverse.mockserver + quarkus-mockserver + provided + + + + + io.quarkiverse.mockserver + quarkus-mockserver-test + + + io.swagger.parser.v3 + swagger-parser + + + test + + + io.swagger.parser.v3 + swagger-parser + test + + + + + + + org.openapitools + openapi-generator-maven-plugin + + + internal + + generate + + + src/main/openapi/openapi-announcement-bff.yaml + gen.io.github.onecx.announcement.bff.rs.internal + gen.io.github.onecx.announcement.bff.rs.internal.model + + + + + jaxrs-spec + ApiService + DTO + false + false + false + false + false + true + quarkus + + / + false + true + true + true + true + true + java8 + true + true + false + true + + + + + com.googlecode.maven-download-plugin + download-maven-plugin + + + generate-resources + + wget + + + + + + https://raw.githubusercontent.com/onecx/onecx-announcement-svc/main/src/main/openapi/announcement-openapi-internal.yaml + + target/tmp/openapi + onecx-announcement-svc.yaml + true + + + + + + \ No newline at end of file diff --git a/src/main/docker/Dockerfile.jvm b/src/main/docker/Dockerfile.jvm new file mode 100644 index 0000000..a554421 --- /dev/null +++ b/src/main/docker/Dockerfile.jvm @@ -0,0 +1,13 @@ +FROM registry.access.redhat.com/ubi9/openjdk-17:1.15 + +ENV LANGUAGE='en_US:en' + +COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/ +COPY --chown=185 target/quarkus-app/*.jar /deployments/ +COPY --chown=185 target/quarkus-app/app/ /deployments/app/ +COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/ + +EXPOSE 8080 +USER 185 +ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" +ENV JAVA_APP_JAR="/deployments/quarkus-run.jar" \ No newline at end of file diff --git a/src/main/docker/Dockerfile.native b/src/main/docker/Dockerfile.native new file mode 100644 index 0000000..c97f217 --- /dev/null +++ b/src/main/docker/Dockerfile.native @@ -0,0 +1,11 @@ +FROM registry.access.redhat.com/ubi9/ubi-minimal:9.2 +WORKDIR /work/ +RUN chown 1001 /work \ + && chmod "g+rwX" /work \ + && chown 1001:root /work +COPY --chown=1001:root target/*-runner /work/application + +EXPOSE 8080 +USER 1001 + +CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] \ No newline at end of file diff --git a/src/main/helm/Chart.yaml b/src/main/helm/Chart.yaml new file mode 100644 index 0000000..0de0e3b --- /dev/null +++ b/src/main/helm/Chart.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +name: onecx-announcement-bff +version: 0.0.0 +appVersion: 0.0.0 +description: Onecx announcement bff +keywords: + - announcement +sources: + - https://github.com/onecx/onecx-announcement-bff +maintainers: + - name: Tkit Developer + email: tkit_dev@1000kit.org +dependencies: + - name: helm-quarkus-app + alias: app + version: ^0 + repository: oci://ghcr.io/onecx/charts \ No newline at end of file diff --git a/src/main/helm/values.yaml b/src/main/helm/values.yaml new file mode 100644 index 0000000..02bc384 --- /dev/null +++ b/src/main/helm/values.yaml @@ -0,0 +1,6 @@ +app: + image: + repository: "onecx/onecx-announcement-bff" + tag: 999-SNAPSHOT + db: + enabled: true \ No newline at end of file diff --git a/src/main/java/io/github/onecx/announcement/bff/rs/controller/AnnouncementRestController.java b/src/main/java/io/github/onecx/announcement/bff/rs/controller/AnnouncementRestController.java new file mode 100644 index 0000000..7cfa37c --- /dev/null +++ b/src/main/java/io/github/onecx/announcement/bff/rs/controller/AnnouncementRestController.java @@ -0,0 +1,119 @@ +package io.github.onecx.announcement.bff.rs.controller; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import jakarta.transaction.Transactional; +import jakarta.validation.ConstraintViolationException; +import jakarta.ws.rs.WebApplicationException; +import jakarta.ws.rs.core.Response; + +import org.eclipse.microprofile.rest.client.inject.RestClient; +import org.jboss.resteasy.reactive.RestResponse; +import org.jboss.resteasy.reactive.server.ServerExceptionMapper; +import org.tkit.quarkus.log.cdi.LogService; + +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; +import io.github.onecx.announcement.bff.rs.mappers.ExceptionMapper; +import io.github.onecx.announcement.bff.rs.mappers.ProblemDetailMapper; + +@ApplicationScoped +@Transactional(value = Transactional.TxType.NOT_SUPPORTED) +@LogService +public class AnnouncementRestController implements AnnouncementInternalApiService { + + @Inject + @RestClient + AnnouncementInternalApi client; + + @Inject + AnnouncementMapper announcementMapper; + + @Inject + ProblemDetailMapper problemDetailMapper; + + @Inject + ExceptionMapper exceptionMapper; + + @Override + public Response addAnnouncement(CreateAnnouncementRequestDTO createAnnouncementRequestDTO) { + + try (Response response = client + .createAnnouncement(announcementMapper.mapCreateAnnouncement(createAnnouncementRequestDTO))) { + Announcement announcement = response.readEntity(Announcement.class); + AnnouncementDTO announcementDTO = announcementMapper.mapAnnouncementToAnnouncementDTO(announcement); + return Response.status(response.getStatus()).entity(announcementDTO).build(); + } + } + + @Override + public Response deleteAnnouncementById(String id) { + + try (Response response = client.deleteAnnouncementById(id)) { + return Response.status(response.getStatus()).build(); + } + } + + @Override + public Response getAllAppsWithAnnouncements() { + + try (Response response = client.getAllAppsWithAnnouncements()) { + AnnouncementApps announcementApps = response.readEntity(AnnouncementApps.class); + return Response.status(response.getStatus()).entity(announcementApps).build(); + } + } + + @Override + public Response getAnnouncementById(String id) { + + try (Response response = client.getAnnouncementById(id)) { + Announcement announcement = response.readEntity(Announcement.class); + AnnouncementDTO announcementDTO = announcementMapper.mapAnnouncementToAnnouncementDTO(announcement); + return Response.status(response.getStatus()).entity(announcementDTO).build(); + } + } + + @Override + public Response getAnnouncements(SearchAnnouncementRequestDTO searchAnnouncementRequestDTO) { + + try (Response response = client + .getAnnouncements(announcementMapper.mapAnnouncementSearchCriteria(searchAnnouncementRequestDTO))) { + AnnouncementPageResult announcementPageResult = response.readEntity(AnnouncementPageResult.class); + AnnouncementPageResultDTO announcementPageResultDTO = announcementMapper + .mapAnnouncementPageResultToAnnouncementPageResultDTO(announcementPageResult); + return Response.status(response.getStatus()).entity(announcementPageResultDTO).build(); + } + } + + @Override + public Response updateAnnouncementById(String id, UpdateAnnouncementRequestDTO updateAnnouncementRequestDTO) { + + try (Response response = client.updateAnnouncementById(id, + announcementMapper.mapUpdateAnnouncement(updateAnnouncementRequestDTO))) { + 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(); + } + } + + @ServerExceptionMapper + public RestResponse constraint(ConstraintViolationException ex) { + + return exceptionMapper.constraint(ex); + } + + @ServerExceptionMapper + public Response restException(WebApplicationException ex) { + + return Response.status(ex.getResponse().getStatus()).build(); + } +} diff --git a/src/main/java/io/github/onecx/announcement/bff/rs/mappers/AnnouncementMapper.java b/src/main/java/io/github/onecx/announcement/bff/rs/mappers/AnnouncementMapper.java new file mode 100644 index 0000000..159f74e --- /dev/null +++ b/src/main/java/io/github/onecx/announcement/bff/rs/mappers/AnnouncementMapper.java @@ -0,0 +1,25 @@ +package io.github.onecx.announcement.bff.rs.mappers; + +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +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.*; + +@Mapper(uses = { OffsetDateTimeMapper.class }) +public interface AnnouncementMapper { + + CreateAnnouncementRequest mapCreateAnnouncement(CreateAnnouncementRequestDTO createAnnouncementRequestDTO); + + UpdateAnnouncementRequest mapUpdateAnnouncement(UpdateAnnouncementRequestDTO updateAnnouncementRequestDTO); + + AnnouncementSearchCriteria mapAnnouncementSearchCriteria(SearchAnnouncementRequestDTO searchAnnouncementRequestDTO); + + @Mapping(target = "version", ignore = true) + AnnouncementDTO mapAnnouncementToAnnouncementDTO(Announcement announcement); + + @Mapping(target = "removeStreamItem", ignore = true) + AnnouncementPageResultDTO mapAnnouncementPageResultToAnnouncementPageResultDTO( + AnnouncementPageResult announcementPageResult); +} diff --git a/src/main/java/io/github/onecx/announcement/bff/rs/mappers/ExceptionMapper.java b/src/main/java/io/github/onecx/announcement/bff/rs/mappers/ExceptionMapper.java new file mode 100644 index 0000000..0379b8d --- /dev/null +++ b/src/main/java/io/github/onecx/announcement/bff/rs/mappers/ExceptionMapper.java @@ -0,0 +1,61 @@ +package io.github.onecx.announcement.bff.rs.mappers; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +import jakarta.validation.ConstraintViolation; +import jakarta.validation.ConstraintViolationException; +import jakarta.validation.Path; +import jakarta.ws.rs.core.Response; + +import org.jboss.resteasy.reactive.RestResponse; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.tkit.quarkus.rs.mappers.OffsetDateTimeMapper; + +import gen.io.github.onecx.announcement.bff.rs.internal.model.ProblemDetailInvalidParamDTO; +import gen.io.github.onecx.announcement.bff.rs.internal.model.ProblemDetailParamDTO; +import gen.io.github.onecx.announcement.bff.rs.internal.model.ProblemDetailResponseDTO; + +@Mapper(uses = { OffsetDateTimeMapper.class }) +public interface ExceptionMapper { + + default RestResponse constraint(ConstraintViolationException ex) { + var dto = exception("CONSTRAINT_VIOLATIONS", ex.getMessage()); + dto.setInvalidParams(createErrorValidationResponse(ex.getConstraintViolations())); + return RestResponse.status(Response.Status.BAD_REQUEST, dto); + } + + @Mapping(target = "removeParamsItem", ignore = true) + @Mapping(target = "params", ignore = true) + @Mapping(target = "invalidParams", ignore = true) + @Mapping(target = "removeInvalidParamsItem", ignore = true) + ProblemDetailResponseDTO exception(String errorCode, String detail); + + default List map(Map params) { + if (params == null) { + return List.of(); + } + return params.entrySet().stream().map(e -> { + var item = new ProblemDetailParamDTO(); + item.setKey(e.getKey()); + if (e.getValue() != null) { + item.setValue(e.getValue().toString()); + } + return item; + }).toList(); + } + + List createErrorValidationResponse( + Set> constraintViolation); + + @Mapping(target = "name", source = "propertyPath") + @Mapping(target = "message", source = "message") + ProblemDetailInvalidParamDTO createError(ConstraintViolation constraintViolation); + + default String mapPath(Path path) { + return path.toString(); + } + +} diff --git a/src/main/java/io/github/onecx/announcement/bff/rs/mappers/ProblemDetailMapper.java b/src/main/java/io/github/onecx/announcement/bff/rs/mappers/ProblemDetailMapper.java new file mode 100644 index 0000000..9c0d304 --- /dev/null +++ b/src/main/java/io/github/onecx/announcement/bff/rs/mappers/ProblemDetailMapper.java @@ -0,0 +1,15 @@ +package io.github.onecx.announcement.bff.rs.mappers; + +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.tkit.quarkus.rs.mappers.OffsetDateTimeMapper; + +import gen.io.github.onecx.announcement.bff.clients.model.ProblemDetailResponse; +import gen.io.github.onecx.announcement.bff.rs.internal.model.ProblemDetailResponseDTO; + +@Mapper(uses = { OffsetDateTimeMapper.class }) +public interface ProblemDetailMapper { + @Mapping(target = "removeParamsItem", ignore = true) + @Mapping(target = "removeInvalidParamsItem", ignore = true) + ProblemDetailResponseDTO mapProblemDetailResponse(ProblemDetailResponse problemDetailResponse); +} diff --git a/src/main/java/io/github/onecx/announcement/bff/rs/mappers/ResponseMapper.java b/src/main/java/io/github/onecx/announcement/bff/rs/mappers/ResponseMapper.java new file mode 100644 index 0000000..3982fcc --- /dev/null +++ b/src/main/java/io/github/onecx/announcement/bff/rs/mappers/ResponseMapper.java @@ -0,0 +1,22 @@ +package io.github.onecx.announcement.bff.rs.mappers; + +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.tkit.quarkus.rs.mappers.OffsetDateTimeMapper; + +import gen.io.github.onecx.announcement.bff.clients.model.Announcement; +import gen.io.github.onecx.announcement.bff.clients.model.AnnouncementPageResult; +import gen.io.github.onecx.announcement.bff.rs.internal.model.AnnouncementDTO; +import gen.io.github.onecx.announcement.bff.rs.internal.model.AnnouncementPageResultDTO; + +@Mapper(uses = OffsetDateTimeMapper.class) +public interface ResponseMapper { + + @Mapping(target = "version", ignore = true) + AnnouncementDTO mapAnnouncementToAnnouncementDTO(Announcement announcement); + + @Mapping(target = "removeStreamItem", ignore = true) + AnnouncementPageResultDTO mapAnnouncementPageResultToAnnouncementPageResultDTO( + AnnouncementPageResult announcementPageResult); + +} diff --git a/src/main/openapi/openapi-announcement-bff.yaml b/src/main/openapi/openapi-announcement-bff.yaml new file mode 100644 index 0000000..0de84ba --- /dev/null +++ b/src/main/openapi/openapi-announcement-bff.yaml @@ -0,0 +1,345 @@ +openapi: "3.0.3" +info: + title: onecx-announcement-bff + version: "1.0" +servers: + - url: https://onecx-announcement-bff:8080 +tags: + - name: AnnouncementInternal + description: Execute Announcement CRUD operations +paths: + /announcements/search: + post: + tags: + - AnnouncementInternal + summary: Find announcements by criteria + operationId: getAnnouncements + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/SearchAnnouncementRequest' + 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: + post: + tags: + - AnnouncementInternal + summary: Add announcement + operationId: addAnnouncement + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateAnnouncementRequest' + responses: + "201": + description: OK + headers: + Location: + required: true + schema: + type: string + format: url + content: + application/json: + schema: + $ref: '#/components/schemas/Announcement' + "400": + description: Bad request + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetailResponse' + /announcements/appIds: + get: + tags: + - AnnouncementInternal + summary: Get all application IDs to which announcements are assigned + operationId: getAllAppsWithAnnouncements + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/AnnouncementApps' + /announcements/{id}: + get: + tags: + - AnnouncementInternal + summary: Retrieve announcement by id + operationId: getAnnouncementById + parameters: + - name: id + in: path + required: true + schema: + type: string + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/Announcement' + delete: + tags: + - AnnouncementInternal + summary: Delete announcement + operationId: deleteAnnouncementById + parameters: + - name: id + in: path + required: true + schema: + type: string + responses: + "204": + description: No content + "400": + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetailResponse' + put: + tags: + - AnnouncementInternal + summary: Patch/update announcement + operationId: updateAnnouncementById + parameters: + - name: id + in: path + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateAnnouncementRequest' + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/Announcement' + "400": + description: Bad request + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetailResponse' +components: + schemas: + AnnouncementApps: + type: object + properties: + appIds: + type: array + items: + type: string + CreateAnnouncementRequest: + type: object + properties: + title: + type: string + content: + type: string + type: + $ref: '#/components/schemas/AnnouncementType' + priority: + $ref: '#/components/schemas/AnnouncementPriorityType' + status: + $ref: '#/components/schemas/AnnouncementStatus' + startDate: + $ref: '#/components/schemas/OffsetDateTime' + endDate: + $ref: '#/components/schemas/OffsetDateTime' + appId: + type: string + SearchAnnouncementRequest: + 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: + 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 + UpdateAnnouncementRequest: + type: object + properties: + title: + type: string + content: + type: string + type: + $ref: '#/components/schemas/AnnouncementType' + priority: + $ref: '#/components/schemas/AnnouncementPriorityType' + status: + $ref: '#/components/schemas/AnnouncementStatus' + startDate: + $ref: '#/components/schemas/OffsetDateTime' + endDate: + $ref: '#/components/schemas/OffsetDateTime' + appId: + type: string + Announcement: + type: object + properties: + version: + format: int32 + type: integer + creationDate: + $ref: '#/components/schemas/OffsetDateTime' + creationUser: + type: string + modificationDate: + $ref: '#/components/schemas/OffsetDateTime' + modificationUser: + type: string + id: + type: string + title: + type: string + content: + type: string + type: + $ref: '#/components/schemas/AnnouncementType' + priority: + $ref: '#/components/schemas/AnnouncementPriorityType' + status: + $ref: '#/components/schemas/AnnouncementStatus' + startDate: + $ref: '#/components/schemas/OffsetDateTime' + endDate: + $ref: '#/components/schemas/OffsetDateTime' + appId: + type: string + AnnouncementPageResult: + type: object + properties: + totalElements: + format: int64 + description: The total elements in the resource. + type: integer + number: + format: int32 + type: integer + size: + format: int32 + type: integer + totalPages: + format: int64 + type: integer + stream: + type: array + items: + $ref: '#/components/schemas/Announcement' + AnnouncementPriorityType: + enum: + - IMPORTANT + - NORMAL + - LOW + type: string + AnnouncementStatus: + enum: + - ACTIVE + - INACTIVE + type: string + AnnouncementType: + enum: + - EVENT + - INFO + - SYSTEM_MAINTENANCE + type: string + OffsetDateTime: + format: date-time + type: string + example: 2022-03-10T12:15:50-04:00 + ProblemDetailResponse: + type: object + properties: + errorCode: + type: string + detail: + type: string + params: + type: array + items: + $ref: '#/components/schemas/ProblemDetailParam' + invalidParams: + type: array + items: + $ref: '#/components/schemas/ProblemDetailInvalidParam' + ProblemDetailParam: + type: object + properties: + key: + type: string + value: + type: string + ProblemDetailInvalidParam: + type: object + properties: + name: + type: string + message: + type: string \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..4822e87 --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,20 @@ +# PROD +%prod.quarkus.rest-client.onecx_announcement_svc.url=http://onecx-announcement-svc:8080 +# BUILD +quarkus.openapi-generator.codegen.input-base-dir=target/tmp/openapi +quarkus.openapi-generator.codegen.spec.onecx_announcement_svc_yaml.config-key=onecx_announcement_svc +quarkus.openapi-generator.codegen.spec.onecx_announcement_svc_yaml.base-package=gen.io.github.onecx.announcement.bff.clients +quarkus.openapi-generator.codegen.spec.onecx_announcement_svc_yaml.return-response=true +#DEV +%dev.quarkus.rest-client.onecx_announcement_svc.url=http://onecx-announcement-svc +# INTEGRATION TEST +quarkus.test.integration-test-profile=test +# TEST +%test.quarkus.http.test-port=0 +%test.tkit.log.json.enabled=false +%test.quarkus.mockserver.devservices.config-class-path=true +%test.quarkus.mockserver.devservices.log=false +%test.quarkus.mockserver.devservices.reuse=true +%test.quarkus.mockserver.devservices.config-file=/mockserver.properties +%test.quarkus.mockserver.devservices.config-dir=/mockserver +%test.quarkus.rest-client.onecx_announcement_svc.url=${quarkus.mockserver.endpoint} \ No newline at end of file diff --git a/src/test/java/io/github/onecx/announcement/bff/rs/AbstractTest.java b/src/test/java/io/github/onecx/announcement/bff/rs/AbstractTest.java new file mode 100644 index 0000000..154ce3e --- /dev/null +++ b/src/test/java/io/github/onecx/announcement/bff/rs/AbstractTest.java @@ -0,0 +1,26 @@ +package io.github.onecx.announcement.bff.rs; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; + +import io.quarkiverse.mockserver.test.MockServerTestResource; +import io.quarkus.test.common.QuarkusTestResource; +import io.restassured.RestAssured; +import io.restassured.config.ObjectMapperConfig; +import io.restassured.config.RestAssuredConfig; + +@QuarkusTestResource(MockServerTestResource.class) +public abstract class AbstractTest { + + static { + RestAssured.config = RestAssuredConfig.config().objectMapperConfig( + ObjectMapperConfig.objectMapperConfig().jackson2ObjectMapperFactory( + (cls, charset) -> { + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.registerModule(new JavaTimeModule()); + objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); + return objectMapper; + })); + } +} diff --git a/src/test/java/io/github/onecx/announcement/bff/rs/AnnouncementRestControllerTest.java b/src/test/java/io/github/onecx/announcement/bff/rs/AnnouncementRestControllerTest.java new file mode 100644 index 0000000..bd1f799 --- /dev/null +++ b/src/test/java/io/github/onecx/announcement/bff/rs/AnnouncementRestControllerTest.java @@ -0,0 +1,310 @@ +package io.github.onecx.announcement.bff.rs; + +import static io.restassured.RestAssured.given; +import static jakarta.ws.rs.core.MediaType.APPLICATION_JSON; +import static org.mockserver.model.HttpRequest.request; +import static org.mockserver.model.HttpResponse.response; + +import java.util.ArrayList; +import java.util.List; + +import jakarta.ws.rs.HttpMethod; +import jakarta.ws.rs.core.Response; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.mockserver.client.MockServerClient; +import org.mockserver.model.JsonBody; +import org.mockserver.model.MediaType; + +import gen.io.github.onecx.announcement.bff.clients.model.*; +import gen.io.github.onecx.announcement.bff.rs.internal.model.*; +import io.github.onecx.announcement.bff.rs.controller.AnnouncementRestController; +import io.quarkiverse.mockserver.test.InjectMockServerClient; +import io.quarkus.test.common.http.TestHTTPEndpoint; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +@TestHTTPEndpoint(AnnouncementRestController.class) +public class AnnouncementRestControllerTest extends AbstractTest { + + private static final String ANNOUNCEMENT_SVC_INTERNAL_API_BASE_PATH = "/internal/announcements"; + + @InjectMockServerClient + MockServerClient mockServerClient; + + @AfterEach + void resetMockserver() { + mockServerClient.reset(); + } + + @Test + void addAnnouncement_shouldReturnAnnouncement() { + + // Request data to svc + Announcement data = new Announcement(); + data.setAppId("appId"); + data.setContent("AnnouncmentContent"); + + // svc call prepare mock endpoint + mockServerClient + .when(request().withPath(ANNOUNCEMENT_SVC_INTERNAL_API_BASE_PATH) + .withMethod(HttpMethod.POST)) + .withPriority(100) + .respond(httpRequest -> response().withStatusCode(Response.Status.OK.getStatusCode()) + .withContentType(MediaType.APPLICATION_JSON) + .withBody(JsonBody.json(data))); + + // bff call input + CreateAnnouncementRequestDTO input = new CreateAnnouncementRequestDTO(); + input.setAppId("appId1"); + + // bff call + var response = given() + .when() + .contentType(APPLICATION_JSON) + .body(input) + .post() + .then() + .statusCode(Response.Status.OK.getStatusCode()) + .contentType(APPLICATION_JSON) + .extract().as(AnnouncementDTO.class); + + // Assertions + Assertions.assertNotNull(response); + Assertions.assertEquals(data.getAppId(), response.getAppId()); + Assertions.assertEquals(data.getContent(), response.getContent()); + } + + @Test + void getAnnouncements_shouldReturnAnnouncementPageResults() { + Announcement announcement = new Announcement(); + announcement.setAppId("appId"); + announcement.setContent("AnnouncmentContent"); + List announcements = new ArrayList<>(); + announcements.add(announcement); + + // 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 + mockServerClient + .when(request().withPath(ANNOUNCEMENT_SVC_INTERNAL_API_BASE_PATH + "/search") + .withMethod(HttpMethod.POST)) + .withPriority(100) + .respond(httpRequest -> response().withStatusCode(Response.Status.OK.getStatusCode()) + .withContentType(MediaType.APPLICATION_JSON) + .withBody(JsonBody.json(data))); + + // bff call input + AnnouncementSearchCriteria input = new AnnouncementSearchCriteria(); + + // bff call + var response = given() + .when() + .contentType(APPLICATION_JSON) + .body(input) + .post("/search") + .then() + .statusCode(Response.Status.OK.getStatusCode()) + .contentType(APPLICATION_JSON) + .extract().as(AnnouncementPageResult.class); + + // Assertions + Assertions.assertNotNull(response); + Assertions.assertEquals(data.getNumber(), response.getNumber()); + Assertions.assertEquals(data.getSize(), response.getSize()); + Assertions.assertEquals(data.getStream().size(), 1); + Assertions.assertEquals(data.getStream().get(0), announcement); + } + + @Test + void getAnnouncementById_shouldReturnAnnouncement() { + // Request data to svc + Announcement data = new Announcement(); + data.setAppId("appIdTest1"); + + // svc call prepare mock endpoint + mockServerClient + .when(request() + .withPath(ANNOUNCEMENT_SVC_INTERNAL_API_BASE_PATH + "/1") + .withMethod(HttpMethod.GET)) + .withPriority(100) + .respond( + httpRequest -> response() + .withStatusCode(Response.Status.OK.getStatusCode()) + .withContentType(MediaType.APPLICATION_JSON) + .withBody(JsonBody.json(data))); + + // bff call + var response = given() + .when() + .contentType(APPLICATION_JSON) + .get("/1") + .then() + .statusCode(Response.Status.OK.getStatusCode()) + .contentType(APPLICATION_JSON) + .extract().as(AnnouncementDTO.class); + + // Assertions + Assertions.assertNotNull(response); + Assertions.assertEquals("appIdTest1", response.getAppId()); + } + + @Test + void getAllAppsWithAnnouncements_shouldReturnAnnouncementApps() { + // Request data to svc + AnnouncementApps data = new AnnouncementApps(); + List appIds = new ArrayList<>(); + appIds.add("1"); + appIds.add("2"); + data.setAppIds(appIds); + + // svc call prepare mock endpoint + mockServerClient + .when(request() + .withPath(ANNOUNCEMENT_SVC_INTERNAL_API_BASE_PATH + "/appIds") + .withMethod(HttpMethod.GET)) + .withPriority(100) + .respond( + httpRequest -> response() + .withStatusCode(Response.Status.OK.getStatusCode()) + .withContentType(MediaType.APPLICATION_JSON) + .withBody(JsonBody.json(data))); + + System.out.println("ARRAY: " + data); + + // bff call + var response = given() + .when() + .contentType(APPLICATION_JSON) + .get("/appIds") + .then() + .statusCode(Response.Status.OK.getStatusCode()) + .contentType(APPLICATION_JSON) + .extract().as(AnnouncementApps.class); + + // Assertions + Assertions.assertNotNull(response); + Assertions.assertEquals(response.getAppIds().size(), 2); + Assertions.assertEquals(response.getAppIds(), data.getAppIds()); + + } + + @Test + void getAnnouncementById_shouldReturnNotFound() { + + String idNotFound = "notFoundId"; + + ProblemDetailResponse problemDetailResponse = new ProblemDetailResponse(); + problemDetailResponse.setErrorCode("404"); + // svc call prepare mock endpoint + mockServerClient + .when(request() + .withPath(ANNOUNCEMENT_SVC_INTERNAL_API_BASE_PATH + "/" + idNotFound) + .withMethod(HttpMethod.GET)) + .withPriority(100) + .respond( + httpRequest -> response() + .withStatusCode(Response.Status.NOT_FOUND.getStatusCode()) + .withContentType(MediaType.APPLICATION_JSON)); + + // bff call + given() + .when() + .contentType(APPLICATION_JSON) + .get(idNotFound) + .then() + .statusCode(Response.Status.NOT_FOUND.getStatusCode()); + + } + + @Test + void deleteAnnouncementById() { + + String deleteId = "deleteId_NO_CONTENT"; + + mockServerClient + .when(request() + .withPath(ANNOUNCEMENT_SVC_INTERNAL_API_BASE_PATH + "/" + deleteId) + .withMethod(HttpMethod.DELETE)) + .withPriority(100) + .respond( + httpRequest -> response() + .withStatusCode(Response.Status.NO_CONTENT.getStatusCode())); + + // bff call + var response = given() + .when() + .contentType(APPLICATION_JSON) + .delete(deleteId) + .then() + .statusCode(Response.Status.NO_CONTENT.getStatusCode()); + + // Assertions + Assertions.assertNotNull(response); + } + + @Test + void updateAnnouncementById() { + String updateId = "updateId_NO_CONTENT"; + Announcement data = new Announcement(); + data.setAppId("appIdTest1"); + + mockServerClient + .when(request() + .withPath(ANNOUNCEMENT_SVC_INTERNAL_API_BASE_PATH + "/" + updateId) + .withMethod(HttpMethod.PUT)) + .withPriority(100) + .respond( + httpRequest -> response() + .withStatusCode(Response.Status.OK.getStatusCode()) + .withBody(JsonBody.json(data))); + + UpdateAnnouncementRequestDTO input = new UpdateAnnouncementRequestDTO(); + // bff call + given() + .when() + .contentType(APPLICATION_JSON) + .body(input) + .put(updateId) + .then() + .statusCode(Response.Status.OK.getStatusCode()); + + } + + @Test + void updateAnnouncementById_shouldReturnBadRequest() { + String updateId = "updateId_NO_CONTENT"; + ProblemDetailResponse problemDetailResponse = new ProblemDetailResponse(); + problemDetailResponse.setErrorCode("400"); + + mockServerClient + .when(request() + .withPath(ANNOUNCEMENT_SVC_INTERNAL_API_BASE_PATH + "/" + updateId) + .withMethod(HttpMethod.PUT)) + .withPriority(100) + .respond( + httpRequest -> response() + .withStatusCode(Response.Status.BAD_REQUEST.getStatusCode()) + .withBody(JsonBody.json(problemDetailResponse))); + ; + + UpdateAnnouncementRequestDTO input = new UpdateAnnouncementRequestDTO(); + // bff call + given() + .when() + .contentType(APPLICATION_JSON) + .body(input) + .put(updateId) + .then() + .statusCode(Response.Status.BAD_REQUEST.getStatusCode()) + .extract().as(ProblemDetailResponseDTO.class); + + } +} diff --git a/src/test/resources/mockserver.properties b/src/test/resources/mockserver.properties new file mode 100644 index 0000000..2a5ad57 --- /dev/null +++ b/src/test/resources/mockserver.properties @@ -0,0 +1,16 @@ +mockserver.initializationJsonPath=/mockserver/*.json +# watch changes in the file +mockserver.watchInitializationJson=true + + +# Certificate Generation +# dynamically generated CA key pair (if they don't already exist in specified directory) +mockserver.dynamicallyCreateCertificateAuthorityCertificate=true +# save dynamically generated CA key pair in working directory +mockserver.directoryToSaveDynamicSSLCertificate=. +# certificate domain name (default "localhost") +mockserver.sslCertificateDomainName=localhost +# comma separated list of ip addresses for Subject Alternative Name domain names (default empty list) +mockserver.sslSubjectAlternativeNameDomains=www.example.com,www.another.com +# comma separated list of ip addresses for Subject Alternative Name ips (default empty list) +mockserver.sslSubjectAlternativeNameIps=127.0.0.1 \ No newline at end of file diff --git a/src/test/resources/mockserver/internal.json b/src/test/resources/mockserver/internal.json new file mode 100644 index 0000000..e69de29 From 3208ca3caa90f2010d31ef97990fc7d6ce015dde Mon Sep 17 00:00:00 2001 From: Jannik Steenken Date: Sun, 7 Jan 2024 20:18:31 +0100 Subject: [PATCH 02/12] feat: test added --- .../rs/AnnouncementRestControllerTest.java | 41 +++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/src/test/java/io/github/onecx/announcement/bff/rs/AnnouncementRestControllerTest.java b/src/test/java/io/github/onecx/announcement/bff/rs/AnnouncementRestControllerTest.java index bd1f799..f281471 100644 --- a/src/test/java/io/github/onecx/announcement/bff/rs/AnnouncementRestControllerTest.java +++ b/src/test/java/io/github/onecx/announcement/bff/rs/AnnouncementRestControllerTest.java @@ -27,7 +27,7 @@ @QuarkusTest @TestHTTPEndpoint(AnnouncementRestController.class) -public class AnnouncementRestControllerTest extends AbstractTest { +class AnnouncementRestControllerTest extends AbstractTest { private static final String ANNOUNCEMENT_SVC_INTERNAL_API_BASE_PATH = "/internal/announcements"; @@ -119,7 +119,7 @@ void getAnnouncements_shouldReturnAnnouncementPageResults() { Assertions.assertNotNull(response); Assertions.assertEquals(data.getNumber(), response.getNumber()); Assertions.assertEquals(data.getSize(), response.getSize()); - Assertions.assertEquals(data.getStream().size(), 1); + Assertions.assertEquals(1, data.getStream().size()); Assertions.assertEquals(data.getStream().get(0), announcement); } @@ -191,7 +191,7 @@ void getAllAppsWithAnnouncements_shouldReturnAnnouncementApps() { // Assertions Assertions.assertNotNull(response); - Assertions.assertEquals(response.getAppIds().size(), 2); + Assertions.assertEquals(2, response.getAppIds().size()); Assertions.assertEquals(response.getAppIds(), data.getAppIds()); } @@ -307,4 +307,39 @@ void updateAnnouncementById_shouldReturnBadRequest() { .extract().as(ProblemDetailResponseDTO.class); } + + @Test + void addAnnouncements_shouldReturnBadRequest_whenRunningIntoValidationConstraints() { + + ProblemDetailResponse data = new ProblemDetailResponse(); + data.setErrorCode("CONSTRAINT_VIOLATIONS"); + data.setDetail( + "createProduct.arg0.name: must not be null"); + List list = new ArrayList<>(); + ProblemDetailInvalidParam param1 = new ProblemDetailInvalidParam(); + param1.setName("createProduct.arg0.name"); + param1.setMessage("must not be null"); + list.add(param1); + data.setParams(null); + data.setInvalidParams(list); + + mockServerClient.when(request().withPath(ANNOUNCEMENT_SVC_INTERNAL_API_BASE_PATH).withMethod(HttpMethod.POST)) + .withPriority(100) + .respond(httpRequest -> response().withStatusCode(Response.Status.BAD_REQUEST.getStatusCode()) + .withContentType(MediaType.APPLICATION_JSON) + .withBody(JsonBody.json(data))); + + CreateAnnouncementRequestDTO emptyRequestDTO; + + var response = given() + .when() + .contentType(APPLICATION_JSON) + .post() + .then() + .statusCode(Response.Status.BAD_REQUEST.getStatusCode()) + .contentType(APPLICATION_JSON) + .extract().as(ProblemDetailResponseDTO.class); + + Assertions.assertNotNull(response); + } } From 163eed4c4e484d4f407c1ce8e9162455299d088e Mon Sep 17 00:00:00 2001 From: Jannik Steenken Date: Mon, 8 Jan 2024 11:32:51 +0100 Subject: [PATCH 03/12] feat: update swagger AnnouncementSearchCriteriaDTO --- .../AnnouncementRestController.java | 4 +- .../bff/rs/mappers/AnnouncementMapper.java | 2 +- .../openapi/openapi-announcement-bff.yaml | 37 ++++++++++++++++++- src/main/resources/application.properties | 19 ++++++++-- 4 files changed, 53 insertions(+), 9 deletions(-) diff --git a/src/main/java/io/github/onecx/announcement/bff/rs/controller/AnnouncementRestController.java b/src/main/java/io/github/onecx/announcement/bff/rs/controller/AnnouncementRestController.java index 7cfa37c..73bbb21 100644 --- a/src/main/java/io/github/onecx/announcement/bff/rs/controller/AnnouncementRestController.java +++ b/src/main/java/io/github/onecx/announcement/bff/rs/controller/AnnouncementRestController.java @@ -78,10 +78,10 @@ public Response getAnnouncementById(String id) { } @Override - public Response getAnnouncements(SearchAnnouncementRequestDTO searchAnnouncementRequestDTO) { + public Response getAnnouncements(AnnouncementSearchCriteriaDTO announcementSearchCriteriaDTO) { try (Response response = client - .getAnnouncements(announcementMapper.mapAnnouncementSearchCriteria(searchAnnouncementRequestDTO))) { + .getAnnouncements(announcementMapper.mapAnnouncementSearchCriteria(announcementSearchCriteriaDTO))) { AnnouncementPageResult announcementPageResult = response.readEntity(AnnouncementPageResult.class); AnnouncementPageResultDTO announcementPageResultDTO = announcementMapper .mapAnnouncementPageResultToAnnouncementPageResultDTO(announcementPageResult); diff --git a/src/main/java/io/github/onecx/announcement/bff/rs/mappers/AnnouncementMapper.java b/src/main/java/io/github/onecx/announcement/bff/rs/mappers/AnnouncementMapper.java index 159f74e..516d3e8 100644 --- a/src/main/java/io/github/onecx/announcement/bff/rs/mappers/AnnouncementMapper.java +++ b/src/main/java/io/github/onecx/announcement/bff/rs/mappers/AnnouncementMapper.java @@ -14,7 +14,7 @@ public interface AnnouncementMapper { UpdateAnnouncementRequest mapUpdateAnnouncement(UpdateAnnouncementRequestDTO updateAnnouncementRequestDTO); - AnnouncementSearchCriteria mapAnnouncementSearchCriteria(SearchAnnouncementRequestDTO searchAnnouncementRequestDTO); + AnnouncementSearchCriteria mapAnnouncementSearchCriteria(AnnouncementSearchCriteriaDTO searchAnnouncementRequestDTO); @Mapping(target = "version", ignore = true) AnnouncementDTO mapAnnouncementToAnnouncementDTO(Announcement announcement); diff --git a/src/main/openapi/openapi-announcement-bff.yaml b/src/main/openapi/openapi-announcement-bff.yaml index 0de84ba..ce7ad78 100644 --- a/src/main/openapi/openapi-announcement-bff.yaml +++ b/src/main/openapi/openapi-announcement-bff.yaml @@ -19,7 +19,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/SearchAnnouncementRequest' + $ref: '#/components/schemas/AnnouncementSearchCriteria' responses: "200": description: OK @@ -342,4 +342,37 @@ components: name: type: string message: - type: string \ No newline at end of file + 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 \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 4822e87..491aa02 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,14 +1,23 @@ +# DEFAULT +tkit.log.json.enabled=false +tkit.log.json.pretty-print=false +tkit.log.json.print-details=false + # PROD %prod.quarkus.rest-client.onecx_announcement_svc.url=http://onecx-announcement-svc:8080 + +# DEV +%dev.quarkus.rest-client.onecx_announcement_svc.url=http://onecx-announcement-svc + # BUILD -quarkus.openapi-generator.codegen.input-base-dir=target/tmp/openapi quarkus.openapi-generator.codegen.spec.onecx_announcement_svc_yaml.config-key=onecx_announcement_svc quarkus.openapi-generator.codegen.spec.onecx_announcement_svc_yaml.base-package=gen.io.github.onecx.announcement.bff.clients quarkus.openapi-generator.codegen.spec.onecx_announcement_svc_yaml.return-response=true -#DEV -%dev.quarkus.rest-client.onecx_announcement_svc.url=http://onecx-announcement-svc +quarkus.openapi-generator.codegen.input-base-dir=target/tmp/openapi + # INTEGRATION TEST quarkus.test.integration-test-profile=test + # TEST %test.quarkus.http.test-port=0 %test.tkit.log.json.enabled=false @@ -17,4 +26,6 @@ quarkus.test.integration-test-profile=test %test.quarkus.mockserver.devservices.reuse=true %test.quarkus.mockserver.devservices.config-file=/mockserver.properties %test.quarkus.mockserver.devservices.config-dir=/mockserver -%test.quarkus.rest-client.onecx_announcement_svc.url=${quarkus.mockserver.endpoint} \ No newline at end of file +%test.quarkus.rest-client.onecx_announcement_svc.url=${quarkus.mockserver.endpoint} + +# PIPE CONFIG \ No newline at end of file From 9c302221f80fd9565d07cd691b1683dacc6b5a61 Mon Sep 17 00:00:00 2001 From: Jannik Steenken Date: Tue, 9 Jan 2024 12:30:00 +0100 Subject: [PATCH 04/12] feat: update pom --- pom.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pom.xml b/pom.xml index ad407cc..0fba9ae 100644 --- a/pom.xml +++ b/pom.xml @@ -66,6 +66,18 @@ io.quarkus quarkus-hibernate-validator + + io.quarkus + quarkus-smallrye-health + + + io.quarkus + quarkus-opentelemetry + + + io.quarkus + quarkus-micrometer-registry-prometheus + io.quarkiverse.mockserver From 8b232ab9dce7671f328fcb2629dcb4c65c08c751 Mon Sep 17 00:00:00 2001 From: Jannik Steenken Date: Tue, 9 Jan 2024 12:32:45 +0100 Subject: [PATCH 05/12] feat: update properties --- src/main/resources/application.properties | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 491aa02..5aee6fb 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,8 +1,3 @@ -# DEFAULT -tkit.log.json.enabled=false -tkit.log.json.pretty-print=false -tkit.log.json.print-details=false - # PROD %prod.quarkus.rest-client.onecx_announcement_svc.url=http://onecx-announcement-svc:8080 From b35146eda439268945333306df8734610c6ce437 Mon Sep 17 00:00:00 2001 From: Jannik Steenken Date: Fri, 12 Jan 2024 17:01:26 +0100 Subject: [PATCH 06/12] feat: helm settings --- src/main/helm/Chart.yaml | 2 +- src/main/helm/values.yaml | 24 ++++++++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/main/helm/Chart.yaml b/src/main/helm/Chart.yaml index 0de0e3b..93f911f 100644 --- a/src/main/helm/Chart.yaml +++ b/src/main/helm/Chart.yaml @@ -1,4 +1,4 @@ -apiVersion: v1 +apiVersion: v2 name: onecx-announcement-bff version: 0.0.0 appVersion: 0.0.0 diff --git a/src/main/helm/values.yaml b/src/main/helm/values.yaml index 02bc384..dee8056 100644 --- a/src/main/helm/values.yaml +++ b/src/main/helm/values.yaml @@ -1,6 +1,18 @@ -app: - image: - repository: "onecx/onecx-announcement-bff" - tag: 999-SNAPSHOT - db: - enabled: true \ No newline at end of file +apiVersion: v2 +name: onecx-announcement-bff +version: 0.0.0 +appVersion: 0.0.0 +description: Onecx announcement management bff +keywords: + - iam + - parameters +sources: + - https://github.com/onecx/onecx-announcement-bff +maintainers: + - name: Tkit Developer + email: tkit_dev@1000kit.org +dependencies: + - name: helm-quarkus-app + alias: app + version: ^0 + repository: oci://ghcr.io/onecx/charts \ No newline at end of file From 24fc2f4c18e13406fac4e4341da7a4e685c14deb Mon Sep 17 00:00:00 2001 From: Jannik Steenken Date: Mon, 15 Jan 2024 12:48:37 +0100 Subject: [PATCH 07/12] fix: change search return PageResult --- src/main/openapi/openapi-announcement-bff.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/openapi/openapi-announcement-bff.yaml b/src/main/openapi/openapi-announcement-bff.yaml index ce7ad78..9852e34 100644 --- a/src/main/openapi/openapi-announcement-bff.yaml +++ b/src/main/openapi/openapi-announcement-bff.yaml @@ -26,7 +26,6 @@ paths: content: application/json: schema: - type: array items: $ref: '#/components/schemas/AnnouncementPageResult' "400": From 4fcadec8553da0b584fec6f1585786325c4dc65f Mon Sep 17 00:00:00 2001 From: Jannik Steenken Date: Mon, 15 Jan 2024 16:29:54 +0100 Subject: [PATCH 08/12] fix: update method error response --- .../bff/rs/controller/AnnouncementRestController.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/main/java/io/github/onecx/announcement/bff/rs/controller/AnnouncementRestController.java b/src/main/java/io/github/onecx/announcement/bff/rs/controller/AnnouncementRestController.java index 73bbb21..6a1319c 100644 --- a/src/main/java/io/github/onecx/announcement/bff/rs/controller/AnnouncementRestController.java +++ b/src/main/java/io/github/onecx/announcement/bff/rs/controller/AnnouncementRestController.java @@ -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; @@ -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(); } } From 63f00aac5d2c96897ef489e112fbc0c3cf4f8ade Mon Sep 17 00:00:00 2001 From: Jannik Steenken Date: Tue, 16 Jan 2024 10:53:28 +0100 Subject: [PATCH 09/12] feat: update openapi validation --- .../AnnouncementRestController.java | 2 +- .../bff/rs/mappers/AnnouncementMapper.java | 1 - .../bff/rs/mappers/ResponseMapper.java | 22 ------ .../openapi/openapi-announcement-bff.yaml | 71 ++++--------------- .../rs/AnnouncementRestControllerTest.java | 18 ++++- 5 files changed, 30 insertions(+), 84 deletions(-) delete mode 100644 src/main/java/io/github/onecx/announcement/bff/rs/mappers/ResponseMapper.java diff --git a/src/main/java/io/github/onecx/announcement/bff/rs/controller/AnnouncementRestController.java b/src/main/java/io/github/onecx/announcement/bff/rs/controller/AnnouncementRestController.java index 6a1319c..992b5a7 100644 --- a/src/main/java/io/github/onecx/announcement/bff/rs/controller/AnnouncementRestController.java +++ b/src/main/java/io/github/onecx/announcement/bff/rs/controller/AnnouncementRestController.java @@ -39,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))) { diff --git a/src/main/java/io/github/onecx/announcement/bff/rs/mappers/AnnouncementMapper.java b/src/main/java/io/github/onecx/announcement/bff/rs/mappers/AnnouncementMapper.java index 516d3e8..34d59f4 100644 --- a/src/main/java/io/github/onecx/announcement/bff/rs/mappers/AnnouncementMapper.java +++ b/src/main/java/io/github/onecx/announcement/bff/rs/mappers/AnnouncementMapper.java @@ -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) diff --git a/src/main/java/io/github/onecx/announcement/bff/rs/mappers/ResponseMapper.java b/src/main/java/io/github/onecx/announcement/bff/rs/mappers/ResponseMapper.java deleted file mode 100644 index 3982fcc..0000000 --- a/src/main/java/io/github/onecx/announcement/bff/rs/mappers/ResponseMapper.java +++ /dev/null @@ -1,22 +0,0 @@ -package io.github.onecx.announcement.bff.rs.mappers; - -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.tkit.quarkus.rs.mappers.OffsetDateTimeMapper; - -import gen.io.github.onecx.announcement.bff.clients.model.Announcement; -import gen.io.github.onecx.announcement.bff.clients.model.AnnouncementPageResult; -import gen.io.github.onecx.announcement.bff.rs.internal.model.AnnouncementDTO; -import gen.io.github.onecx.announcement.bff.rs.internal.model.AnnouncementPageResultDTO; - -@Mapper(uses = OffsetDateTimeMapper.class) -public interface ResponseMapper { - - @Mapping(target = "version", ignore = true) - AnnouncementDTO mapAnnouncementToAnnouncementDTO(Announcement announcement); - - @Mapping(target = "removeStreamItem", ignore = true) - AnnouncementPageResultDTO mapAnnouncementPageResultToAnnouncementPageResultDTO( - AnnouncementPageResult announcementPageResult); - -} diff --git a/src/main/openapi/openapi-announcement-bff.yaml b/src/main/openapi/openapi-announcement-bff.yaml index 9852e34..0818401 100644 --- a/src/main/openapi/openapi-announcement-bff.yaml +++ b/src/main/openapi/openapi-announcement-bff.yaml @@ -26,6 +26,7 @@ paths: content: application/json: schema: + type: array items: $ref: '#/components/schemas/AnnouncementPageResult' "400": @@ -38,8 +39,8 @@ paths: post: tags: - AnnouncementInternal - summary: Add announcement - operationId: addAnnouncement + summary: Create announcement + operationId: createAnnouncement requestBody: required: true content: @@ -111,12 +112,6 @@ paths: responses: "204": description: No content - "400": - description: Bad Request - content: - application/json: - schema: - $ref: '#/components/schemas/ProblemDetailResponse' put: tags: - AnnouncementInternal @@ -129,6 +124,7 @@ paths: schema: type: string requestBody: + required: true content: application/json: schema: @@ -157,6 +153,9 @@ components: type: string CreateAnnouncementRequest: type: object + required: + - title + - startDate properties: title: type: string @@ -174,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: @@ -223,6 +208,9 @@ components: type: integer UpdateAnnouncementRequest: type: object + required: + - title + - startDate properties: title: type: string @@ -243,7 +231,7 @@ components: Announcement: type: object properties: - version: + modificationCount: format: int32 type: integer creationDate: @@ -341,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 \ No newline at end of file + type: string \ No newline at end of file diff --git a/src/test/java/io/github/onecx/announcement/bff/rs/AnnouncementRestControllerTest.java b/src/test/java/io/github/onecx/announcement/bff/rs/AnnouncementRestControllerTest.java index f281471..9c0f187 100644 --- a/src/test/java/io/github/onecx/announcement/bff/rs/AnnouncementRestControllerTest.java +++ b/src/test/java/io/github/onecx/announcement/bff/rs/AnnouncementRestControllerTest.java @@ -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; @@ -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.*; @@ -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 @@ -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() @@ -79,6 +87,7 @@ void addAnnouncement_shouldReturnAnnouncement() { @Test void getAnnouncements_shouldReturnAnnouncementPageResults() { + Announcement announcement = new Announcement(); announcement.setAppId("appId"); announcement.setContent("AnnouncmentContent"); @@ -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"); @@ -267,6 +279,8 @@ void updateAnnouncementById() { .withBody(JsonBody.json(data))); UpdateAnnouncementRequestDTO input = new UpdateAnnouncementRequestDTO(); + input.setStartDate(offsetDateTime); + input.setTitle("appTitle"); // bff call given() .when() @@ -309,7 +323,7 @@ void updateAnnouncementById_shouldReturnBadRequest() { } @Test - void addAnnouncements_shouldReturnBadRequest_whenRunningIntoValidationConstraints() { + void createAnnouncement_shouldReturnBadRequest_whenRunningIntoValidationConstraints() { ProblemDetailResponse data = new ProblemDetailResponse(); data.setErrorCode("CONSTRAINT_VIOLATIONS"); From 7a5c832d135673385bc20b68c06bca67b695acbd Mon Sep 17 00:00:00 2001 From: Jannik Steenken Date: Wed, 17 Jan 2024 11:50:14 +0100 Subject: [PATCH 10/12] fix: helm files changes --- src/main/helm/values.yaml | 24 ++++++----------------- src/main/resources/application.properties | 1 + 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/main/helm/values.yaml b/src/main/helm/values.yaml index dee8056..02bc384 100644 --- a/src/main/helm/values.yaml +++ b/src/main/helm/values.yaml @@ -1,18 +1,6 @@ -apiVersion: v2 -name: onecx-announcement-bff -version: 0.0.0 -appVersion: 0.0.0 -description: Onecx announcement management bff -keywords: - - iam - - parameters -sources: - - https://github.com/onecx/onecx-announcement-bff -maintainers: - - name: Tkit Developer - email: tkit_dev@1000kit.org -dependencies: - - name: helm-quarkus-app - alias: app - version: ^0 - repository: oci://ghcr.io/onecx/charts \ No newline at end of file +app: + image: + repository: "onecx/onecx-announcement-bff" + tag: 999-SNAPSHOT + db: + enabled: true \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 5aee6fb..8640eec 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -9,6 +9,7 @@ quarkus.openapi-generator.codegen.spec.onecx_announcement_svc_yaml.config-key=on quarkus.openapi-generator.codegen.spec.onecx_announcement_svc_yaml.base-package=gen.io.github.onecx.announcement.bff.clients quarkus.openapi-generator.codegen.spec.onecx_announcement_svc_yaml.return-response=true quarkus.openapi-generator.codegen.input-base-dir=target/tmp/openapi +quarkus.log.level=DEBUG # INTEGRATION TEST quarkus.test.integration-test-profile=test From da78408a32e380eccc2b178d1a022da35a3d1298 Mon Sep 17 00:00:00 2001 From: Jannik Steenken Date: Wed, 17 Jan 2024 11:53:16 +0100 Subject: [PATCH 11/12] fix: log level delete --- src/main/resources/application.properties | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 8640eec..5aee6fb 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -9,7 +9,6 @@ quarkus.openapi-generator.codegen.spec.onecx_announcement_svc_yaml.config-key=on quarkus.openapi-generator.codegen.spec.onecx_announcement_svc_yaml.base-package=gen.io.github.onecx.announcement.bff.clients quarkus.openapi-generator.codegen.spec.onecx_announcement_svc_yaml.return-response=true quarkus.openapi-generator.codegen.input-base-dir=target/tmp/openapi -quarkus.log.level=DEBUG # INTEGRATION TEST quarkus.test.integration-test-profile=test From 667f86dd341ac9533a325991567899040c269187 Mon Sep 17 00:00:00 2001 From: Jannik Steenken Date: Wed, 17 Jan 2024 14:20:26 +0100 Subject: [PATCH 12/12] fix: delete response mapper --- .../bff/rs/mappers/ResponseMapper.java | 22 ------------------- 1 file changed, 22 deletions(-) delete mode 100644 src/main/java/io/github/onecx/announcement/bff/rs/mappers/ResponseMapper.java diff --git a/src/main/java/io/github/onecx/announcement/bff/rs/mappers/ResponseMapper.java b/src/main/java/io/github/onecx/announcement/bff/rs/mappers/ResponseMapper.java deleted file mode 100644 index 3982fcc..0000000 --- a/src/main/java/io/github/onecx/announcement/bff/rs/mappers/ResponseMapper.java +++ /dev/null @@ -1,22 +0,0 @@ -package io.github.onecx.announcement.bff.rs.mappers; - -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.tkit.quarkus.rs.mappers.OffsetDateTimeMapper; - -import gen.io.github.onecx.announcement.bff.clients.model.Announcement; -import gen.io.github.onecx.announcement.bff.clients.model.AnnouncementPageResult; -import gen.io.github.onecx.announcement.bff.rs.internal.model.AnnouncementDTO; -import gen.io.github.onecx.announcement.bff.rs.internal.model.AnnouncementPageResultDTO; - -@Mapper(uses = OffsetDateTimeMapper.class) -public interface ResponseMapper { - - @Mapping(target = "version", ignore = true) - AnnouncementDTO mapAnnouncementToAnnouncementDTO(Announcement announcement); - - @Mapping(target = "removeStreamItem", ignore = true) - AnnouncementPageResultDTO mapAnnouncementPageResultToAnnouncementPageResultDTO( - AnnouncementPageResult announcementPageResult); - -}