-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* test(AttendeeFixture): 참가자용 테스트 fixture 추가 * feat(MeetingService): 약속 생성 결과 조회 로직 추가 * feat(MeetingController): 약속 생성 결과 조회 컨트롤러 추가 * refactor(MeetingController): 불분명한 메서드명 변경 * refactor(MeetingController): API Path 수정 및 불분명한 명명 수정 * test(MeetingController): API Path 수정 및 UUID 오류 발생시 응답 코드 테스트 추가 * refactor(MeetingService): 사용하지 않는 어노테이션 및 Enum 값 제거
- Loading branch information
Showing
7 changed files
with
180 additions
and
9 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
31 changes: 31 additions & 0 deletions
31
backend/src/main/java/com/woowacourse/momo/exception/code/MeetingErrorCode.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,31 @@ | ||
package com.woowacourse.momo.exception.code; | ||
|
||
import org.springframework.http.HttpStatus; | ||
|
||
public enum MeetingErrorCode implements ErrorCodeType { | ||
|
||
INVALID_UUID(HttpStatus.BAD_REQUEST, "유효하지 않은 UUID 입니다."); | ||
|
||
private final HttpStatus httpStatus; | ||
private final String message; | ||
|
||
MeetingErrorCode(HttpStatus httpStatus, String message) { | ||
this.httpStatus = httpStatus; | ||
this.message = message; | ||
} | ||
|
||
@Override | ||
public HttpStatus httpStatus() { | ||
return httpStatus; | ||
} | ||
|
||
@Override | ||
public String message() { | ||
return message; | ||
} | ||
|
||
@Override | ||
public String errorCode() { | ||
return name(); | ||
} | ||
} |
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
10 changes: 10 additions & 0 deletions
10
backend/src/main/java/com/woowacourse/momo/service/meeting/dto/MeetingSharingResponse.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,10 @@ | ||
package com.woowacourse.momo.service.meeting.dto; | ||
|
||
import com.woowacourse.momo.domain.meeting.Meeting; | ||
|
||
public record MeetingSharingResponse(String uuid) { | ||
|
||
public static MeetingSharingResponse from(Meeting meeting) { | ||
return new MeetingSharingResponse(meeting.getUuid()); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
backend/src/test/java/com/woowacourse/momo/controller/meeting/MeetingControllerTest.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,62 @@ | ||
package com.woowacourse.momo.controller.meeting; | ||
|
||
import com.woowacourse.momo.domain.attendee.AttendeeRepository; | ||
import com.woowacourse.momo.domain.meeting.Meeting; | ||
import com.woowacourse.momo.domain.meeting.MeetingRepository; | ||
import com.woowacourse.momo.fixture.AttendeeFixture; | ||
import com.woowacourse.momo.fixture.MeetingFixture; | ||
import com.woowacourse.momo.support.IsolateDatabase; | ||
import io.restassured.RestAssured; | ||
import io.restassured.http.ContentType; | ||
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.context.SpringBootTest; | ||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; | ||
import org.springframework.boot.test.web.server.LocalServerPort; | ||
import org.springframework.http.HttpStatus; | ||
|
||
@IsolateDatabase | ||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) | ||
class MeetingControllerTest { | ||
|
||
@LocalServerPort | ||
private int port; | ||
|
||
@Autowired | ||
private AttendeeRepository attendeeRepository; | ||
|
||
@Autowired | ||
private MeetingRepository meetingRepository; | ||
|
||
private Meeting meeting; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
RestAssured.port = port; | ||
|
||
meeting = meetingRepository.save(MeetingFixture.COFFEE.create()); | ||
attendeeRepository.save(AttendeeFixture.HOST_JAZZ.create(meeting)); | ||
} | ||
|
||
@DisplayName("약속 공유 정보를 조회하면 200OK와 응답을 반환한다.") | ||
@Test | ||
void findMeetingSharing() { | ||
RestAssured.given().log().all() | ||
.contentType(ContentType.JSON) | ||
.when().get("/api/v1/meeting/{uuid}/sharing", meeting.getUuid()) | ||
.then().log().all() | ||
.statusCode(HttpStatus.OK.value()); | ||
} | ||
|
||
@DisplayName("약속 공유 정보 조회시 UUID가 유효하지 않으면 400 Bad Request를 반환한다.") | ||
@Test | ||
void findMeetingSharingFailedWithInvalidUUID() { | ||
RestAssured.given().log().all() | ||
.contentType(ContentType.JSON) | ||
.when().get("/api/v1/meeting/{uuid}/sharing", "1234") | ||
.then().log().all() | ||
.statusCode(HttpStatus.BAD_REQUEST.value()); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
backend/src/test/java/com/woowacourse/momo/fixture/AttendeeFixture.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,29 @@ | ||
package com.woowacourse.momo.fixture; | ||
|
||
import com.woowacourse.momo.domain.attendee.Attendee; | ||
import com.woowacourse.momo.domain.attendee.AttendeeName; | ||
import com.woowacourse.momo.domain.attendee.AttendeePassword; | ||
import com.woowacourse.momo.domain.attendee.Role; | ||
import com.woowacourse.momo.domain.meeting.Meeting; | ||
|
||
public enum AttendeeFixture { | ||
|
||
HOST_JAZZ("jazz", "hostPw!123", Role.HOST), | ||
GUEST_DAON("daon", "daonPw!123", Role.GUEST), | ||
GUEST_BAKEY("bakey", "bakeyPw!123", Role.GUEST), | ||
GUEST_PEDRO("pedro", "pedroPw!123", Role.GUEST); | ||
|
||
private final String name; | ||
private final String password; | ||
private final Role role; | ||
|
||
AttendeeFixture(String name, String password, Role role) { | ||
this.name = name; | ||
this.password = password; | ||
this.role = role; | ||
} | ||
|
||
public Attendee create(Meeting meeting) { | ||
return new Attendee(meeting, new AttendeeName(name), new AttendeePassword(password), role); | ||
} | ||
} |
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