-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
234 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/main/java/com/example/busan/reservation/dto/FindReservationRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.example.busan.reservation.dto; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
public record FindReservationRequest(LocalDateTime start, LocalDateTime end) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,7 +155,7 @@ paths: | |
현재 유저 정보 조회하기: | ||
value: "{\"name\":\"연어\",\"phone\":\"01012341234\",\"email\":\"\ | ||
[email protected]\",\"role\":\"USER\",\"company\":\"우형\",\"region\"\ | ||
:\"BUSAN\",\"createdAt\":\"2024-01-13T17:45:12.402886\"}" | ||
:\"BUSAN\",\"createdAt\":\"2024-01-13T18:38:16.899219\"}" | ||
post: | ||
tags: | ||
- members | ||
|
@@ -276,18 +276,18 @@ paths: | |
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/reservations-2055281597' | ||
$ref: '#/components/schemas/reservations-all-2055281597' | ||
examples: | ||
자신의 회의실 예약 목록 최신 순으로 보기: | ||
value: "{\"content\":[{\"id\":1,\"status\":\"RESERVED\",\"cancelReason\"\ | ||
:null,\"startTime\":\"2024-01-13T17:45:14.276581\",\"endTime\"\ | ||
:\"2024-01-13T19:45:14.276586\",\"name\":\"황재현\",\"phone\":\"\ | ||
01012341234\",\"reservedAt\":\"2024-01-13T17:45:14.276596\",\"\ | ||
:null,\"startTime\":\"2024-01-13T18:38:18.68911\",\"endTime\"\ | ||
:\"2024-01-13T20:38:18.689115\",\"name\":\"황재현\",\"phone\":\"\ | ||
01012341234\",\"reservedAt\":\"2024-01-13T18:38:18.689124\",\"\ | ||
roomId\":1,\"roomName\":\"대회의실\",\"company\":\"요기요\"},{\"id\"\ | ||
:2,\"status\":\"CANCELED\",\"cancelReason\":\"쓰기 싫어졌어요..\",\"\ | ||
startTime\":\"2024-01-13T17:45:14.276604\",\"endTime\":\"2024-01-13T19:45:14.276606\"\ | ||
startTime\":\"2024-01-13T18:38:18.689133\",\"endTime\":\"2024-01-13T20:38:18.689134\"\ | ||
,\"name\":\"황재현\",\"phone\":\"01012341234\",\"reservedAt\":\"\ | ||
2024-01-13T17:45:14.276608\",\"roomId\":1,\"roomName\":\"대회의실\"\ | ||
2024-01-13T18:38:18.689137\",\"roomId\":1,\"roomName\":\"대회의실\"\ | ||
,\"company\":\"토스뱅크\"}],\"pageable\":\"INSTANCE\",\"last\":true,\"\ | ||
totalPages\":1,\"totalElements\":2,\"first\":true,\"size\":2,\"\ | ||
number\":0,\"sort\":{\"empty\":true,\"sorted\":false,\"unsorted\"\ | ||
|
@@ -308,6 +308,55 @@ paths: | |
responses: | ||
"201": | ||
description: "201" | ||
/reservations/all: | ||
get: | ||
tags: | ||
- reservations | ||
operationId: 전체 회의실 예약 목록 최신 순으로 보기 | ||
parameters: | ||
- name: page | ||
in: query | ||
description: 페이지는 1부터 시작 (디폴트값 1) | ||
required: false | ||
schema: | ||
type: string | ||
- name: size | ||
in: query | ||
description: 페이지별 사이즈 (디폴트값 10) | ||
required: false | ||
schema: | ||
type: string | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/reservations-all1582432150' | ||
examples: | ||
전체 회의실 예약 목록 최신 순으로 보기: | ||
value: "{\"start\":\"2024-01-13T18:38:18.800506\",\"end\":\"2024-01-13T18:38:18.800508\"\ | ||
}" | ||
responses: | ||
"200": | ||
description: "200" | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/reservations-all-2055281597' | ||
examples: | ||
전체 회의실 예약 목록 최신 순으로 보기: | ||
value: "{\"content\":[{\"id\":1,\"status\":\"RESERVED\",\"cancelReason\"\ | ||
:null,\"startTime\":\"2024-01-13T18:38:18.800459\",\"endTime\"\ | ||
:\"2024-01-13T20:38:18.800463\",\"name\":\"황재현\",\"phone\":\"\ | ||
01012341234\",\"reservedAt\":\"2024-01-13T18:38:18.80047\",\"\ | ||
roomId\":1,\"roomName\":\"대회의실\",\"company\":\"요기요\"},{\"id\"\ | ||
:2,\"status\":\"CANCELED\",\"cancelReason\":\"쓰기 싫어졌어요..\",\"\ | ||
startTime\":\"2024-01-13T18:38:18.800473\",\"endTime\":\"2024-01-13T20:38:18.800474\"\ | ||
,\"name\":\"황재현\",\"phone\":\"01012341234\",\"reservedAt\":\"\ | ||
2024-01-13T18:38:18.800477\",\"roomId\":1,\"roomName\":\"대회의실\"\ | ||
,\"company\":\"토스뱅크\"}],\"pageable\":\"INSTANCE\",\"last\":true,\"\ | ||
totalPages\":1,\"totalElements\":2,\"first\":true,\"size\":2,\"\ | ||
number\":0,\"sort\":{\"empty\":true,\"sorted\":false,\"unsorted\"\ | ||
:true},\"numberOfElements\":2,\"empty\":false}" | ||
/reservations/{reservationId}: | ||
put: | ||
tags: | ||
|
@@ -441,6 +490,15 @@ components: | |
isDuplicated: | ||
type: boolean | ||
description: 중복 여부 | ||
reservations-all1582432150: | ||
type: object | ||
properties: | ||
start: | ||
type: string | ||
description: 시작일(포함) | ||
end: | ||
type: string | ||
description: 마지막일(포함) | ||
rooms1328389190: | ||
type: array | ||
items: | ||
|
@@ -568,7 +626,7 @@ components: | |
reason: | ||
type: string | ||
description: 취소 사유 | ||
reservations-2055281597: | ||
reservations-all-2055281597: | ||
type: object | ||
properties: | ||
number: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
import com.example.busan.reservation.domain.Status; | ||
import com.example.busan.reservation.dto.CancelReservationRequest; | ||
import com.example.busan.reservation.dto.CreateReservationRequest; | ||
import com.example.busan.reservation.dto.FindReservationRequest; | ||
import com.example.busan.reservation.dto.ReservationResponse; | ||
import com.example.busan.reservation.dto.UpdateReservationRequest; | ||
import com.example.busan.reservation.service.ReservationService; | ||
|
@@ -125,8 +126,8 @@ void update() throws Exception { | |
} | ||
|
||
@Test | ||
@DisplayName("회의실 예약 목록 조회하기") | ||
void findAll() throws Exception { | ||
@DisplayName("자신의 회의실 예약 목록 조회하기") | ||
void findAllByCurrentLoggedInMember() throws Exception { | ||
//given | ||
httpSession.setAttribute(AuthController.AUTHORIZATION, new Authentication("[email protected]", Role.USER)); | ||
|
||
|
@@ -137,7 +138,7 @@ void findAll() throws Exception { | |
2L, Status.CANCELED, "쓰기 싫어졌어요..", LocalDateTime.now(), LocalDateTime.now().plusHours(2), | ||
"황재현", "01012341234", LocalDateTime.now(), 1L, "대회의실", "토스뱅크"); | ||
|
||
given(reservationService.findAll(any(), any())) | ||
given(reservationService.findAllByCurrentLoggedInMember(any(), any())) | ||
.willReturn(new PageImpl<>(List.of(reservation1, reservation2))); | ||
|
||
//when | ||
|
@@ -179,4 +180,65 @@ void findAll() throws Exception { | |
//then | ||
assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value()); | ||
} | ||
|
||
@Test | ||
@DisplayName("전체 회의실 예약 목록 조회하기") | ||
void findAll() throws Exception { | ||
//given | ||
final ReservationResponse reservation1 = new ReservationResponse( | ||
1L, Status.RESERVED, null, LocalDateTime.now(), LocalDateTime.now().plusHours(2), | ||
"황재현", "01012341234", LocalDateTime.now(), 1L, "대회의실", "요기요"); | ||
final ReservationResponse reservation2 = new ReservationResponse( | ||
2L, Status.CANCELED, "쓰기 싫어졌어요..", LocalDateTime.now(), LocalDateTime.now().plusHours(2), | ||
"황재현", "01012341234", LocalDateTime.now(), 1L, "대회의실", "토스뱅크"); | ||
final String request = objectMapper.writeValueAsString( | ||
new FindReservationRequest(LocalDateTime.now(), LocalDateTime.now())); | ||
|
||
given(reservationService.findAll(any(), any())) | ||
.willReturn(new PageImpl<>(List.of(reservation1, reservation2))); | ||
|
||
//when | ||
final MockHttpServletResponse response = mockMvc.perform( | ||
get("/reservations/all") | ||
.queryParam("page", "1") | ||
.queryParam("size", "10") | ||
.session(httpSession) | ||
.content(request) | ||
.contentType(APPLICATION_JSON)) | ||
.andDo(print()) | ||
.andDo(document("전체 회의실 예약 목록 최신 순으로 보기", | ||
queryParameters( | ||
parameterWithName("page").description("페이지는 1부터 시작 (디폴트값 1)").optional(), | ||
parameterWithName("size").description("페이지별 사이즈 (디폴트값 10)").optional()), | ||
requestFields( | ||
fieldWithPath("start").description("시작일(포함)"), | ||
fieldWithPath("end").description("마지막일(포함)")), | ||
responseFields( | ||
fieldWithPath("content.[].id").description("예약 ID"), | ||
fieldWithPath("content.[].status").description("예약 상태"), | ||
fieldWithPath("content.[].cancelReason").description("취소 상태일 경우 취소 이유(취소가 아니면 null)").optional(), | ||
fieldWithPath("content.[].startTime").description("시작 시각"), | ||
fieldWithPath("content.[].endTime").description("종료 시각"), | ||
fieldWithPath("content.[].name").description("예약자 성함"), | ||
fieldWithPath("content.[].phone").description("예약자 휴대폰 번호"), | ||
fieldWithPath("content.[].reservedAt").description("예약 일시"), | ||
fieldWithPath("content.[].roomId").description("회의실 ID"), | ||
fieldWithPath("content.[].company").description("예약자 회사"), | ||
fieldWithPath("content.[].roomName").description("회의실 이름"), | ||
fieldWithPath("last").description("마지막 페이지인지"), | ||
fieldWithPath("first").description("첫 페이지인지"), | ||
fieldWithPath("empty").description("빈 데이터인지"), | ||
fieldWithPath("totalPages").description("전체 페이지 개수"), | ||
fieldWithPath("totalElements").description("전체 DB 데이터 요소 개수"), | ||
fieldWithPath("numberOfElements").description("현재 응답 데이터 요소 개수"), | ||
fieldWithPath("size").description("한 페이지당 사이즈"), | ||
fieldWithPath("number").description("현재 페이지"), | ||
fieldWithPath("pageable").description("요청한 페이지네이션 정보").ignored(), | ||
fieldWithPath("sort.*").description("정렬 정보").ignored()))) | ||
.andReturn() | ||
.getResponse(); | ||
|
||
//then | ||
assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.