-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BE] 약속 생성 결과 조회 API 구현 #52
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
114312c
test(AttendeeFixture): 참가자용 테스트 fixture 추가
ikjo39 c6f78c4
feat(MeetingService): 약속 생성 결과 조회 로직 추
ikjo39 a7ea9ed
feat(MeetingController): 약속 생성 결과 조회 컨트롤러 추가
ikjo39 4d2b134
Merge branch 'develop' into feat/50-get-completed-meeting-info
ikjo39 bea2ced
Merge branch 'develop' into feat/50-get-completed-meeting-info
hw0603 bd97e4a
refactor(MeetingController): 불분명한 메서드명 변
ikjo39 92125c6
refactor(MeetingController): API Path 수정 및 불분명한 명명 수정
ikjo39 cf2a033
test(MeetingController): API Path 수정 및 UUID 오류 발생시 응답 코드 테스트 추가
ikjo39 662653a
refactor(MeetingService): 사용하지 않는 어노테이션 및 Enum 값 제거
ikjo39 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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); | ||
} | ||
Comment on lines
+26
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 연관관계가 있는 fixture을 어떻게 만들어야 하나 궁금했는데, 이렇게 Fixture을 만들 수 있네요! 👍👍 |
||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enum 픽스쳐 기가 막히네요👍🏻