diff --git a/backend/src/test/java/mouda/backend/darakbangmember/business/DarakbangMemberServiceTest.java b/backend/src/test/java/mouda/backend/darakbangmember/business/DarakbangMemberServiceTest.java index 2c8fc5abc..3449c189e 100644 --- a/backend/src/test/java/mouda/backend/darakbangmember/business/DarakbangMemberServiceTest.java +++ b/backend/src/test/java/mouda/backend/darakbangmember/business/DarakbangMemberServiceTest.java @@ -5,6 +5,8 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -13,7 +15,10 @@ import mouda.backend.common.fixture.MemberFixture; import mouda.backend.darakbang.domain.Darakbang; import mouda.backend.darakbang.infrastructure.DarakbangRepository; +import mouda.backend.darakbangmember.domain.DarakBangMemberRole; +import mouda.backend.darakbangmember.domain.DarakbangMember; import mouda.backend.darakbangmember.infrastructure.DarakbangMemberRepository; +import mouda.backend.darakbangmember.presentation.response.DarakbangMemberResponses; import mouda.backend.darakbangmember.presentation.response.DarakbangMemberRoleResponse; import mouda.backend.member.domain.Member; import mouda.backend.member.infrastructure.MemberRepository; @@ -51,4 +56,29 @@ void success() { assertThat(response.role()).isEqualTo("OUTSIDER"); } } + + @DisplayName("다락방 멤버 조회 테스트") + @Nested + class DarakbangMemberReadTest { + + @DisplayName("모든 다락방 멤버는 다락방 멤버 목록을 조회할 수 있다.") + @EnumSource(mode = EnumSource.Mode.INCLUDE, names = {"MANAGER", "MEMBER"}) + @ParameterizedTest + void failToReadWithoutDarakbangManager(DarakBangMemberRole darakBangMemberRole) { + Member hogee = memberRepository.save(MemberFixture.getHogee()); + Darakbang darakbang = darakbangRepository.save(DarakbangFixture.getDarakbangWithWooteco()); + DarakbangMember darakbangMember = DarakbangMember.builder() + .darakbang(darakbang) + .memberId(hogee.getId()) + .nickname("소소파파") + .role(darakBangMemberRole) + .build(); + DarakbangMember darakbangHogee = darakbangMemberRepository.save(darakbangMember); + + DarakbangMemberResponses responses = darakbangMemberService.findAllDarakbangMembers( + darakbang.getId(), darakbangHogee); + + assertThat(responses.responses()).hasSize(1); + } + } }