Skip to content

Commit b7ba2f4

Browse files
committed
test: given, when, then 주석 추가 #28
1 parent 39691e1 commit b7ba2f4

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

backend/src/test/java/ddangkong/controller/balance/content/BalanceContentControllerTest.java

+8-5
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,30 @@
1212

1313
class BalanceContentControllerTest extends BaseControllerTest {
1414

15-
private static final BalanceContentResponse EXPECTED_RESPONSE = new BalanceContentResponse(
16-
1L, Category.EXAMPLE, "민초 vs 반민초",
17-
new BalanceOptionResponse(1L, "민초"),
18-
new BalanceOptionResponse(2L, "반민초"));
19-
2015
@Nested
2116
class 현재_방의_내용_조회 {
2217

18+
private static final BalanceContentResponse EXPECTED_RESPONSE = new BalanceContentResponse(
19+
1L, Category.EXAMPLE, "민초 vs 반민초",
20+
new BalanceOptionResponse(1L, "민초"),
21+
new BalanceOptionResponse(2L, "반민초"));
22+
2323
@Test
2424
void 현재_방의_질문을_조회할_수_있다() {
25+
// when
2526
BalanceContentResponse actual = RestAssured.given().log().all()
2627
.when().get("/api/balances/rooms/1/question")
2728
.then().log().all()
2829
.statusCode(200)
2930
.extract().as(BalanceContentResponse.class);
3031

32+
// then
3133
assertThat(actual).isEqualTo(EXPECTED_RESPONSE);
3234
}
3335

3436
@Test
3537
void 방의_식별자가_음수인_경우_예외를_던진다() {
38+
// when & then
3639
RestAssured.given().log().all()
3740
.when().get("/api/balances/rooms/-1/question")
3841
.then().log().all()

backend/src/test/java/ddangkong/domain/balance/content/RoomContentRepositoryTest.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@ class 방의_최신_질문_조회 {
1717

1818
@Test
1919
void 방의_가장_최신의_질문을_조회할_수_있다() {
20-
RoomContent actual = roomContentRepository.findTopByRoomIdOrderByCreatedAtDesc(1L).get();
20+
// given
21+
Long recentContentId = 1L;
2122

23+
// when
24+
RoomContent actual = roomContentRepository.findTopByRoomIdOrderByCreatedAtDesc(recentContentId).get();
25+
26+
// then
2227
assertThat(actual.getId()).isEqualTo(2L);
2328
}
2429
}

backend/src/test/java/ddangkong/service/balance/content/BalanceContentServiceTest.java

+3
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,16 @@ class 현재_방의_내용_조회 {
2929

3030
@Test
3131
void 방의_최신_내용을_조회할_수_있다() {
32+
// when
3233
BalanceContentResponse actual = balanceContentService.findRecentBalanceContent(PROGRESS_ROOM_ID);
3334

35+
// then
3436
assertThat(actual).isEqualTo(BALANCE_CONTENT_RESPONSE);
3537
}
3638

3739
@Test
3840
void 방이_없을_경우_예외를_던진다() {
41+
// when & then
3942
assertThatThrownBy(() -> balanceContentService.findRecentBalanceContent(NOT_EXIST_ROOM_ID))
4043
.isInstanceOf(BusinessLogicException.class)
4144
.hasMessage("해당 방의 질문이 존재하지 않습니다.");

0 commit comments

Comments
 (0)