Skip to content
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 @@ -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;
Expand All @@ -19,16 +20,19 @@
@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,

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

@JsonInclude(JsonInclude.Include.NON_NULL)
@Schema(description = "Filter subtype")
String filterSubtype,

Expand All @@ -39,9 +43,11 @@ public record GlobalFilterInfos(
@Schema(description = "Was filter recently applied")
boolean recent,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

boolean (primitive) can not be null


@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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
}
Expand Down Expand Up @@ -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");
});
Expand Down