-
Notifications
You must be signed in to change notification settings - Fork 81
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
Implementing a new EventResponseDTO with field rearrangement #8082
base: dev
Are you sure you want to change the base?
Changes from 7 commits
78c5422
bbd0f2d
927ceb3
0ec5cc4
55399d0
b8e88f2
41d6e40
c027f8b
1458946
88dabc5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,11 @@ | |
import greencity.dto.event.AddEventDtoRequest; | ||
import greencity.dto.event.AddressDto; | ||
import greencity.dto.event.EventAuthorDto; | ||
import greencity.dto.event.EventDateInformationDto; | ||
import greencity.dto.event.EventDateLocationDto; | ||
import greencity.dto.event.EventDto; | ||
import greencity.dto.event.EventInformationDto; | ||
import greencity.dto.event.EventResponseDto; | ||
import greencity.dto.event.UpdateEventDateLocationDto; | ||
import greencity.dto.event.UpdateEventRequestDto; | ||
import greencity.dto.favoriteplace.FavoritePlaceDto; | ||
|
@@ -39,6 +42,7 @@ | |
import greencity.dto.location.LocationDto; | ||
import greencity.dto.location.MapBoundsDto; | ||
import greencity.dto.place.PlaceByBoundsDto; | ||
import greencity.dto.tag.TagDto; | ||
import greencity.dto.todolistitem.CustomToDoListItemResponseDto; | ||
import greencity.dto.todolistitem.ToDoListItemPostDto; | ||
import greencity.dto.todolistitem.ToDoListItemRequestDto; | ||
|
@@ -59,15 +63,19 @@ | |
import greencity.enums.ArticleType; | ||
import greencity.enums.CommentStatus; | ||
import greencity.enums.EventStatus; | ||
import greencity.enums.EventType; | ||
import greencity.enums.Role; | ||
import greencity.enums.ToDoListItemStatus; | ||
import greencity.enums.TagType; | ||
import greencity.enums.UserStatus; | ||
import java.security.Principal; | ||
import java.sql.Date; | ||
import java.time.Instant; | ||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
import java.time.OffsetDateTime; | ||
import java.time.ZoneId; | ||
import java.time.ZoneOffset; | ||
import java.time.ZonedDateTime; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
|
@@ -588,4 +596,55 @@ public static List<PlaceByBoundsDto> getPlaceByBoundsDto() { | |
.location(new LocationDto()) | ||
.build()); | ||
} | ||
} | ||
|
||
public static EventResponseDto getEventResponseDto() { | ||
return EventResponseDto.builder() | ||
.id(1L) | ||
.eventInformation(EventInformationDto.builder() | ||
.title("Test Event") | ||
.description("New Test Event") | ||
.tags(List.of(TagUaEnDto.builder() | ||
.id(2L) | ||
.nameUa("Соціальний") | ||
.nameEn("Social") | ||
.build())) | ||
.build()) | ||
.organizer(EventAuthorDto.builder().id(1L).name("Test").email("[email protected]").build()) | ||
.creationDate(LocalDate.of(2025, 1, 10)) | ||
.isOpen(true) | ||
.dates(List.of( | ||
EventDateInformationDto.builder() | ||
.startDate(ZonedDateTime.of(2025, 12, 26, 12, 30, 0, 0, ZoneOffset.UTC)) | ||
.finishDate(ZonedDateTime.of(2025, 12, 26, 21, 59, 0, 0, ZoneOffset.UTC)) | ||
.onlineLink("www.testlink.com") | ||
.coordinates(AddressDto.builder() | ||
.latitude(50.44628775288652) | ||
.longitude(30.49364829378446) | ||
.streetEn("Halytska Square") | ||
.streetUa("Галицька площа") | ||
.houseNumber("1") | ||
.cityEn("Kyiv") | ||
.cityUa("Київ") | ||
.regionEn("Kyiv") | ||
.regionUa("місто Київ") | ||
.countryEn("Ukraine") | ||
.countryUa("Україна") | ||
.formattedAddressEn("Halytska Sq, 1, Kyiv, Ukraine, 02000") | ||
.formattedAddressUa("Галицька пл., 1, Київ, Україна, 02000") | ||
.build()) | ||
.build())) | ||
.titleImage("https://test.png") | ||
.additionalImages(List.of("https://test1.png", "https://test2.png")) | ||
.type(EventType.OFFLINE) | ||
.isRelevant(true) | ||
.likes(3) | ||
.dislikes(1) | ||
.countComments(1) | ||
.eventRate(20.0) | ||
.currentUserGrade(50) | ||
.isSubscribed(false) | ||
.isFavorite(false) | ||
.isOrganizedByFriend(false) | ||
.build(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package greencity.dto.event; | ||
|
||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
@SuperBuilder | ||
@NoArgsConstructor | ||
@Getter | ||
@Setter | ||
@EqualsAndHashCode(callSuper = true) | ||
public class EventDateInformationDto extends AbstractEventDateLocationDto { | ||
private Long id; | ||
private EventResponseDto event; | ||
private AddressDto coordinates; | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,20 @@ | ||||||||||||||||||||||||||||||||
package greencity.dto.event; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
import greencity.dto.tag.TagUaEnDto; | ||||||||||||||||||||||||||||||||
import jakarta.validation.constraints.NotEmpty; | ||||||||||||||||||||||||||||||||
import lombok.AllArgsConstructor; | ||||||||||||||||||||||||||||||||
import lombok.Builder; | ||||||||||||||||||||||||||||||||
import lombok.Data; | ||||||||||||||||||||||||||||||||
import lombok.NoArgsConstructor; | ||||||||||||||||||||||||||||||||
import java.util.List; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
@Builder | ||||||||||||||||||||||||||||||||
@NoArgsConstructor | ||||||||||||||||||||||||||||||||
@AllArgsConstructor | ||||||||||||||||||||||||||||||||
@Data | ||||||||||||||||||||||||||||||||
public class EventInformationDto { | ||||||||||||||||||||||||||||||||
private String title; | ||||||||||||||||||||||||||||||||
private String description; | ||||||||||||||||||||||||||||||||
@NotEmpty | ||||||||||||||||||||||||||||||||
private List<TagUaEnDto> tags; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
Comment on lines
+16
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add validation constraints to prevent potential security issues. The public class EventInformationDto {
+ @NotBlank
+ @Size(min = 1, max = 255)
private String title;
+ @NotBlank
+ @Size(max = 5000)
private String description;
@NotEmpty
+ @Size(max = 100)
private List<TagUaEnDto> tags;
} This ensures:
📝 Committable suggestion
Suggested change
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package greencity.dto.event; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import greencity.enums.EventType; | ||
import jakarta.validation.constraints.Max; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import org.springframework.lang.Nullable; | ||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
@Data | ||
@Builder | ||
public class EventResponseDto { | ||
private Long id; | ||
|
||
private EventInformationDto eventInformation; | ||
|
||
private EventAuthorDto organizer; | ||
|
||
private LocalDate creationDate; | ||
|
||
private Boolean isOpen; | ||
|
||
@Max(7) | ||
private List<EventDateInformationDto> dates; | ||
|
||
@Nullable | ||
private String titleImage; | ||
|
||
@Nullable | ||
@Max(4) | ||
private List<String> additionalImages; | ||
|
||
private EventType type; | ||
|
||
@JsonProperty("isSubscribed") | ||
private boolean isSubscribed; | ||
|
||
@JsonProperty("isFavorite") | ||
private boolean isFavorite; | ||
|
||
private Boolean isRelevant; | ||
|
||
private Integer likes; | ||
|
||
private Integer dislikes; | ||
|
||
private Integer countComments; | ||
|
||
@JsonProperty("isOrganizedByFriend") | ||
private boolean isOrganizedByFriend; | ||
|
||
private Double eventRate; | ||
|
||
private Integer currentUserGrade; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider using per-test locale configuration instead of global default
Setting the default locale globally can affect other tests running in parallel and may mask locale-specific issues. Consider these alternatives:
@BeforeEach
to reset locale after each testHere's an example of using explicit locales:
Or if global setting is necessary, ensure cleanup: