From ccd486facdfa325989ae03ef646e7d2678207467 Mon Sep 17 00:00:00 2001 From: JordenReuter <149687553+JordenReuter@users.noreply.github.com> Date: Wed, 12 Jun 2024 16:08:02 +0200 Subject: [PATCH] fix: fixed image constraint and adjusted test (#92) --- .../tkit/onecx/workspace/domain/models/Image.java | 2 +- src/main/resources/db/changeLog.xml | 2 +- .../db/v1/2024-06-12-update-image-constraint.xml | 12 ++++++++++++ .../ImagesInternalRestControllerTest.java | 2 +- 4 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 src/main/resources/db/v1/2024-06-12-update-image-constraint.xml diff --git a/src/main/java/org/tkit/onecx/workspace/domain/models/Image.java b/src/main/java/org/tkit/onecx/workspace/domain/models/Image.java index 900aeb9..022ba25 100644 --- a/src/main/java/org/tkit/onecx/workspace/domain/models/Image.java +++ b/src/main/java/org/tkit/onecx/workspace/domain/models/Image.java @@ -12,7 +12,7 @@ @Getter @Setter @Table(name = "IMAGE", uniqueConstraints = { - @UniqueConstraint(name = "IMAGE_CONSTRAINTS", columnNames = { "REF_ID", "REF_TYPE" }) + @UniqueConstraint(name = "IMAGE_CONSTRAINTS", columnNames = { "REF_ID", "TENANT_ID", "REF_TYPE" }) }) @SuppressWarnings("squid:S2160") public class Image extends TraceableEntity { diff --git a/src/main/resources/db/changeLog.xml b/src/main/resources/db/changeLog.xml index ed7f8ad..219550a 100644 --- a/src/main/resources/db/changeLog.xml +++ b/src/main/resources/db/changeLog.xml @@ -12,5 +12,5 @@ - + \ No newline at end of file diff --git a/src/main/resources/db/v1/2024-06-12-update-image-constraint.xml b/src/main/resources/db/v1/2024-06-12-update-image-constraint.xml new file mode 100644 index 0000000..7c5c173 --- /dev/null +++ b/src/main/resources/db/v1/2024-06-12-update-image-constraint.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/src/test/java/org/tkit/onecx/workspace/rs/internal/controllers/ImagesInternalRestControllerTest.java b/src/test/java/org/tkit/onecx/workspace/rs/internal/controllers/ImagesInternalRestControllerTest.java index 8efbb08..4c553e6 100644 --- a/src/test/java/org/tkit/onecx/workspace/rs/internal/controllers/ImagesInternalRestControllerTest.java +++ b/src/test/java/org/tkit/onecx/workspace/rs/internal/controllers/ImagesInternalRestControllerTest.java @@ -96,7 +96,7 @@ void uploadImage_shouldReturnBadRequest_whenImageIs() { assertThat(exception.getErrorCode()).isEqualTo("PERSIST_ENTITY_FAILED"); assertThat(exception.getDetail()).isEqualTo( - "could not execute statement [ERROR: duplicate key value violates unique constraint 'image_constraints' Detail: Key (ref_id, ref_type)=(productNameUpload, logo) already exists.]"); + "could not execute statement [ERROR: duplicate key value violates unique constraint 'image_constraints' Detail: Key (ref_id, tenant_id, ref_type)=(productNameUpload, tenant-100, logo) already exists.]"); } @Test