diff --git a/src/main/java/com/keeper/homepage/domain/seminar/api/SeminarAttendanceController.java b/src/main/java/com/keeper/homepage/domain/seminar/api/SeminarAttendanceController.java index 09b633f87..3b97b3e5d 100644 --- a/src/main/java/com/keeper/homepage/domain/seminar/api/SeminarAttendanceController.java +++ b/src/main/java/com/keeper/homepage/domain/seminar/api/SeminarAttendanceController.java @@ -12,6 +12,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Sort; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.access.annotation.Secured; @@ -49,7 +50,7 @@ public ResponseEntity> getAttendances( @RequestParam(defaultValue = "10") @PositiveOrZero int size ) { Page responses = seminarAttendanceService.getAttendances( - PageRequest.of(page, size)); + PageRequest.of(page, size, Sort.by(Sort.DEFAULT_DIRECTION, "generation.generation").and(Sort.by(Sort.DEFAULT_DIRECTION,"profile.realName")))); return ResponseEntity.ok(responses); } diff --git a/src/test/java/com/keeper/homepage/domain/seminar/api/SeminarAttendanceControllerTest.java b/src/test/java/com/keeper/homepage/domain/seminar/api/SeminarAttendanceControllerTest.java index 67efa9c16..10c502d4a 100644 --- a/src/test/java/com/keeper/homepage/domain/seminar/api/SeminarAttendanceControllerTest.java +++ b/src/test/java/com/keeper/homepage/domain/seminar/api/SeminarAttendanceControllerTest.java @@ -24,6 +24,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import com.keeper.homepage.domain.member.entity.Member; +import com.keeper.homepage.domain.member.entity.embedded.RealName; import com.keeper.homepage.domain.seminar.dto.request.SeminarAttendanceCodeRequest; import com.keeper.homepage.domain.seminar.dto.request.SeminarAttendanceStatusRequest; import com.keeper.homepage.domain.seminar.dto.request.SeminarStartRequest; @@ -56,8 +57,8 @@ public class SeminarAttendanceControllerTest extends SeminarApiTestHelper { @BeforeEach void setUp() { - adminId = memberTestHelper.builder().build().getId(); - userId = memberTestHelper.builder().build().getId(); + adminId = memberTestHelper.builder().realName(RealName.from("김영환")).build().getId(); + userId = memberTestHelper.builder().realName(RealName.from("김기철")).build().getId(); adminToken = jwtTokenProvider.createAccessToken(ACCESS_TOKEN, adminId, ROLE_회원, ROLE_회장); userToken = jwtTokenProvider.createAccessToken(ACCESS_TOKEN, userId, ROLE_회원); @@ -268,17 +269,17 @@ class GetSeminarAttendanceTest { mockMvc.perform(get("/seminars/attendances") .cookie(new Cookie(ACCESS_TOKEN.getTokenName(), adminToken))) .andExpect(status().isOk()) - .andExpect(jsonPath("$.content[0].memberId").value(adminId)) - .andExpect(jsonPath("$.content[0].memberName").value(admin.getRealName())) - .andExpect(jsonPath("$.content[0].generation").value(admin.getGeneration())) - .andExpect(jsonPath("$.content[0].attendances[0].attendanceStatus").value(ATTENDANCE.toString())) + .andExpect(jsonPath("$.content[0].memberId").value(userId)) + .andExpect(jsonPath("$.content[0].memberName").value(user.getRealName())) + .andExpect(jsonPath("$.content[0].generation").value(user.getGeneration())) + .andExpect(jsonPath("$.content[0].attendances[0].attendanceId").value(attendanceId)) + .andExpect(jsonPath("$.content[0].attendances[0].attendanceStatus").value(LATENESS.toString())) .andExpect(jsonPath("$.content[0].attendances[0].excuse").isEmpty()) .andExpect(jsonPath("$.content[0].attendances[0].attendDate").value(LocalDate.now().toString())) - .andExpect(jsonPath("$.content[1].memberId").value(userId)) - .andExpect(jsonPath("$.content[1].memberName").value(user.getRealName())) - .andExpect(jsonPath("$.content[1].generation").value(user.getGeneration())) - .andExpect(jsonPath("$.content[1].attendances[0].attendanceId").value(attendanceId)) - .andExpect(jsonPath("$.content[1].attendances[0].attendanceStatus").value(LATENESS.toString())) + .andExpect(jsonPath("$.content[1].memberId").value(adminId)) + .andExpect(jsonPath("$.content[1].memberName").value(admin.getRealName())) + .andExpect(jsonPath("$.content[1].generation").value(admin.getGeneration())) + .andExpect(jsonPath("$.content[1].attendances[0].attendanceStatus").value(ATTENDANCE.toString())) .andExpect(jsonPath("$.content[1].attendances[0].excuse").isEmpty()) .andExpect(jsonPath("$.content[1].attendances[0].attendDate").value(LocalDate.now().toString())) .andDo(document("get-seminar-attendances",