Skip to content

Commit ff2d4e1

Browse files
authored
Clean up global filter dto (#56)
Signed-off-by: Hugo Marcellin <[email protected]>
1 parent a781dd1 commit ff2d4e1

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

src/main/java/org/gridsuite/studyconfig/server/dto/GlobalFilterInfos.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
package org.gridsuite.studyconfig.server.dto;
88

9+
import com.fasterxml.jackson.annotation.JsonInclude;
910
import io.swagger.v3.oas.annotations.media.Schema;
1011
import jakarta.validation.constraints.NotNull;
1112
import lombok.Builder;
@@ -19,16 +20,19 @@
1920
@Schema(name = "GlobalFilterDto", description = "Global filter configuration")
2021
public record GlobalFilterInfos(
2122

23+
@JsonInclude(JsonInclude.Include.NON_NULL)
2224
@Schema(description = "Global filter UUID")
2325
UUID id,
2426

27+
@JsonInclude(JsonInclude.Include.NON_NULL)
2528
@Schema(description = "Generic filter ID")
2629
UUID uuid,
2730

2831
@NotNull(message = "Filter type is mandatory")
2932
@Schema(description = "Filter type")
3033
String filterType,
3134

35+
@JsonInclude(JsonInclude.Include.NON_NULL)
3236
@Schema(description = "Filter subtype")
3337
String filterSubtype,
3438

@@ -39,9 +43,11 @@ public record GlobalFilterInfos(
3943
@Schema(description = "Was filter recently applied")
4044
boolean recent,
4145

46+
@JsonInclude(JsonInclude.Include.NON_NULL)
4247
@Schema(description = "Generic filter related equipment type")
4348
String equipmentType,
4449

50+
@JsonInclude(JsonInclude.Include.NON_NULL)
4551
@Schema(description = "Generic filter path")
4652
String path
4753

src/main/java/org/gridsuite/studyconfig/server/mapper/SpreadsheetConfigMapper.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,16 @@ public static ColumnEntity toColumnEntity(ColumnInfos dto) {
9393
}
9494

9595
public static GlobalFilterInfos toGlobalFilterDto(GlobalFilterEntity entity) {
96-
return new GlobalFilterInfos(
97-
entity.getId(),
98-
entity.getUuid(),
99-
entity.getFilterType(),
100-
entity.getFilterSubtype(),
101-
entity.getLabel(),
102-
entity.isRecent(),
103-
entity.getEquipmentType(),
104-
entity.getPath()
105-
);
96+
return GlobalFilterInfos.builder()
97+
.uuid(entity.getUuid())
98+
.filterType(entity.getFilterType())
99+
.filterSubtype(entity.getFilterSubtype())
100+
.label(entity.getLabel())
101+
.recent(entity.isRecent())
102+
.equipmentType(entity.getEquipmentType())
103+
.path(entity.getPath())
104+
.build();
105+
106106
}
107107

108108
public static GlobalFilterEntity toGlobalFilterEntity(GlobalFilterInfos dto) {

src/test/java/org/gridsuite/studyconfig/server/DtoConverterTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,7 @@ void testConversionToDtoOfSpreadsheetConfig() {
8484
assertThat(d.columns().get(1).filterValue()).isNull();
8585
// Global filters assertions
8686
assertThat(d.globalFilters()).hasSize(2);
87-
assertThat(d.globalFilters().get(0).id()).isNotNull();
8887
assertThat(d.globalFilters().get(0).label()).isEqualTo("GlobalFilter1");
89-
90-
assertThat(d.globalFilters().get(1).id()).isNotNull();
9188
assertThat(d.globalFilters().get(1).label()).isEqualTo("GlobalFilter2");
9289
});
9390
}
@@ -249,7 +246,6 @@ void testConversionToDtoOfGlobalFilter() {
249246
assertThat(dto)
250247
.as("DTO conversion result")
251248
.satisfies(d -> {
252-
assertThat(d.id()).isEqualTo(uuid);
253249
assertThat(d.uuid()).isEqualTo(filterId);
254250
assertThat(d.label()).isEqualTo("TestGlobalFilter");
255251
});

0 commit comments

Comments
 (0)