diff --git a/src/main/java/org/gridsuite/studyconfig/server/dto/GlobalFilterInfos.java b/src/main/java/org/gridsuite/studyconfig/server/dto/GlobalFilterInfos.java index 578cc30..f9fee01 100644 --- a/src/main/java/org/gridsuite/studyconfig/server/dto/GlobalFilterInfos.java +++ b/src/main/java/org/gridsuite/studyconfig/server/dto/GlobalFilterInfos.java @@ -6,6 +6,7 @@ */ package org.gridsuite.studyconfig.server.dto; +import com.fasterxml.jackson.annotation.JsonInclude; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; import lombok.Builder; @@ -19,9 +20,11 @@ @Schema(name = "GlobalFilterDto", description = "Global filter configuration") public record GlobalFilterInfos( + @JsonInclude(JsonInclude.Include.NON_NULL) @Schema(description = "Global filter UUID") UUID id, + @JsonInclude(JsonInclude.Include.NON_NULL) @Schema(description = "Generic filter ID") UUID uuid, @@ -29,6 +32,7 @@ public record GlobalFilterInfos( @Schema(description = "Filter type") String filterType, + @JsonInclude(JsonInclude.Include.NON_NULL) @Schema(description = "Filter subtype") String filterSubtype, @@ -39,9 +43,11 @@ public record GlobalFilterInfos( @Schema(description = "Was filter recently applied") boolean recent, + @JsonInclude(JsonInclude.Include.NON_NULL) @Schema(description = "Generic filter related equipment type") String equipmentType, + @JsonInclude(JsonInclude.Include.NON_NULL) @Schema(description = "Generic filter path") String path diff --git a/src/main/java/org/gridsuite/studyconfig/server/mapper/SpreadsheetConfigMapper.java b/src/main/java/org/gridsuite/studyconfig/server/mapper/SpreadsheetConfigMapper.java index 1c523ab..6106fd1 100644 --- a/src/main/java/org/gridsuite/studyconfig/server/mapper/SpreadsheetConfigMapper.java +++ b/src/main/java/org/gridsuite/studyconfig/server/mapper/SpreadsheetConfigMapper.java @@ -93,16 +93,16 @@ public static ColumnEntity toColumnEntity(ColumnInfos dto) { } public static GlobalFilterInfos toGlobalFilterDto(GlobalFilterEntity entity) { - return new GlobalFilterInfos( - entity.getId(), - entity.getUuid(), - entity.getFilterType(), - entity.getFilterSubtype(), - entity.getLabel(), - entity.isRecent(), - entity.getEquipmentType(), - entity.getPath() - ); + return GlobalFilterInfos.builder() + .uuid(entity.getUuid()) + .filterType(entity.getFilterType()) + .filterSubtype(entity.getFilterSubtype()) + .label(entity.getLabel()) + .recent(entity.isRecent()) + .equipmentType(entity.getEquipmentType()) + .path(entity.getPath()) + .build(); + } public static GlobalFilterEntity toGlobalFilterEntity(GlobalFilterInfos dto) { diff --git a/src/test/java/org/gridsuite/studyconfig/server/DtoConverterTest.java b/src/test/java/org/gridsuite/studyconfig/server/DtoConverterTest.java index b6bbabe..99147f3 100644 --- a/src/test/java/org/gridsuite/studyconfig/server/DtoConverterTest.java +++ b/src/test/java/org/gridsuite/studyconfig/server/DtoConverterTest.java @@ -84,10 +84,7 @@ void testConversionToDtoOfSpreadsheetConfig() { assertThat(d.columns().get(1).filterValue()).isNull(); // Global filters assertions assertThat(d.globalFilters()).hasSize(2); - assertThat(d.globalFilters().get(0).id()).isNotNull(); assertThat(d.globalFilters().get(0).label()).isEqualTo("GlobalFilter1"); - - assertThat(d.globalFilters().get(1).id()).isNotNull(); assertThat(d.globalFilters().get(1).label()).isEqualTo("GlobalFilter2"); }); } @@ -249,7 +246,6 @@ void testConversionToDtoOfGlobalFilter() { assertThat(dto) .as("DTO conversion result") .satisfies(d -> { - assertThat(d.id()).isEqualTo(uuid); assertThat(d.uuid()).isEqualTo(filterId); assertThat(d.label()).isEqualTo("TestGlobalFilter"); });