diff --git a/src/main/java/org/tkit/onecx/welcome/domain/models/Image.java b/src/main/java/org/tkit/onecx/welcome/domain/models/Image.java index e28d38b..1d5a82d 100644 --- a/src/main/java/org/tkit/onecx/welcome/domain/models/Image.java +++ b/src/main/java/org/tkit/onecx/welcome/domain/models/Image.java @@ -12,11 +12,9 @@ @Setter @Table(name = "IMAGE") @Entity -//@NamedEntityGraph(name = Image.IMAGE_FULL, includeAllAttributes = true) +@SuppressWarnings("java:S2160") public class Image extends TraceableEntity { - // public static final String IMAGE_FULL = "Image.full"; - @TenantId @Column(name = "TENANT_ID") private String tenantId; diff --git a/src/main/java/org/tkit/onecx/welcome/domain/models/ImageData.java b/src/main/java/org/tkit/onecx/welcome/domain/models/ImageData.java index 8722f0b..2b9c6f6 100644 --- a/src/main/java/org/tkit/onecx/welcome/domain/models/ImageData.java +++ b/src/main/java/org/tkit/onecx/welcome/domain/models/ImageData.java @@ -14,6 +14,7 @@ @Setter @Table(name = "IMAGE_DATA") @Entity +@SuppressWarnings("java:S2160") public class ImageData extends TraceableEntity { @TenantId @@ -21,7 +22,7 @@ public class ImageData extends TraceableEntity { private String tenantId; @Column(name = "IMAGE_DATA") - private byte[] imageData; + private byte[] imageContent; @Column(name = "DATA_LENGTH") private Integer dataLength; diff --git a/src/main/java/org/tkit/onecx/welcome/rs/internal/mappers/ImageMapper.java b/src/main/java/org/tkit/onecx/welcome/rs/internal/mappers/ImageMapper.java index 9d501fa..6673387 100644 --- a/src/main/java/org/tkit/onecx/welcome/rs/internal/mappers/ImageMapper.java +++ b/src/main/java/org/tkit/onecx/welcome/rs/internal/mappers/ImageMapper.java @@ -20,7 +20,7 @@ public interface ImageMapper { @Mapping(target = "modificationDate", ignore = true) @Mapping(target = "modificationCount", ignore = true) @Mapping(target = "mimeType", source = "contentType") - @Mapping(target = "imageData", source = "data") + @Mapping(target = "imageContent", source = "data") @Mapping(target = "id", ignore = true) @Mapping(target = "dataLength", source = "contentLength") @Mapping(target = "creationUser", ignore = true) @@ -45,7 +45,7 @@ public interface ImageMapper { default ImageData update(ImageData imageToUpdate, Integer contentLength, byte[] body, String mimeType) { imageToUpdate.setMimeType(mimeType); - imageToUpdate.setImageData(body); + imageToUpdate.setImageContent(body); imageToUpdate.setDataLength(contentLength); return imageToUpdate; } @@ -57,6 +57,7 @@ default ImageData update(ImageData imageToUpdate, Integer contentLength, byte[] @Mapping(target = "controlTraceabilityManual", ignore = true) void updateInfo(@MappingTarget Image infoToUpdate, ImageInfoDTO imageInfoDTO); + @Mapping(target = "imageData", source = "imageContent") @Mapping(target = "imageId", source = "id") ImageDataResponseDTO mapResponse(ImageData image); diff --git a/src/test/java/org/tkit/onecx/welcome/rs/internal/controllers/ImageInternalRestControllerTest.java b/src/test/java/org/tkit/onecx/welcome/rs/internal/controllers/ImageInternalRestControllerTest.java index b4d9a8a..1011f7b 100644 --- a/src/test/java/org/tkit/onecx/welcome/rs/internal/controllers/ImageInternalRestControllerTest.java +++ b/src/test/java/org/tkit/onecx/welcome/rs/internal/controllers/ImageInternalRestControllerTest.java @@ -23,10 +23,9 @@ @QuarkusTest @TestHTTPEndpoint(ImageInternalRestController.class) @WithDBData(value = "data/testdata-internal.xml", deleteBeforeInsert = true, deleteAfterTest = true, rinseAndRepeat = true) -public class ImageInternalRestControllerTest extends AbstractTest { +class ImageInternalRestControllerTest extends AbstractTest { private static final String MEDIA_TYPE_IMAGE_PNG = "image/png"; - private static final String MEDIA_TYPE_IMAGE_JPG = "image/jpg"; private static final File FILE = new File( Objects.requireNonNull(ImageInternalRestController.class.getResource("/images/Testimage.png")).getFile()); @@ -168,7 +167,6 @@ void updateImageDataByIdTest() { @Test void updateImageInfoByIdTest() { // get image info - var data = given() .contentType(APPLICATION_JSON) .pathParam("id", "22-222") @@ -293,7 +291,7 @@ void getAllImageInfosTest() { .contentType(APPLICATION_JSON) .extract().as(ImageInfoDTO[].class); - assertThat(output.length).isEqualTo(2); + assertThat(output).hasSize(2); } @Test