Skip to content

Commit

Permalink
Fixing issue in members list nor being initialized when converting to…
Browse files Browse the repository at this point in the history
… response.
  • Loading branch information
Idan-sh committed Aug 14, 2024
1 parent 77b0f6d commit d5c9b55
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class Group {

@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, orphanRemoval = true)
@JoinColumn(name = "group_id")
private List<Member> membersList = new ArrayList<>(); // Initialize to an empty members list.
private List<Member> membersList; // Initialize to an empty members list.

// TODO: Add Admins list, will be initialized with the creatorId as the only admin.

Expand All @@ -47,7 +47,7 @@ public GroupResponse toGroupResponse() {
description,
creatorId,
timeCreated,
membersList.stream().map(Member::toMemberResponse).toList() // Convert to member response
membersList != null ? membersList.stream().map(Member::toMemberResponse).toList() : new ArrayList<>() // Convert to member response
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public GroupResponse createGroup(GroupCreateRequest groupCreateRequest) {

// TODO: Add creator Id into a new list of admins
Group createdGroup = Group.builder()
.groupId(groupIdReceived != null ? groupIdReceived : UUID.randomUUID().toString()) // If defined a group ID then use it, otherwise generate random group ID.
.groupId(groupIdReceived != null ? groupIdReceived : UUID.randomUUID().toString().replaceAll("[^0-9]", "")) // If defined a group ID then use it, otherwise generate random group ID.
.groupName(groupCreateRequest.groupName())
.description(groupCreateRequest.description())
.creatorId(groupCreateRequest.creatorId())
Expand Down

0 comments on commit d5c9b55

Please sign in to comment.