Skip to content

Commit

Permalink
Test: Controller - 유저 주최한 토론 조회 테스트 코드 작성 (TAVE-balak#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
jyjyjy25 committed Feb 17, 2024
1 parent 448695f commit 13fadb8
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.ResultActions;
import tavebalak.OTTify.common.constant.GradeType;
import tavebalak.OTTify.community.dto.response.MyDiscussionDto;
import tavebalak.OTTify.genre.dto.GenreDTO;
import tavebalak.OTTify.oauth.jwt.JwtService;
import tavebalak.OTTify.oauth.redis.RefreshTokenRepository;
Expand Down Expand Up @@ -268,4 +269,27 @@ public void findUserLikedReviews() throws Exception {
.andExpect(jsonPath("$.data", response).exists());

}

@Test
@DisplayName("유저는 주최한 토론 목록을 조회할 수 있다.")
public void findUserHostingDiscussion() throws Exception {
// given
MyDiscussionDto discussionDto1 = new MyDiscussionDto(3L, LocalDateTime.now(), "어벤져스", "아쿠아맨 보셨나요?", "이렇게 할 수 있다니 정말 놀라운데요?",
"https://ottify-s3-bucket.s3.ap-northeast-2.amazonaws.com/discussion-images/819afed3-bfc8-4e24-ade4-3904dbec694e.jpg", 3, 1);
MyDiscussionDto discussionDto2 = new MyDiscussionDto(5L, LocalDateTime.now(), "어벤져스2", "어벤져스 보셨나요?", "놀라운데요?",
"https://ottify-s3-bucket.s3.ap-northeast-2.amazonaws.com/discussion-images/819afed3-bfc8-4e24-ade4-3904dbec694e.jpg", 5, 4);
MyDiscussionDto discussionDto3 = new MyDiscussionDto(2L, LocalDateTime.now(), "웡카", "웡카에 나온 춤", "따라하실분??",
"https://ottify-s3-bucket.s3.ap-northeast-2.amazonaws.com/discussion-images/819afed3-bfc8-4e24-ade4-3904dbec694e.jpg", 11, 10);
List<MyDiscussionDto> response = new ArrayList<>(Arrays.asList(discussionDto1, discussionDto2, discussionDto3));

// when
when(userService.getHostedDiscussion(any(Pageable.class))).thenReturn(response);

ResultActions result = mockMvc.perform(get(BASE_URL + "/discussion/hosting"));

// then
result.andExpect(status().isOk())
.andExpect(jsonPath("$.data").isNotEmpty())
.andExpect(jsonPath("$.data", response).exists());
}
}

0 comments on commit 13fadb8

Please sign in to comment.