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
@@ -1,10 +1,11 @@
package com.daytodo.domain.course.dto;

import com.daytodo.domain.course.enums.HomeBannerStatus;
import com.daytodo.domain.course.enums.ParticipantType;
import com.daytodo.domain.course.entity.Course;
import com.daytodo.domain.course.enums.CourseStatus;
import com.daytodo.domain.course.enums.HomeBannerStatus;
import com.daytodo.domain.course.enums.MemberRole;
import com.daytodo.domain.course.enums.MemberStatus;
import com.daytodo.domain.course.enums.ParticipantType;
import com.daytodo.domain.place.enums.PlaceRecommendationSource;

import java.time.LocalDate;
Expand Down Expand Up @@ -55,7 +56,8 @@ public record CalendarCourse(
Long courseId,
String courseName,
ParticipantType participantType,
long memberCount
long memberCount,
CourseStatus courseStatus
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ public CourseResponse.Calendar getCalendar(Long userId, Integer year, Integer mo
course.getCourseId(),
course.getCourseName(),
course.getParticipantType(),
memberCounts.getOrDefault(course.getCourseId(), 0L)
memberCounts.getOrDefault(course.getCourseId(), 0L),
course.getCourseStatus()
))
.toList()
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public final class UserResponse {
private UserResponse() {
}

public record Profile(Long userId, String nickname, String profileImageUrl) {
public record Profile(Long userId, String email, String nickname, String profileImageUrl) {
}

public record InterestRegion(Long regionId, String regionName, String parentRegionName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ public UserResponse.Profile updateProfile(
}
throw exception;
}
return new UserResponse.Profile(user.getId(), user.getNickname(), user.getProfileImageUrl());
return new UserResponse.Profile(
user.getId(),
user.getEmail(),
user.getNickname(),
user.getProfileImageUrl()
);
}

private String normalizeNickname(String nickname) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ public class UserService {

public UserResponse.Profile getProfile(Long userId) {
User user = getActiveUser(userId);
return new UserResponse.Profile(user.getId(), user.getNickname(), user.getProfileImageUrl());
return new UserResponse.Profile(
user.getId(),
user.getEmail(),
user.getNickname(),
user.getProfileImageUrl()
);
}

public UserResponse.InterestRegions getInterestRegions(Long userId) {
Expand Down Expand Up @@ -138,4 +143,4 @@ private UserResponse.InterestRegion toInterestRegion(Region region) {
region.getParent() == null ? null : region.getParent().getRegionName()
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ void appliesDateFilterOnlyToCreatedCourses() {
@Test
void groupsMultipleCalendarCoursesOnSameDate() {
Course first = course(100L, "첫 코스", TODAY, CourseStatus.PLANNING);
Course second = course(101L, "둘째 코스", TODAY, CourseStatus.PLANNING);
Course second = course(101L, "둘째 코스", TODAY, CourseStatus.COMPLETED);
when(courseRepository.findCalendarCourses(
1L,
MemberStatus.JOINED,
Expand All @@ -211,6 +211,9 @@ void groupsMultipleCalendarCoursesOnSameDate() {

assertThat(response.schedules()).hasSize(1);
assertThat(response.schedules().get(0).courses()).hasSize(2);
assertThat(response.schedules().get(0).courses())
.extracting(CourseResponse.CalendarCourse::courseStatus)
.containsExactly(CourseStatus.PLANNING, CourseStatus.COMPLETED);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.daytodo.domain.user.controller;

import com.daytodo.domain.user.dto.UserResponse;
import com.daytodo.domain.user.service.UserService;
import com.daytodo.domain.user.service.ProfileService;
import com.daytodo.domain.user.service.UserNotificationService;
Expand All @@ -24,7 +25,9 @@
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@ExtendWith(MockitoExtension.class)
class UserControllerTest {
Expand Down Expand Up @@ -60,8 +63,13 @@ void delegatesUsingAuthenticatedPrincipal() throws Exception {
SecurityContextHolder.getContext().setAuthentication(
new UsernamePasswordAuthenticationToken(1L, null)
);
when(userService.getProfile(1L)).thenReturn(
new UserResponse.Profile(1L, "user@example.com", "daytodo", "profile.png")
);

mockMvc.perform(get("/users/profile"))
.andExpect(status().isOk());
.andExpect(status().isOk())
.andExpect(jsonPath("$.email").value("user@example.com"));
verify(userService).getProfile(1L);
}

Expand Down Expand Up @@ -118,4 +126,4 @@ void deletesFcmTokenUsingAuthenticatedPrincipal() throws Exception {
new com.daytodo.domain.user.dto.UserRequest.DeleteFcmToken("device-token")
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ void updatesNicknameWithoutTreatingCurrentUserAsDuplicate() {
UserResponse.Profile response = service.updateProfile(1L, " 새 닉네임 ", null);

assertThat(response.nickname()).isEqualTo("새 닉네임");
assertThat(response.email()).isEqualTo("user@example.com");
assertThat(response.profileImageUrl()).isEqualTo("old-url");
verify(profileImageStorage, never()).upload(org.mockito.ArgumentMatchers.any(), org.mockito.ArgumentMatchers.any());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ void authenticatedUserCanReadOwnProfile() {
UserResponse.Profile response = userService.getProfile(1L);

assertThat(response.userId()).isEqualTo(1L);
assertThat(response.email()).isEqualTo("user@example.com");
assertThat(response.nickname()).isEqualTo("daytodo");
assertThat(response.profileImageUrl()).isEqualTo("profile.png");
}
Expand Down Expand Up @@ -224,4 +225,4 @@ private Region region(Long id, Region parent, String name, RegionLevel level) {
ReflectionTestUtils.setField(region, "regionId", id);
return region;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void protectedUserApiRejectsRequestWithoutJwtInCommonErrorFormat() throws Except
@Test
void jwtPrincipalOverridesUntrustedUserIdHeader() throws Exception {
when(userService.getProfile(1L))
.thenReturn(new UserResponse.Profile(1L, "daytodo", null));
.thenReturn(new UserResponse.Profile(1L, "user@example.com", "daytodo", null));

mockMvc.perform(get("/users/profile")
.header(HttpHeaders.AUTHORIZATION, bearer(1L))
Expand Down
Loading