Skip to content

Commit

Permalink
fix: fixed sonar code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
JordenReuter committed Feb 26, 2024
1 parent 2ca2cf0 commit 6c083a8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
@Setter
@Table(name = "IMAGE_DATA")
@Entity
@SuppressWarnings("java:S2160")
public class ImageData extends TraceableEntity {

@TenantId
@Column(name = "TENANT_ID")
private String tenantId;

@Column(name = "IMAGE_DATA")
private byte[] imageData;
private byte[] imageContent;

@Column(name = "DATA_LENGTH")
private Integer dataLength;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
}
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -168,7 +167,6 @@ void updateImageDataByIdTest() {
@Test
void updateImageInfoByIdTest() {
// get image info

var data = given()
.contentType(APPLICATION_JSON)
.pathParam("id", "22-222")
Expand Down Expand Up @@ -293,7 +291,7 @@ void getAllImageInfosTest() {
.contentType(APPLICATION_JSON)
.extract().as(ImageInfoDTO[].class);

assertThat(output.length).isEqualTo(2);
assertThat(output).hasSize(2);
}

@Test
Expand Down

0 comments on commit 6c083a8

Please sign in to comment.