From 2325ee2753f25252bb0ea963e260f0264e1f8c4b Mon Sep 17 00:00:00 2001 From: JordenReuter <149687553+JordenReuter@users.noreply.github.com> Date: Wed, 25 Sep 2024 12:27:14 +0200 Subject: [PATCH] added position to bookmark (#10) * added position to bookmark * feat: fix log and remove modifiers * fix: assertion --- .../pages/onecx-bookmark-svc-extensions.adoc | 72 +++++++++---------- .../pages/onecx-bookmark-svc.adoc | 32 +++++---- .../bookmark/domain/models/Bookmark.java | 2 + .../rs/internal/log/InternalLogParam.java | 56 +++++++-------- .../onecx-bookmark-internal-openapi.yaml | 12 ++++ src/main/resources/db/changeLog.xml | 2 +- .../db/v1/2024-09-25-position-field.xml | 22 ++++++ .../bookmark/domain/daos/BookmarkDAOTest.java | 2 +- .../BookmarkRestControllerTest.java | 15 ++-- src/test/resources/data/test-internal.xml | 2 +- 10 files changed, 129 insertions(+), 88 deletions(-) create mode 100644 src/main/resources/db/v1/2024-09-25-position-field.xml diff --git a/docs/modules/onecx-bookmark-svc/pages/onecx-bookmark-svc-extensions.adoc b/docs/modules/onecx-bookmark-svc/pages/onecx-bookmark-svc-extensions.adoc index cce673a..934b649 100644 --- a/docs/modules/onecx-bookmark-svc/pages/onecx-bookmark-svc-extensions.adoc +++ b/docs/modules/onecx-bookmark-svc/pages/onecx-bookmark-svc-extensions.adoc @@ -12,158 +12,158 @@ h| Version | https://onecx.github.io/docs/onecx-quarkus/current/onecx-quarkus/onecx-core.html[Link] | -| 0.26.0 +| 0.30.0 | onecx-tenant | https://onecx.github.io/docs/onecx-quarkus/current/onecx-quarkus/onecx-tenant.html[Link] -| https://github.com/onecx/onecx-quarkus/blob/0.26.0/docs/modules/onecx-quarkus/pages/includes/onecx-tenant.adoc[Link] -| 0.26.0 +| https://github.com/onecx/onecx-quarkus/blob/0.30.0/docs/modules/onecx-quarkus/pages/includes/onecx-tenant.adoc[Link] +| 0.30.0 | quarkus-oidc | https://quarkus.io/guides/security-oidc-bearer-token-authentication-tutorial[Link] | https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-oidc.adoc[Link] -| 3.13.2 +| 3.14.4 | 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.31.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-rest-context.adoc[Link] -| 2.31.0 +| https://github.com/1000kit/tkit-quarkus/blob/2.32.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-rest-context.adoc[Link] +| 2.32.0 | tkit-quarkus-jpa-tenant | https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-jpa-tenant.html[Link] -| https://github.com/1000kit/tkit-quarkus/blob/2.31.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-jpa-tenant.adoc[Link] -| 2.31.0 +| https://github.com/1000kit/tkit-quarkus/blob/2.32.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-jpa-tenant.adoc[Link] +| 2.32.0 | tkit-quarkus-data-import | https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-data-import.html[Link] -| https://github.com/1000kit/tkit-quarkus/blob/2.31.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-data-import.adoc[Link] -| 2.31.0 +| https://github.com/1000kit/tkit-quarkus/blob/2.32.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-data-import.adoc[Link] +| 2.32.0 | tkit-quarkus-jpa | https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-jpa.html[Link] -| https://github.com/1000kit/tkit-quarkus/blob/2.31.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-jpa.adoc[Link] -| 2.31.0 +| https://github.com/1000kit/tkit-quarkus/blob/2.32.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-jpa.adoc[Link] +| 2.32.0 | 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.31.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-cdi.adoc[Link] -| 2.31.0 +| https://github.com/1000kit/tkit-quarkus/blob/2.32.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-cdi.adoc[Link] +| 2.32.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.31.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-rs.adoc[Link] -| 2.31.0 +| https://github.com/1000kit/tkit-quarkus/blob/2.32.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-rs.adoc[Link] +| 2.32.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.31.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-json.adoc[Link] -| 2.31.0 +| https://github.com/1000kit/tkit-quarkus/blob/2.32.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-json.adoc[Link] +| 2.32.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.31.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-rest.adoc[Link] -| 2.31.0 +| https://github.com/1000kit/tkit-quarkus/blob/2.32.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-rest.adoc[Link] +| 2.32.0 | quarkus-arc | https://quarkus.io/guides/cdi-reference[Link] | https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-arc.adoc[Link] -| 3.13.2 +| 3.14.4 | quarkus-liquibase | https://quarkus.io/guides/liquibase[Link] | https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-liquibase.adoc[Link] -| 3.13.2 +| 3.14.4 | quarkus-smallrye-health | https://quarkus.io/guides/smallrye-health[Link] | https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-smallrye-health.adoc[Link] -| 3.13.2 +| 3.14.4 | quarkus-micrometer-registry-prometheus | https://quarkus.io/guides/telemetry-micrometer[Link] | https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-micrometer-registry-prometheus.adoc[Link] -| 3.13.2 +| 3.14.4 | quarkus-hibernate-orm | https://quarkus.io/guides/hibernate-orm[Link] | https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-hibernate-orm.adoc[Link] -| 3.13.2 +| 3.14.4 | quarkus-rest | https://quarkus.io/guides/rest[Link] | https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-rest.adoc[Link] -| 3.13.2 +| 3.14.4 | quarkus-rest-jackson | https://quarkus.io/guides/rest-json[Link] | -| 3.13.2 +| 3.14.4 | quarkus-jdbc-postgresql | https://quarkus.io/guides/datasource[Link] | https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-jdbc-postgresql.adoc[Link] -| 3.13.2 +| 3.14.4 | quarkus-smallrye-openapi | https://quarkus.io/guides/openapi-swaggerui[Link] | https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-smallrye-openapi.adoc[Link] -| 3.13.2 +| 3.14.4 | quarkus-hibernate-validator | https://quarkus.io/guides/validation[Link] | https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-hibernate-validator.adoc[Link] -| 3.13.2 +| 3.14.4 | quarkus-opentelemetry | https://quarkus.io/guides/opentelemetry[Link] | https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-opentelemetry.adoc[Link] -| 3.13.2 +| 3.14.4 | 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.31.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-security.adoc[Link] -| 2.31.0 +| https://github.com/1000kit/tkit-quarkus/blob/2.32.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-security.adoc[Link] +| 2.32.0 | quarkus-container-image-docker | https://quarkus.io/guides/container-image[Link] | https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-container-image-docker.adoc[Link] -| 3.13.2 +| 3.14.4 | onecx-security | | -| 0.26.0 +| 0.30.0 | quarkus-smallrye-context-propagation | | -| 3.13.2 +| 3.14.4 |=== \ No newline at end of file diff --git a/docs/modules/onecx-bookmark-svc/pages/onecx-bookmark-svc.adoc b/docs/modules/onecx-bookmark-svc/pages/onecx-bookmark-svc.adoc index d64ee31..e583317 100644 --- a/docs/modules/onecx-bookmark-svc/pages/onecx-bookmark-svc.adoc +++ b/docs/modules/onecx-bookmark-svc/pages/onecx-bookmark-svc.adoc @@ -1,63 +1,65 @@ - :summaryTableId: onecx-bookmark-svc [.configuration-legend] icon:lock[title=Fixed at build time] Configuration property fixed at build time - All other configuration properties are overridable at runtime [.configuration-reference.searchable, cols="80,.^10,.^10"] |=== -h|[[onecx-bookmark-svc_configuration]]link:#onecx-bookmark-svc_configuration[Configuration property] - +h|[.header-title]##Configuration property## h|Type h|Default -a| [[onecx-bookmark-svc_onecx-bookmark-default-enabled]]`link:#onecx-bookmark-svc_onecx-bookmark-default-enabled[onecx.bookmark.default.enabled]` - +a| [[onecx-bookmark-svc_onecx-bookmark-default-enabled]] [.property-path]##`onecx.bookmark.default.enabled`## [.description] -- Enable or disable default bookmark + ifdef::add-copy-button-to-env-var[] Environment variable: env_var_with_copy_button:+++ONECX_BOOKMARK_DEFAULT_ENABLED+++[] endif::add-copy-button-to-env-var[] ifndef::add-copy-button-to-env-var[] Environment variable: `+++ONECX_BOOKMARK_DEFAULT_ENABLED+++` endif::add-copy-button-to-env-var[] ---|boolean +-- +|boolean |`false` - -a| [[onecx-bookmark-svc_onecx-bookmark-default-url]]`link:#onecx-bookmark-svc_onecx-bookmark-default-url[onecx.bookmark.default.url]` - +a| [[onecx-bookmark-svc_onecx-bookmark-default-url]] [.property-path]##`onecx.bookmark.default.url`## [.description] -- Default bookmark URL + ifdef::add-copy-button-to-env-var[] Environment variable: env_var_with_copy_button:+++ONECX_BOOKMARK_DEFAULT_URL+++[] endif::add-copy-button-to-env-var[] ifndef::add-copy-button-to-env-var[] Environment variable: `+++ONECX_BOOKMARK_DEFAULT_URL+++` endif::add-copy-button-to-env-var[] ---|string +-- +|string |`https://github.com/onecx` - -a| [[onecx-bookmark-svc_onecx-bookmark-product-item-id]]`link:#onecx-bookmark-svc_onecx-bookmark-product-item-id[onecx.bookmark.product-item-id]` - +a| [[onecx-bookmark-svc_onecx-bookmark-product-item-id]] [.property-path]##`onecx.bookmark.product-item-id`## [.description] -- Default bookmark URL + ifdef::add-copy-button-to-env-var[] Environment variable: env_var_with_copy_button:+++ONECX_BOOKMARK_PRODUCT_ITEM_ID+++[] endif::add-copy-button-to-env-var[] ifndef::add-copy-button-to-env-var[] Environment variable: `+++ONECX_BOOKMARK_PRODUCT_ITEM_ID+++` endif::add-copy-button-to-env-var[] ---|string +-- +|string |`PRODUCT_BASE_DOC_URL` -|=== \ No newline at end of file +|=== + + +:!summaryTableId: \ No newline at end of file diff --git a/src/main/java/org/tkit/onecx/bookmark/domain/models/Bookmark.java b/src/main/java/org/tkit/onecx/bookmark/domain/models/Bookmark.java index cf38260..072abd2 100644 --- a/src/main/java/org/tkit/onecx/bookmark/domain/models/Bookmark.java +++ b/src/main/java/org/tkit/onecx/bookmark/domain/models/Bookmark.java @@ -56,4 +56,6 @@ public class Bookmark extends TraceableEntity { @Enumerated(EnumType.STRING) private Scope scope; + @Column(name = "POSITION", nullable = false) + private Integer position; } diff --git a/src/main/java/org/tkit/onecx/bookmark/rs/internal/log/InternalLogParam.java b/src/main/java/org/tkit/onecx/bookmark/rs/internal/log/InternalLogParam.java index 0195e81..675ceef 100644 --- a/src/main/java/org/tkit/onecx/bookmark/rs/internal/log/InternalLogParam.java +++ b/src/main/java/org/tkit/onecx/bookmark/rs/internal/log/InternalLogParam.java @@ -1,34 +1,34 @@ -// package org.tkit.onecx.bookmark.rs.internal.log; +package org.tkit.onecx.bookmark.rs.internal.log; -// import java.util.List; +import java.util.List; -// import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.context.ApplicationScoped; -// import org.tkit.quarkus.log.cdi.LogParam; +import org.tkit.quarkus.log.cdi.LogParam; -// import gen.org.tkit.onecx.bookmark.rs.internal.model.BookmarkSearchCriteriaDTO; -// import gen.org.tkit.onecx.bookmark.rs.internal.model.CreateBookmarkDTO; -// import gen.org.tkit.onecx.bookmark.rs.internal.model.UpdateBookmarkDTO; +import gen.org.tkit.onecx.bookmark.rs.internal.model.BookmarkSearchCriteriaDTO; +import gen.org.tkit.onecx.bookmark.rs.internal.model.CreateBookmarkDTO; +import gen.org.tkit.onecx.bookmark.rs.internal.model.UpdateBookmarkDTO; -// @ApplicationScoped -// public class InternalLogParam implements LogParam { +@ApplicationScoped +public class InternalLogParam implements LogParam { -// @Override -// public List getClasses() { -// return List.of( -// item(10, CreateBookmarkDTO.class, x -> { -// CreateBookmarkDTO d = (CreateBookmarkDTO) x; -// return CreateBookmarkDTO.class.getSimpleName() + "[" + d.getProductName() + "," + d.getItemId() + "]"; -// }), -// item(10, UpdateBookmarkDTO.class, x -> { -// UpdateBookmarkDTO d = (UpdateBookmarkDTO) x; -// return UpdateBookmarkDTO.class.getSimpleName() + "[" + d.getProductName() + "," + d.getItemId() + "]"; -// }), -// item(10, BookmarkSearchCriteriaDTO.class, x -> { -// BookmarkSearchCriteriaDTO d = (BookmarkSearchCriteriaDTO) x; -// return BookmarkSearchCriteriaDTO.class.getSimpleName() + "[" + d.getPageNumber() + "," -// + d.getPageSize() -// + "]"; -// })); -// } -// } + @Override + public List getClasses() { + return List.of( + item(10, CreateBookmarkDTO.class, x -> { + CreateBookmarkDTO d = (CreateBookmarkDTO) x; + return CreateBookmarkDTO.class.getSimpleName() + "[" + d.getProductName() + "," + d.getAppId() + "]"; + }), + item(10, UpdateBookmarkDTO.class, x -> { + UpdateBookmarkDTO d = (UpdateBookmarkDTO) x; + return UpdateBookmarkDTO.class.getSimpleName() + "[" + d.getDisplayName() + "]"; + }), + item(10, BookmarkSearchCriteriaDTO.class, x -> { + BookmarkSearchCriteriaDTO d = (BookmarkSearchCriteriaDTO) x; + return BookmarkSearchCriteriaDTO.class.getSimpleName() + "[" + d.getPageNumber() + "," + + d.getPageSize() + + "]"; + })); + } +} diff --git a/src/main/openapi/onecx-bookmark-internal-openapi.yaml b/src/main/openapi/onecx-bookmark-internal-openapi.yaml index 16b4e6c..6c20bbe 100644 --- a/src/main/openapi/onecx-bookmark-internal-openapi.yaml +++ b/src/main/openapi/onecx-bookmark-internal-openapi.yaml @@ -161,6 +161,7 @@ components: - appId - scope - workspaceName + - position type: object properties: id: @@ -201,6 +202,9 @@ components: enum: - PRIVATE - PUBLIC + position: + format: int32 + type: integer BookmarkPageResult: type: object properties: @@ -231,6 +235,7 @@ components: - workspaceName - productName - scope + - position type: object properties: displayName: @@ -258,10 +263,14 @@ components: enum: - PRIVATE - PUBLIC + position: + format: int32 + type: integer UpdateBookmark: required: - displayName - modificationCount + - position type: object properties: modificationCount: @@ -269,6 +278,9 @@ components: type: integer displayName: type: string + position: + format: int32 + type: integer ProblemDetailResponse: type: object properties: diff --git a/src/main/resources/db/changeLog.xml b/src/main/resources/db/changeLog.xml index 5efc1c7..1cb964f 100644 --- a/src/main/resources/db/changeLog.xml +++ b/src/main/resources/db/changeLog.xml @@ -4,5 +4,5 @@ xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd"> - + \ No newline at end of file diff --git a/src/main/resources/db/v1/2024-09-25-position-field.xml b/src/main/resources/db/v1/2024-09-25-position-field.xml new file mode 100644 index 0000000..cff2018 --- /dev/null +++ b/src/main/resources/db/v1/2024-09-25-position-field.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/test/java/org/tkit/onecx/bookmark/domain/daos/BookmarkDAOTest.java b/src/test/java/org/tkit/onecx/bookmark/domain/daos/BookmarkDAOTest.java index 740417e..3e5fdc4 100644 --- a/src/test/java/org/tkit/onecx/bookmark/domain/daos/BookmarkDAOTest.java +++ b/src/test/java/org/tkit/onecx/bookmark/domain/daos/BookmarkDAOTest.java @@ -27,7 +27,7 @@ void beforeAll() { } @Test - public void findTenantIdByOrgIdExceptionTest() { + void findTenantIdByOrgIdExceptionTest() { methodExceptionTests(() -> dao.findBookmarksByCriteria(null), BookmarkDAO.ErrorKeys.ERROR_GET_BY_BOOKMARK_CRITERIA); } diff --git a/src/test/java/org/tkit/onecx/bookmark/rs/internal/controllers/BookmarkRestControllerTest.java b/src/test/java/org/tkit/onecx/bookmark/rs/internal/controllers/BookmarkRestControllerTest.java index 17a36f4..5478d12 100644 --- a/src/test/java/org/tkit/onecx/bookmark/rs/internal/controllers/BookmarkRestControllerTest.java +++ b/src/test/java/org/tkit/onecx/bookmark/rs/internal/controllers/BookmarkRestControllerTest.java @@ -25,7 +25,7 @@ public class BookmarkRestControllerTest extends AbstractTest { @Test - public void createBookmark() { + void createBookmark() { CreateBookmarkDTO createBookmarkDTO = new CreateBookmarkDTO(); createBookmarkDTO.setDisplayName("newDisplayName"); @@ -34,6 +34,7 @@ public void createBookmark() { createBookmarkDTO.setWorkspaceName("newWorkspace"); createBookmarkDTO.setEndpointName("newEndpoint"); createBookmarkDTO.setScope(CreateBookmarkDTO.ScopeEnum.PUBLIC); + createBookmarkDTO.setPosition(1); var res = given() .contentType(APPLICATION_JSON) @@ -66,11 +67,12 @@ public void createBookmark() { } @Test - public void updateBookmark() { + void updateBookmark() { UpdateBookmarkDTO updateBookmarkDTO = new UpdateBookmarkDTO(); updateBookmarkDTO.setDisplayName("newDisplayName"); updateBookmarkDTO.setModificationCount(0); + updateBookmarkDTO.setPosition(2); given() .contentType(APPLICATION_JSON) @@ -130,11 +132,12 @@ public void updateBookmark() { } @Test - public void updateBookmark_shouldNotFindUpdateBookmark() { + void updateBookmark_shouldNotFindUpdateBookmark() { UpdateBookmarkDTO updateBookmarkDTO = new UpdateBookmarkDTO(); updateBookmarkDTO.setDisplayName("newDisplayName"); updateBookmarkDTO.setModificationCount(1); + updateBookmarkDTO.setPosition(1); given() .contentType(APPLICATION_JSON) @@ -149,7 +152,7 @@ public void updateBookmark_shouldNotFindUpdateBookmark() { } @Test - public void searchBookmarksByCriteria() { + void searchBookmarksByCriteria() { BookmarkSearchCriteriaDTO bookmarkSearchCriteriaDTO = new BookmarkSearchCriteriaDTO(); bookmarkSearchCriteriaDTO.setWorkspaceName("workspaceName_notExist"); @@ -166,7 +169,7 @@ public void searchBookmarksByCriteria() { } @Test - public void deleteBookmark() { + void deleteBookmark() { var res = given() .contentType(APPLICATION_JSON) @@ -196,7 +199,7 @@ public void deleteBookmark() { assertThat(output).isNotNull(); assertThat(output.getStream()).isNotNull(); - assertThat(output.getStream().size()).isEqualTo(0); + assertThat(output.getStream().isEmpty()); } } diff --git a/src/test/resources/data/test-internal.xml b/src/test/resources/data/test-internal.xml index 4bacb3b..b072020 100644 --- a/src/test/resources/data/test-internal.xml +++ b/src/test/resources/data/test-internal.xml @@ -2,6 +2,6 @@ - +