-
Notifications
You must be signed in to change notification settings - Fork 1
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
46 changed files
with
774 additions
and
192 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
39 changes: 39 additions & 0 deletions
39
api/src/main/java/dev/hooon/booking/BookingApiController.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,39 @@ | ||
package dev.hooon.booking; | ||
|
||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.web.PageableDefault; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import dev.hooon.auth.jwt.JwtAuthorization; | ||
import dev.hooon.booking.application.BookingService; | ||
import dev.hooon.booking.dto.response.BookingListResponse; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
public class BookingApiController { | ||
|
||
private final BookingService bookingService; | ||
|
||
@GetMapping("/api/users/booking") | ||
@Operation(summary = "예매 조회 API", description = "예매를 조회한다") | ||
@ApiResponse(responseCode = "200", useReturnTypeSchema = true) | ||
public ResponseEntity<BookingListResponse> getBookings( | ||
@Parameter(hidden = true) @JwtAuthorization Long userId, | ||
@RequestParam(name = "duration") int duration, | ||
@PageableDefault(size = 10) Pageable pageable | ||
) { | ||
BookingListResponse bookingListResponse = bookingService.getBookings( | ||
userId, | ||
duration, | ||
pageable | ||
); | ||
return ResponseEntity.ok(bookingListResponse); | ||
} | ||
} |
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
98 changes: 98 additions & 0 deletions
98
api/src/test/java/dev/hooon/booking/BookingApiControllerTest.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,98 @@ | ||
package dev.hooon.booking; | ||
|
||
import static org.springframework.http.HttpHeaders.*; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.test.context.jdbc.Sql; | ||
import org.springframework.test.util.ReflectionTestUtils; | ||
import org.springframework.test.web.servlet.MockMvc; | ||
import org.springframework.test.web.servlet.ResultActions; | ||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; | ||
|
||
import dev.hooon.common.support.ApiTestSupport; | ||
import dev.hooon.user.domain.entity.User; | ||
|
||
@DisplayName("[BookingApiController API 테스트]") | ||
@Sql("/sql/user_bookings_find.sql") | ||
class BookingApiControllerTest extends ApiTestSupport { | ||
|
||
@Autowired | ||
private MockMvc mockMvc; | ||
|
||
@DisplayName("사용자는 조회 기간에 따른 예매 정보를 조회할 수 있다 - 1") | ||
@Test | ||
void getBookings_test_1() throws Exception { | ||
|
||
// given | ||
User user = new User(); | ||
ReflectionTestUtils.setField(user, "id", 1L); | ||
|
||
// when | ||
ResultActions resultActions = mockMvc.perform( | ||
MockMvcRequestBuilders | ||
.get("/api/users/booking?duration=3600&page=0&size=2") | ||
.header(AUTHORIZATION, accessToken) | ||
); | ||
|
||
// then | ||
resultActions.andExpectAll( | ||
status().isOk(), | ||
|
||
jsonPath("$.bookingList.length()").value(2), | ||
|
||
jsonPath("$.bookingList[0].bookingId").isNumber(), | ||
jsonPath("$.bookingList[0].bookingDate").isString(), | ||
jsonPath("$.bookingList[0].showInfo.showName").isString(), | ||
jsonPath("$.bookingList[0].showInfo.showDate").isString(), | ||
jsonPath("$.bookingList[0].showInfo.showRound").isNumber(), | ||
jsonPath("$.bookingList[0].showInfo.showRoundStartTime").isString(), | ||
jsonPath("$.bookingList[0].ticketNumber").isNumber(), | ||
jsonPath("$.bookingList[0].currentState").isString(), | ||
|
||
jsonPath("$.bookingList[1].bookingId").isNumber(), | ||
jsonPath("$.bookingList[1].bookingDate").isString(), | ||
jsonPath("$.bookingList[1].showInfo.showName").isString(), | ||
jsonPath("$.bookingList[1].showInfo.showDate").isString(), | ||
jsonPath("$.bookingList[1].showInfo.showRound").isNumber(), | ||
jsonPath("$.bookingList[1].showInfo.showRoundStartTime").isString(), | ||
jsonPath("$.bookingList[1].ticketNumber").isNumber(), | ||
jsonPath("$.bookingList[1].currentState").isString() | ||
); | ||
} | ||
|
||
@DisplayName("사용자는 조회 기간에 따른 예매 정보를 조회할 수 있다 - 2") | ||
@Test | ||
void getBookings_test_2() throws Exception { | ||
|
||
// given | ||
User user = new User(); | ||
ReflectionTestUtils.setField(user, "id", 1L); | ||
|
||
// when | ||
ResultActions resultActions = mockMvc.perform( | ||
MockMvcRequestBuilders | ||
.get("/api/users/booking?duration=30&page=0&size=2") | ||
.header(AUTHORIZATION, accessToken) | ||
); | ||
|
||
// then | ||
resultActions.andExpectAll( | ||
status().isOk(), | ||
|
||
jsonPath("$.bookingList.length()").value(1), | ||
|
||
jsonPath("$.bookingList[0].bookingId").isNumber(), | ||
jsonPath("$.bookingList[0].bookingDate").isString(), | ||
jsonPath("$.bookingList[0].showInfo.showName").isString(), | ||
jsonPath("$.bookingList[0].showInfo.showDate").isString(), | ||
jsonPath("$.bookingList[0].showInfo.showRound").isNumber(), | ||
jsonPath("$.bookingList[0].showInfo.showRoundStartTime").isString(), | ||
jsonPath("$.bookingList[0].ticketNumber").isNumber(), | ||
jsonPath("$.bookingList[0].currentState").isString() | ||
|
||
); | ||
} | ||
} |
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
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
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.