4.1. 회원의 일정 할당 - 성공
POST /api/v1/meetings/met123/schedules/members HTTP/1.1
Content-Type: application/json;charset=UTF-8
Content-Length: 263
-X-CSRF-TOKEN: b-5kkQYw5vF1f5507ZAH5pVSJ_QfN9YZoRjM5rPSa058IkMTWt1V8zUChMhYRqlAjL0zh6wzCpV5UbI0w3v50YWzDywdEycl
+X-CSRF-TOKEN: fHZC2TikfETI1o_ziV5lExPEamw9sHw2ZGmyOo68AgJo8GtuTURy71nHTHDl5bjE73NRIyumRw0KiRobXFHTC76KNjNexQhd
Host: localhost:8080
{
@@ -1672,7 +1706,7 @@ 4.
POST /api/v1/meetings/met123/schedules/members HTTP/1.1
Content-Type: application/json;charset=UTF-8
Content-Length: 53
-X-CSRF-TOKEN: f0BiWfuLv9Qe7JFnfquBmkQ38y9RPuqR70e4Y8bWV2pTBin6SSJSbZm_iu0z3KZXR4a1rHcO3k5mXY6833CJAqTubgxhYkrC
+X-CSRF-TOKEN: emlRLEuuW6pD876EFxlB4W-liRgj6vL46G3WnVx2vaQvx9t_HlxgH3_MOJNuxtu3dTR11leUpHob3MDV2FSz_mVD2Z1K_7oc
Host: localhost:8080
{
@@ -1771,7 +1805,7 @@ 4.3. 비회원 일정 할당 - 성공
POST /api/v1/meetings/met123/schedules/guests HTTP/1.1
Content-Type: application/json;charset=UTF-8
Content-Length: 263
-X-CSRF-TOKEN: UvrdsviOghc1Jaj6YKwb1qtP3hNNM5xlpMngHLy8MMd51uF-N8O_h8josyEYHZDNBYEv5sp483J5VvlIkayGft6EVaMd7thP
+X-CSRF-TOKEN: y0NSiO3yA78e79fBZUQ6JGBCsjTUp9pWxJEKLK6C3RHNuASy-iZmvo7KNdozirH1BmkOFFlyn1Xll-t7pqg5HJjkvyX1jjHX
Host: localhost:8080
{
@@ -1868,7 +1902,7 @@ 4.
POST /api/v1/meetings/met123/schedules/guests HTTP/1.1
Content-Type: application/json;charset=UTF-8
Content-Length: 53
-X-CSRF-TOKEN: VKu_DhKySQT4o-Uy8U7LXqEPkaOhgeSr4sjTEoKAYa-Xjr-EN5rcOSKEeDbVkdBWxGP_bZk2vMHAtYKG1v7lIbW0AJ3x6Nq9
+X-CSRF-TOKEN: RPc99OA4GINfsI_vhn-k8cY-IJHdI5Z-6zmFjcMBDZF0JxJEc8UMzYINLbZygbja5VKQw_ULDfDoFaJT3li8vvIwPKZDH3Al
Host: localhost:8080
{
@@ -1946,7 +1980,7 @@ 4.5. 회원 일정 조회 - 성공
HTTP Request
GET /api/v1/meetings/met123/schedules/members HTTP/1.1
-X-CSRF-TOKEN: lE8EQK1CkeOjNvMg_qxUq0pcfI6ATV-vhIW0DZ4A1s8pnrJjpnoxc8x784eOB8YWz4Fgyno9Ube3fmyCtbHQaPw5svsfqNFR
+X-CSRF-TOKEN: DzpISr3w-s-zvLooWDSHT8rmop4kCXZ-xyiYUM552Zc6GIBLbAh8KN_Jyv-ehI0aPRmzefjXj_wSbRBTpRj8YvscuqJYLbBz
Host: localhost:8080
@@ -2040,7 +2074,7 @@ 4.6.
HTTP Request
GET /api/v1/meetings/met123/schedules/members HTTP/1.1
-X-CSRF-TOKEN: VL-hXM4x1yvumB1MTuqU_HvghkBMzoJpt20tLQFPhJErDdVsNY-Wb6wC4xzDqisuKsegzxiGqyF6rOZEgV1IT2ArsvQZa7YI
+X-CSRF-TOKEN: U9TFiDzHZ5sZh6V6BbjDN02s9CSAmVd-iOK7Kh312uQFnfw2Yuf8v1r3Ba40vpJPMpX3B3Sc2UazoGNT64OPGCvNudMxr8gE
Host: localhost:8080
@@ -2074,7 +2108,7 @@ 4.7. 비회원 일정 조회 - 성공
HTTP Request
GET /api/v1/meetings/met123/schedules/guests?scheduleUuid=sch123 HTTP/1.1
-X-CSRF-TOKEN: FC_IVScsMYyhdf8wv3BGSBf2jKClNvYG9u4qC9zZlJNz0aXlIUmsY0UUBLyMTM4Hil1yfSbOocKcBZUrztZPau_upfBG4sGA
+X-CSRF-TOKEN: 1C0Yhue6lRhHWNyTWoVICQve7i_zZCZWrYh5QzP5wK9-CQmo5xgos97brC9qYb-jaqh8P2i6w03HU0N7ne5MIQXN-JZPOm_M
Host: localhost:8080
@@ -2154,7 +2188,7 @@ 4.
HTTP Request
GET /api/v1/meetings/met123/schedules/guests?scheduleUuid=sch123 HTTP/1.1
-X-CSRF-TOKEN: 6S5Sk-AdthcMUkRBhn-vJu88uYaKoAWH7AtO0We_RHxhtYyv2Exi9dcq0ichNHAg41KbRYoJlOS7wzKq1Tot5VHZJk1XgrqX
+X-CSRF-TOKEN: b-Q1dPkP-O7E9YjomeYy5eJigXRt-gMFZ-ihexn6mdMieKKfX90FQp05zI3pwezY-ssGg4QErExewzIoAdiQSy3LqOERQcCm
Host: localhost:8080
@@ -2228,7 +2262,7 @@ 4.9. 회원 일정 수정 - 성공
PATCH /api/v1/meetings/met123/schedules HTTP/1.1
Content-Type: application/json;charset=UTF-8
Content-Length: 235
-X-CSRF-TOKEN: zwqj3n_zabB9UJzBKOEbH79_Fq_geENvVEhqJWGbqX-rTiWW9j6X6kvGC9ZQNKX2TcwvKIdJO83WHCBCbX5ZQ1P9n0bKfEPy
+X-CSRF-TOKEN: qGbPddT6JM6wlY6nb2nTmGTgdeIn2Ej9d77Hc39NpVmfRQtxzQSsELLJEPud8-qXXkTnrlXWWIBGuinQR4f_EUd1kz37dT4U
Host: localhost:8080
{
@@ -2336,7 +2370,7 @@ 4.10.
PATCH /api/v1/meetings/met123/schedules HTTP/1.1
Content-Type: application/json;charset=UTF-8
Content-Length: 32
-X-CSRF-TOKEN: JTV_9CXw73qCrouDF9635pcj5aqjNukYl1ty0v8auMqhepFvRw0dxRXB3U2vmLniL_OD1PVByJKaD9g1rm1H4Ml8ja-WHKkK
+X-CSRF-TOKEN: m74KMPkbPzdPq_izflwftnCFmkWa6nE_n7YPoTuFxe982KcXrd8zA5x4DgdizcqHGHErjkm8tySp3BUS-tQ4xQ2399gYvMMn
Host: localhost:8080
{
@@ -2433,7 +2467,7 @@ 4.11. 비회원 일정 수정 - 성공<
PATCH /api/v1/meetings/met123/schedules/sch123 HTTP/1.1
Content-Type: application/json;charset=UTF-8
Content-Length: 235
-X-CSRF-TOKEN: uXQMEldqNMWRKyKZALY9TPygDAwXDU_XSdtl9u8Q7MUAA7i22BY8cTJSBfC8TkGtNpsJLcuWITUkNX36LbhWldwk3KA3Zt2C
+X-CSRF-TOKEN: 40rEgGALCXYm5s-zfu1osRXJjq0NZGozSycVhrY_OizvfM4KgiuhsFY9ME4L3vnRScBcgiXxo88-UlMeKkV25NNaXByNTvs8
Host: localhost:8080
{
@@ -2545,7 +2579,7 @@ 4.
PATCH /api/v1/meetings/met123/schedules/sch123 HTTP/1.1
Content-Type: application/json;charset=UTF-8
Content-Length: 32
-X-CSRF-TOKEN: j6aKfcvZoope4vUmnmdu7lfgapH7Vy1eFeDrXqRc5fxDMan8v8WySfrol71z1JQV-Epa3meCR_PPYxRzcdWJbJVs051zB8jM
+X-CSRF-TOKEN: jkbedfcIXIrRacqNcKGVTsBsw53yPTTfVw30dV0v_LMId7rA63K9Q8FpZLz8DPy_QoyhfKYN7v_ECgzyMjuXQmgWyYJuQIv4
Host: localhost:8080
{
diff --git a/src/test/java/com/dnd/jjakkak/domain/meeting/MeetingDummy.java b/src/test/java/com/dnd/jjakkak/domain/meeting/MeetingDummy.java
index df49914..d0f4266 100644
--- a/src/test/java/com/dnd/jjakkak/domain/meeting/MeetingDummy.java
+++ b/src/test/java/com/dnd/jjakkak/domain/meeting/MeetingDummy.java
@@ -3,6 +3,8 @@
import com.dnd.jjakkak.domain.meeting.dto.request.MeetingCreateRequestDto;
import com.dnd.jjakkak.domain.meeting.dto.response.*;
import com.dnd.jjakkak.domain.meeting.entity.Meeting;
+import com.dnd.jjakkak.global.common.PageInfo;
+import com.dnd.jjakkak.global.common.PagedResponse;
import org.springframework.test.util.ReflectionTestUtils;
import java.time.LocalDate;
@@ -64,7 +66,7 @@ public static MeetingInfoResponseDto createInfoResponse() {
return responseDto;
}
- public static MeetingTimeResponseDto createMeetingTimeResponseDto() {
+ public static PagedResponse createMeetingTimeResponseDto() {
MeetingTime response = MeetingTime.builder()
.startTime(LocalDateTime.of(2024, 8, 27, 10, 0))
.endTime(LocalDateTime.of(2024, 8, 27, 12, 0))
@@ -79,7 +81,9 @@ public static MeetingTimeResponseDto createMeetingTimeResponseDto() {
MeetingTimeResponseDto responseDto = new MeetingTimeResponseDto(2, false, startDate, endDate);
responseDto.addMeetingTimeList(List.of(response));
- return responseDto;
+ PageInfo pageInfo = new PageInfo(1, 1, 1, 1);
+
+ return new PagedResponse<>(responseDto, pageInfo);
}
diff --git a/src/test/java/com/dnd/jjakkak/domain/meeting/controller/MeetingControllerTest.java b/src/test/java/com/dnd/jjakkak/domain/meeting/controller/MeetingControllerTest.java
index c78e018..cf07259 100644
--- a/src/test/java/com/dnd/jjakkak/domain/meeting/controller/MeetingControllerTest.java
+++ b/src/test/java/com/dnd/jjakkak/domain/meeting/controller/MeetingControllerTest.java
@@ -7,6 +7,7 @@
import com.dnd.jjakkak.domain.meeting.service.MeetingService;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@@ -15,6 +16,7 @@
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
+import java.time.LocalDateTime;
import java.util.List;
import static org.mockito.ArgumentMatchers.any;
@@ -22,8 +24,7 @@
import static org.mockito.Mockito.when;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*;
import static org.springframework.restdocs.payload.PayloadDocumentation.*;
-import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName;
-import static org.springframework.restdocs.request.RequestDocumentation.pathParameters;
+import static org.springframework.restdocs.request.RequestDocumentation.*;
import static org.springframework.restdocs.snippet.Attributes.key;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@@ -43,6 +44,8 @@ class MeetingControllerTest extends AbstractRestDocsTest {
@Autowired
ObjectMapper objectMapper = new ObjectMapper().registerModule(new JavaTimeModule());
+ @Autowired
+ private ParameterNamesModule parameterNamesModule;
@Test
@@ -151,37 +154,49 @@ void getMeetingInfo_success() throws Exception {
void getBestTime_success() throws Exception {
String meetingUuid = "123ABC";
- when(meetingService.getMeetingTimes(anyString(), any()))
+ when(meetingService.getMeetingTimes(anyString(), any(), any()))
.thenReturn(MeetingDummy.createMeetingTimeResponseDto());
+ String now = LocalDateTime.now().toString();
+
mockMvc.perform(get("/api/v1/meetings/{meetingUuid}/times", meetingUuid)
.param("sort", "COUNT")
+ .param("request_time", now)
.contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON))
.andExpectAll(
status().isOk(),
- jsonPath("$.numberOfPeople").value(2),
- jsonPath("$.isAnonymous").value(false),
- jsonPath("$.meetingStartDate").value("2024-08-27"),
- jsonPath("$.meetingEndDate").value("2024-08-29"),
- jsonPath("$.meetingTimeList[0].memberNames.[0]").value("고래"),
- jsonPath("$.meetingTimeList[0].memberNames.[1]").value("상어"),
- jsonPath("$.meetingTimeList[0].startTime").value("2024-08-27T10:00:00"),
- jsonPath("$.meetingTimeList[0].endTime").value("2024-08-27T12:00:00"),
- jsonPath("$.meetingTimeList[0].rank").value(1.0))
+ jsonPath("$.data.numberOfPeople").value(2),
+ jsonPath("$.data.isAnonymous").value(false),
+ jsonPath("$.data.meetingStartDate").value("2024-08-27"),
+ jsonPath("$.data.meetingEndDate").value("2024-08-29"),
+ jsonPath("$.data.meetingTimeList[0].memberNames.[0]").value("고래"),
+ jsonPath("$.data.meetingTimeList[0].memberNames.[1]").value("상어"),
+ jsonPath("$.data.meetingTimeList[0].startTime").value("2024-08-27T10:00:00"),
+ jsonPath("$.data.meetingTimeList[0].endTime").value("2024-08-27T12:00:00"),
+ jsonPath("$.data.meetingTimeList[0].rank").value(1.0))
.andDo(restDocs.document(
pathParameters(
parameterWithName("meetingUuid").description("모임 UUID")
),
+ queryParameters(
+ parameterWithName("request_time").description("요청 시간"),
+ parameterWithName("sort").description("정렬 기준 (COUNT, RANK)")
+ ),
responseFields(
- fieldWithPath("numberOfPeople").description("총 인원 수"),
- fieldWithPath("isAnonymous").description("익명 여부"),
- fieldWithPath("meetingStartDate").description("모임 시작 날짜"),
- fieldWithPath("meetingEndDate").description("모임 종료 날짜"),
- fieldWithPath("meetingTimeList[].memberNames").description("멤버 이름 리스트"),
- fieldWithPath("meetingTimeList[].startTime").description("시작 시간"),
- fieldWithPath("meetingTimeList[].endTime").description("종료 시간"),
- fieldWithPath("meetingTimeList[].rank").description("우선순위 (오름차순)")
+ fieldWithPath("data.numberOfPeople").description("총 인원 수"),
+ fieldWithPath("data.isAnonymous").description("익명 여부"),
+ fieldWithPath("data.meetingStartDate").description("모임 시작 날짜"),
+ fieldWithPath("data.meetingEndDate").description("모임 종료 날짜"),
+ fieldWithPath("data.requestTime").description("요청 시간"),
+ fieldWithPath("data.meetingTimeList[].memberNames").description("멤버 이름 리스트"),
+ fieldWithPath("data.meetingTimeList[].startTime").description("시작 시간"),
+ fieldWithPath("data.meetingTimeList[].endTime").description("종료 시간"),
+ fieldWithPath("data.meetingTimeList[].rank").description("우선순위 (오름차순)"),
+ fieldWithPath("pageInfo.page").description("현재 페이지"),
+ fieldWithPath("pageInfo.size").description("페이지 크기"),
+ fieldWithPath("pageInfo.totalElements").description("총 요소 수"),
+ fieldWithPath("pageInfo.totalPages").description("총 페이지 수")
))
);
}
diff --git a/src/test/java/com/dnd/jjakkak/domain/meeting/repository/MeetingRepositoryTest.java b/src/test/java/com/dnd/jjakkak/domain/meeting/repository/MeetingRepositoryTest.java
index df308f2..c6bd173 100644
--- a/src/test/java/com/dnd/jjakkak/domain/meeting/repository/MeetingRepositoryTest.java
+++ b/src/test/java/com/dnd/jjakkak/domain/meeting/repository/MeetingRepositoryTest.java
@@ -7,16 +7,18 @@
import com.dnd.jjakkak.domain.meeting.dto.response.MeetingTime;
import com.dnd.jjakkak.domain.meeting.dto.response.MeetingTimeResponseDto;
import com.dnd.jjakkak.domain.meeting.entity.Meeting;
-import com.dnd.jjakkak.domain.meeting.enums.MeetingSort;
import com.dnd.jjakkak.domain.meetingcategory.entity.MeetingCategory;
import com.dnd.jjakkak.domain.member.entity.Member;
import com.dnd.jjakkak.domain.schedule.entity.Schedule;
+import com.dnd.jjakkak.global.common.PageInfo;
+import com.dnd.jjakkak.global.common.PagedResponse;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager;
+import org.springframework.data.domain.Pageable;
import org.springframework.test.util.ReflectionTestUtils;
import java.time.LocalDate;
@@ -167,6 +169,8 @@ void getMeetingInfo() {
@DisplayName("모임 시간 조회 - COUNT 기준 정렬")
void getMeetingTimes_defaultSort() {
+ LocalDateTime now = LocalDateTime.now();
+
// given
Schedule schedule1 = Schedule.builder()
.meeting(testMeeting)
@@ -174,6 +178,8 @@ void getMeetingTimes_defaultSort() {
.scheduleUuid("123abc")
.build();
+ schedule1.changeAssignedAt(now);
+
em.persist(schedule1);
@@ -200,6 +206,8 @@ void getMeetingTimes_defaultSort() {
.scheduleUuid("456def")
.build();
+ schedule2.changeAssignedAt(now);
+
em.persist(schedule2);
DateOfSchedule dateOfSchedule3 = DateOfSchedule.builder()
@@ -216,18 +224,30 @@ void getMeetingTimes_defaultSort() {
String uuid = "123abc";
// when
- MeetingTimeResponseDto actual = meetingRepository.getMeetingTimes(uuid, MeetingSort.COUNT);
+ Pageable pageable = Pageable.ofSize(10);
+ PagedResponse actual = meetingRepository.getMeetingTimes(uuid, pageable, LocalDateTime.now());
// then
- assertEquals(2, actual.getMeetingTimeList().size());
- MeetingTime primary = actual.getMeetingTimeList().get(0);
+ PageInfo pageInfo = actual.getPageInfo();
+ assertAll(
+ () -> assertEquals(2, pageInfo.getTotalElements()),
+ () -> assertEquals(1, pageInfo.getTotalPages())
+ );
+
+ MeetingTimeResponseDto data = actual.getData();
+ assertAll(
+ () -> assertEquals(2, data.getMeetingTimeList().size())
+ );
+
+
+ MeetingTime primary = data.getMeetingTimeList().get(0);
assertAll(
() -> assertEquals(dateOfSchedule1.getDateOfScheduleStart(), primary.getStartTime()),
() -> assertEquals(dateOfSchedule1.getDateOfScheduleEnd(), primary.getEndTime())
);
- MeetingTime secondary = actual.getMeetingTimeList().get(1);
+ MeetingTime secondary = data.getMeetingTimeList().get(1);
assertAll(
() -> assertEquals(dateOfSchedule2.getDateOfScheduleStart(), secondary.getStartTime()),
() -> assertEquals(dateOfSchedule2.getDateOfScheduleEnd(), secondary.getEndTime())
@@ -239,6 +259,7 @@ void getMeetingTimes_defaultSort() {
@DisplayName("모임 시간 조회 - LATEST 기준 정렬")
void getMeetingTimes_latestSort() {
// given
+ LocalDateTime now = LocalDateTime.now();
Schedule schedule1 = Schedule.builder()
.meeting(testMeeting)
@@ -246,6 +267,7 @@ void getMeetingTimes_latestSort() {
.scheduleUuid("123abc")
.build();
+ schedule1.changeAssignedAt(now);
DateOfSchedule dateOfSchedule1 = DateOfSchedule.builder()
.schedule(schedule1)
@@ -263,6 +285,8 @@ void getMeetingTimes_latestSort() {
.scheduleUuid("456def")
.build();
+ schedule2.changeAssignedAt(now);
+
DateOfSchedule dateOfSchedule2 = DateOfSchedule.builder()
.schedule(schedule2)
.dateOfScheduleRank(2)
@@ -278,18 +302,26 @@ void getMeetingTimes_latestSort() {
String uuid = "123abc";
// when
- MeetingTimeResponseDto actual = meetingRepository.getMeetingTimes(uuid, MeetingSort.LATEST);
+ Pageable pageable = Pageable.ofSize(10);
+ PagedResponse actual = meetingRepository.getMeetingTimes(uuid, pageable, LocalDateTime.now());
// then
- assertEquals(2, actual.getMeetingTimeList().size());
+ PageInfo pageInfo = actual.getPageInfo();
+ assertAll(
+ () -> assertEquals(2, pageInfo.getTotalElements()),
+ () -> assertEquals(1, pageInfo.getTotalPages())
+ );
+
+ MeetingTimeResponseDto data = actual.getData();
+ assertEquals(2, data.getMeetingTimeList().size());
- MeetingTime primary = actual.getMeetingTimeList().get(0);
+ MeetingTime primary = data.getMeetingTimeList().get(0);
assertAll(
() -> assertEquals(dateOfSchedule2.getDateOfScheduleStart(), primary.getStartTime()),
() -> assertEquals(dateOfSchedule2.getDateOfScheduleEnd(), primary.getEndTime())
);
- MeetingTime secondary = actual.getMeetingTimeList().get(1);
+ MeetingTime secondary = data.getMeetingTimeList().get(1);
assertAll(
() -> assertEquals(dateOfSchedule1.getDateOfScheduleStart(), secondary.getStartTime()),
() -> assertEquals(dateOfSchedule1.getDateOfScheduleEnd(), secondary.getEndTime())
@@ -328,7 +360,6 @@ void getParticipant() {
em.persist(schedule2);
em.flush();
- // em.clear(); // clear를 사용하면 엔티티가 detached 상태가 되므로 주의 필요
String uuid = "123abc";
diff --git a/src/test/java/com/dnd/jjakkak/domain/meeting/service/MeetingServiceTest.java b/src/test/java/com/dnd/jjakkak/domain/meeting/service/MeetingServiceTest.java
index 5f055e0..e3732ee 100644
--- a/src/test/java/com/dnd/jjakkak/domain/meeting/service/MeetingServiceTest.java
+++ b/src/test/java/com/dnd/jjakkak/domain/meeting/service/MeetingServiceTest.java
@@ -9,7 +9,6 @@
import com.dnd.jjakkak.domain.meeting.dto.response.MeetingTime;
import com.dnd.jjakkak.domain.meeting.dto.response.MeetingTimeResponseDto;
import com.dnd.jjakkak.domain.meeting.entity.Meeting;
-import com.dnd.jjakkak.domain.meeting.enums.MeetingSort;
import com.dnd.jjakkak.domain.meeting.exception.MeetingNotFoundException;
import com.dnd.jjakkak.domain.meeting.repository.MeetingRepository;
import com.dnd.jjakkak.domain.meetingcategory.repository.MeetingCategoryRepository;
@@ -17,14 +16,17 @@
import com.dnd.jjakkak.domain.member.entity.Member;
import com.dnd.jjakkak.domain.member.repository.MemberRepository;
import com.dnd.jjakkak.domain.schedule.service.ScheduleService;
+import com.dnd.jjakkak.global.common.PagedResponse;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.data.domain.Pageable;
import org.springframework.test.util.ReflectionTestUtils;
+import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;
@@ -182,26 +184,28 @@ void testGetMeetingBestTime_Success() {
// given
String uuid = "1234abcd";
- MeetingTimeResponseDto expected = MeetingDummy.createMeetingTimeResponseDto();
+ PagedResponse expected = MeetingDummy.createMeetingTimeResponseDto();
- when(meetingRepository.getMeetingTimes(anyString(), any()))
+ when(meetingRepository.getMeetingTimes(anyString(), any(), any()))
.thenReturn(expected);
when(meetingRepository.existsByMeetingUuid(anyString()))
.thenReturn(true);
// when
- MeetingTimeResponseDto actual = meetingService.getMeetingTimes(uuid, MeetingSort.COUNT);
+ Pageable pageable = Pageable.ofSize(10);
+ LocalDateTime now = LocalDateTime.now();
+ PagedResponse actual = meetingService.getMeetingTimes(uuid, pageable, now);
// then
assertAll(
- () -> assertEquals(expected.getNumberOfPeople(), actual.getNumberOfPeople()),
- () -> assertEquals(expected.getIsAnonymous(), actual.getIsAnonymous())
+ () -> assertEquals(expected.getData().getNumberOfPeople(), actual.getData().getNumberOfPeople()),
+ () -> assertEquals(expected.getData().getIsAnonymous(), actual.getData().getIsAnonymous())
);
- assertEquals(expected.getMeetingTimeList().size(), actual.getMeetingTimeList().size());
- MeetingTime expectedTime = expected.getMeetingTimeList().get(0);
- MeetingTime actualTime = actual.getMeetingTimeList().get(0);
+ assertEquals(expected.getData().getMeetingTimeList().size(), actual.getData().getMeetingTimeList().size());
+ MeetingTime expectedTime = expected.getData().getMeetingTimeList().get(0);
+ MeetingTime actualTime = actual.getData().getMeetingTimeList().get(0);
assertAll(
() -> assertEquals(expectedTime.getMemberNames(), actualTime.getMemberNames()),
@@ -210,7 +214,7 @@ void testGetMeetingBestTime_Success() {
() -> assertEquals(expectedTime.getRank(), actualTime.getRank())
);
- verify(meetingRepository, times(1)).getMeetingTimes(uuid, MeetingSort.COUNT);
+ verify(meetingRepository, times(1)).getMeetingTimes(uuid, pageable, now);
verify(meetingRepository, times(1)).existsByMeetingUuid(uuid);
}
@@ -225,7 +229,7 @@ void testGetMeetingBestTime_Fail() {
// expected
assertThrows(MeetingNotFoundException.class,
- () -> meetingService.getMeetingTimes(uuid, MeetingSort.COUNT));
+ () -> meetingService.getMeetingTimes(uuid, Pageable.ofSize(10), LocalDateTime.now()));
}
@Test