From 57aec94ad2c2cd3258a54b0a488803b56f7c99ba Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Fri, 27 Sep 2024 10:53:46 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=EB=8B=A4=EB=9D=BD=EB=B0=A9=20?= =?UTF-8?q?=EB=A9=A4=EB=B2=84=20=EC=A1=B0=ED=9A=8C=20=EA=B6=8C=ED=95=9C=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/DarakbangMemberService.java | 3 --- .../business/DarakbangMemberServiceTest.java | 19 ------------------- 2 files changed, 22 deletions(-) diff --git a/backend/src/main/java/mouda/backend/darakbangmember/business/DarakbangMemberService.java b/backend/src/main/java/mouda/backend/darakbangmember/business/DarakbangMemberService.java index 39ac9ae2e..f2cebc31a 100644 --- a/backend/src/main/java/mouda/backend/darakbangmember/business/DarakbangMemberService.java +++ b/backend/src/main/java/mouda/backend/darakbangmember/business/DarakbangMemberService.java @@ -13,20 +13,17 @@ import mouda.backend.darakbangmember.presentation.response.DarakbangMemberResponses; import mouda.backend.darakbangmember.presentation.response.DarakbangMemberRoleResponse; import mouda.backend.member.domain.Member; -import mouda.backend.member.implement.MemberValidator; @Service @Transactional @RequiredArgsConstructor public class DarakbangMemberService { - private final MemberValidator memberValidator; private final DarakbangMemberFinder darakbangMemberFinder; private final DarakbangFinder darakbangFinder; @Transactional(readOnly = true) public DarakbangMemberResponses findAllDarakbangMembers(Long darakbangId, DarakbangMember member) { - memberValidator.validateNotManager(member); DarakbangMembers darakbangMembers = darakbangMemberFinder.findAllDarakbangMembers(darakbangId); return DarakbangMemberResponses.toResponse(darakbangMembers); 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 f0985cbb0..2c8fc5abc 100644 --- a/backend/src/test/java/mouda/backend/darakbangmember/business/DarakbangMemberServiceTest.java +++ b/backend/src/test/java/mouda/backend/darakbangmember/business/DarakbangMemberServiceTest.java @@ -13,8 +13,6 @@ import mouda.backend.common.fixture.MemberFixture; import mouda.backend.darakbang.domain.Darakbang; import mouda.backend.darakbang.infrastructure.DarakbangRepository; -import mouda.backend.darakbangmember.domain.DarakbangMember; -import mouda.backend.darakbangmember.exception.DarakbangMemberException; import mouda.backend.darakbangmember.infrastructure.DarakbangMemberRepository; import mouda.backend.darakbangmember.presentation.response.DarakbangMemberRoleResponse; import mouda.backend.member.domain.Member; @@ -35,23 +33,6 @@ class DarakbangMemberServiceTest { @Autowired private DarakbangMemberService darakbangMemberService; - @DisplayName("다락방 멤버 조회 테스트") - @Nested - class DarakbangMemberReadTest { - - @DisplayName("다락방 관리자가 아니라면 멤버 조회에 실패한다.") - @Test - void failToReadWithoutDarakbangManager() { - Member hogee = memberRepository.save(MemberFixture.getHogee()); - Darakbang darakbang = darakbangRepository.save(DarakbangFixture.getDarakbangWithWooteco()); - DarakbangMember darakbangHogee = darakbangMemberRepository.save( - DarakbangMemberFixture.getDarakbangMemberWithWooteco(darakbang, hogee)); - - assertThatThrownBy(() -> darakbangMemberService.findAllDarakbangMembers(darakbang.getId(), darakbangHogee)) - .isInstanceOf(DarakbangMemberException.class); - } - } - @DisplayName("다락방 멤버 권한 조회 테스트") @Nested class DarakbangMemberRoleReadTest { From 8ad3705245865d157e6d3713334bbbe7c5350942 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Fri, 4 Oct 2024 17:24:46 +0900 Subject: [PATCH 2/2] =?UTF-8?q?test:=20=EB=8B=A4=EB=9D=BD=EB=B0=A9=20?= =?UTF-8?q?=EB=A9=A4=EB=B2=84=20=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/DarakbangMemberServiceTest.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) 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); + } + } }