Skip to content

Commit

Permalink
test: 테스트 내 약속 잠금시 변경된 HTTP 메서드 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
ikjo39 committed Jul 31, 2024
1 parent 62a8000 commit 0d2521a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void lock() {
.contentType(ContentType.JSON)
.pathParam("uuid", meeting.getUuid())
.header("Authorization", "Bearer " + token)
.when().post("/api/v1/meetings/{uuid}/lock")
.when().patch("/api/v1/meetings/{uuid}/lock")
.then().log().all()
.statusCode(HttpStatus.OK.value());
}
Expand All @@ -189,7 +189,7 @@ void lockWithInvalidUUID() {
.contentType(ContentType.JSON)
.pathParam("uuid", invalidUUID)
.header("Authorization", "Bearer " + token)
.when().post("/api/v1/meetings/{uuid}/lock")
.when().patch("/api/v1/meetings/{uuid}/lock")
.then().log().all()
.statusCode(HttpStatus.NOT_FOUND.value());
}
Expand All @@ -213,40 +213,8 @@ void lockWithNoPermission() {
.contentType(ContentType.JSON)
.pathParam("uuid", meeting.getUuid())
.header("Authorization", "Bearer " + token)
.when().post("/api/v1/meetings/{uuid}/lock")
.when().patch("/api/v1/meetings/{uuid}/lock")
.then().log().all()
.statusCode(HttpStatus.FORBIDDEN.value());
}

@DisplayName("약속을 중복으로 잠그면 400을 반환한다.")
@Test
void lockWithDuplicatedRequest() {
Meeting meeting = meetingRepository.save(MeetingFixture.DINNER.create());
Attendee attendee = attendeeRepository.save(AttendeeFixture.HOST_JAZZ.create(meeting));
AttendeeLoginRequest request = new AttendeeLoginRequest(attendee.name(), attendee.password());

String token = RestAssured.given().log().all()
.contentType(ContentType.JSON)
.body(request)
.when().post("/api/v1/meetings/{uuid}/login", meeting.getUuid())
.then().log().all()
.statusCode(HttpStatus.OK.value())
.extract().jsonPath().getString("data.token");

RestAssured.given().log().all()
.contentType(ContentType.JSON)
.pathParam("uuid", meeting.getUuid())
.header("Authorization", "Bearer " + token)
.when().post("/api/v1/meetings/{uuid}/lock")
.then().log().all()
.statusCode(HttpStatus.OK.value());

RestAssured.given().log().all()
.contentType(ContentType.JSON)
.pathParam("uuid", meeting.getUuid())
.header("Authorization", "Bearer " + token)
.when().post("/api/v1/meetings/{uuid}/lock")
.then().log().all()
.statusCode(HttpStatus.BAD_REQUEST.value());
}
}
11 changes: 0 additions & 11 deletions backend/src/test/java/kr/momo/domain/meeting/MeetingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,4 @@ void lock() {

assertThat(meeting.isLocked()).isTrue();
}

@DisplayName("약속이 잠겨있는데 잠금을 요청하면 예외가 발생한다.")
@Test
void throwExceptionWhenLocked() {
Meeting meeting = MeetingFixture.DINNER.create();
meeting.lock();

assertThatThrownBy(meeting::lock)
.isInstanceOf(MomoException.class)
.hasMessage(MeetingErrorCode.MEETING_LOCKED.message());
}
}

0 comments on commit 0d2521a

Please sign in to comment.