diff --git a/src/main/java/com/moabam/api/application/room/RoomService.java b/src/main/java/com/moabam/api/application/room/RoomService.java index 1bcc0f47..75a761cd 100644 --- a/src/main/java/com/moabam/api/application/room/RoomService.java +++ b/src/main/java/com/moabam/api/application/room/RoomService.java @@ -3,7 +3,6 @@ import static com.moabam.api.domain.room.RoomType.*; import static com.moabam.global.error.model.ErrorMessage.*; -import java.time.LocalDate; import java.util.List; import org.apache.commons.lang3.StringUtils; @@ -148,12 +147,12 @@ public void deportParticipant(Long managerId, Long roomId, Long memberId) { member.exitRoom(room.getRoomType()); } - public String checkIfParticipant(Long memberId, Long roomId) { + public boolean checkIfParticipant(Long memberId, Long roomId) { try { getParticipant(memberId, roomId); - return String.format("https://dev-api.moabam.com/%d/%s", roomId, LocalDate.now()); + return true; } catch (NotFoundException e) { - return String.format("https://dev-api.moabam.com/%d/un-joined", roomId); + return false; } } diff --git a/src/main/java/com/moabam/api/presentation/RoomController.java b/src/main/java/com/moabam/api/presentation/RoomController.java index 68f74388..ce4725e3 100644 --- a/src/main/java/com/moabam/api/presentation/RoomController.java +++ b/src/main/java/com/moabam/api/presentation/RoomController.java @@ -1,6 +1,5 @@ package com.moabam.api.presentation; -import java.io.IOException; import java.time.LocalDate; import java.util.List; @@ -37,7 +36,6 @@ import com.moabam.global.auth.annotation.Auth; import com.moabam.global.auth.model.AuthMember; -import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; @@ -91,11 +89,9 @@ public void exitRoom(@Auth AuthMember authMember, @PathVariable("roomId") Long r } @GetMapping("/{roomId}/check") - @ResponseStatus(HttpStatus.FOUND) - public void checkIfParticipant(@Auth AuthMember authMember, @PathVariable("roomId") Long roomId, - HttpServletResponse response) throws IOException { - String urlToRedirect = roomService.checkIfParticipant(authMember.id(), roomId); - response.sendRedirect(urlToRedirect); + @ResponseStatus(HttpStatus.OK) + public boolean checkIfParticipant(@Auth AuthMember authMember, @PathVariable("roomId") Long roomId) { + return roomService.checkIfParticipant(authMember.id(), roomId); } @GetMapping("/{roomId}/un-joined") diff --git a/src/test/java/com/moabam/api/presentation/RoomControllerTest.java b/src/test/java/com/moabam/api/presentation/RoomControllerTest.java index ebfbfd16..265450c4 100644 --- a/src/test/java/com/moabam/api/presentation/RoomControllerTest.java +++ b/src/test/java/com/moabam/api/presentation/RoomControllerTest.java @@ -971,7 +971,7 @@ void get_join_history_success() throws Exception { .andDo(print()); } - @DisplayName("참여중이지 않은 방에 대한 리다이렉션 반환 성공") + @DisplayName("참여중이지 않은 방에 대한 확인 성공") @WithMember @Test void check_if_participant_false_success() throws Exception { @@ -981,8 +981,7 @@ void check_if_participant_false_success() throws Exception { // expected mockMvc.perform(get("/rooms/" + savedRoom.getId() + "/check")) - .andExpect(status().isFound()) - .andExpect(redirectedUrl(String.format("https://dev-api.moabam.com/%d/un-joined", savedRoom.getId()))) + .andExpect(status().isOk()) .andDo(print()); } @@ -1021,7 +1020,7 @@ void get_un_joined_room_details() throws Exception { .andDo(print()); } - @DisplayName("참여중인 방에 대한 리다이렉션 반환 성공") + @DisplayName("참여중인 방에 대한 확인 성공") @WithMember @Test void check_if_participant_true_success() throws Exception { @@ -1034,9 +1033,7 @@ void check_if_participant_true_success() throws Exception { // expected mockMvc.perform(get("/rooms/" + savedRoom.getId() + "/check")) - .andExpect(status().isFound()) - .andExpect( - redirectedUrl(String.format("https://dev-api.moabam.com/%d/%s", savedRoom.getId(), LocalDate.now()))) + .andExpect(status().isOk()) .andDo(print()); }