Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fixed sonar code smells #3

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading