From 9d327139899244acb18244f36a255c687a5765e7 Mon Sep 17 00:00:00 2001 From: wonyongChoi05 Date: Wed, 17 May 2023 16:10:08 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20filterService=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/FilterServiceTest.java | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 backend/src/test/java/wooteco/prolog/studylog/application/FilterServiceTest.java diff --git a/backend/src/test/java/wooteco/prolog/studylog/application/FilterServiceTest.java b/backend/src/test/java/wooteco/prolog/studylog/application/FilterServiceTest.java new file mode 100644 index 000000000..14d90ba1e --- /dev/null +++ b/backend/src/test/java/wooteco/prolog/studylog/application/FilterServiceTest.java @@ -0,0 +1,78 @@ +package wooteco.prolog.studylog.application; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import wooteco.prolog.login.ui.LoginMember; +import wooteco.prolog.member.application.MemberService; +import wooteco.prolog.member.application.dto.MemberResponse; +import wooteco.prolog.member.domain.Role; +import wooteco.prolog.roadmap.application.dto.SessionResponse; +import wooteco.prolog.session.application.MissionService; +import wooteco.prolog.session.application.SessionService; +import wooteco.prolog.session.application.dto.MissionResponse; +import wooteco.prolog.studylog.application.dto.FilterResponse; +import wooteco.prolog.studylog.application.dto.TagResponse; + +import java.util.ArrayList; +import java.util.List; + +import static org.assertj.core.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.doReturn; + +@ExtendWith(MockitoExtension.class) +class FilterServiceTest { + + @InjectMocks + FilterService filterService; + + @Mock + SessionService sessionService; + + @Mock + MissionService missionService; + + @Mock + TagService tagService; + + @Mock + MemberService memberService; + + @DisplayName("로그인 멤버와 관련된 세션, 미션, 태그, 멤버 정보를 가져와서 FilterResponse를 반환한다.") + @Test + void showAll() { + // given + LoginMember loginMember = new LoginMember(); + + List sessionResponses = new ArrayList<>(); + sessionResponses.add(new SessionResponse(1L, "session1")); + doReturn(sessionResponses).when(sessionService).findAllWithMySessionFirst(loginMember); + + List missionResponses = new ArrayList<>(); + missionResponses.add(new MissionResponse(1L, "mission1", new wooteco.prolog.session.application.dto.SessionResponse(1L, "session1"))); + doReturn(missionResponses).when(missionService).findAllWithMyMissionFirst(loginMember); + + List tagResponses = new ArrayList<>(); + tagResponses.add(new TagResponse(1L, "tag1")); + doReturn(tagResponses).when(tagService).findTagsIncludedInStudylogs(); + + List memberResponses = new ArrayList<>(); + memberResponses.add(new MemberResponse(1L, "베베", "bebe", Role.CREW, "img")); + doReturn(memberResponses).when(memberService).findAllOrderByNickNameAsc(); + + // when + FilterResponse response = filterService.showAll(loginMember); + + // then + assertAll( + () -> assertThat(response.getSessions()).isEqualTo(sessionResponses), + () -> assertThat(response.getMissions()).isEqualTo(missionResponses), + () -> assertThat(response.getTags()).isEqualTo(tagResponses), + () -> assertThat(response.getMembers()).isEqualTo(memberResponses) + ); + } +}