diff --git a/backend/core/src/test/java/site/timecapsulearchive/core/common/fixture/domain/GroupCapsuleOpenFixture.java b/backend/core/src/test/java/site/timecapsulearchive/core/common/fixture/domain/GroupCapsuleOpenFixture.java index f555ad68a..795913fd7 100644 --- a/backend/core/src/test/java/site/timecapsulearchive/core/common/fixture/domain/GroupCapsuleOpenFixture.java +++ b/backend/core/src/test/java/site/timecapsulearchive/core/common/fixture/domain/GroupCapsuleOpenFixture.java @@ -1,8 +1,11 @@ package site.timecapsulearchive.core.common.fixture.domain; import java.util.List; +import java.util.Optional; import site.timecapsulearchive.core.domain.capsule.entity.Capsule; +import site.timecapsulearchive.core.domain.capsule.entity.CapsuleType; import site.timecapsulearchive.core.domain.capsule.entity.GroupCapsuleOpen; +import site.timecapsulearchive.core.domain.capsuleskin.entity.CapsuleSkin; import site.timecapsulearchive.core.domain.member.entity.Member; public class GroupCapsuleOpenFixture { @@ -18,8 +21,16 @@ public static List groupCapsuleOpens(Boolean isOpened, Capsule ).toList(); } - public static GroupCapsuleOpen groupCapsuleOpen(Member member, Capsule capsule, - Boolean isOpened) { - return GroupCapsuleOpen.createOf(member, capsule, isOpened); + public static Optional groupCapsuleOpen(int dataPrefix) { + Member member = MemberFixture.member(dataPrefix); + CapsuleSkin capsuleSkin = CapsuleSkinFixture.capsuleSkin(member); + + return Optional.of( + GroupCapsuleOpen.createOf( + MemberFixture.member(dataPrefix), + CapsuleFixture.capsule(member, capsuleSkin, CapsuleType.GROUP), + Boolean.FALSE + ) + ); } } diff --git a/backend/core/src/test/java/site/timecapsulearchive/core/domain/capsule/group_capsule/service/GroupCapsuleServiceTest.java b/backend/core/src/test/java/site/timecapsulearchive/core/domain/capsule/group_capsule/service/GroupCapsuleServiceTest.java index f2c95ac23..c6caa072a 100644 --- a/backend/core/src/test/java/site/timecapsulearchive/core/domain/capsule/group_capsule/service/GroupCapsuleServiceTest.java +++ b/backend/core/src/test/java/site/timecapsulearchive/core/domain/capsule/group_capsule/service/GroupCapsuleServiceTest.java @@ -13,14 +13,8 @@ import java.util.Optional; import org.assertj.core.api.SoftAssertions; import org.junit.jupiter.api.Test; -import org.mockito.Mockito; -import site.timecapsulearchive.core.common.fixture.domain.CapsuleFixture; -import site.timecapsulearchive.core.common.fixture.domain.CapsuleSkinFixture; import site.timecapsulearchive.core.common.fixture.domain.GroupCapsuleOpenFixture; -import site.timecapsulearchive.core.common.fixture.domain.MemberFixture; import site.timecapsulearchive.core.common.fixture.dto.CapsuleDtoFixture; -import site.timecapsulearchive.core.domain.capsule.entity.CapsuleType; -import site.timecapsulearchive.core.domain.capsule.entity.GroupCapsuleOpen; import site.timecapsulearchive.core.domain.capsule.exception.GroupCapsuleOpenNotFoundException; import site.timecapsulearchive.core.domain.capsule.generic_capsule.data.dto.CapsuleDetailDto; import site.timecapsulearchive.core.domain.capsule.generic_capsule.repository.CapsuleRepository; @@ -28,9 +22,7 @@ import site.timecapsulearchive.core.domain.capsule.group_capsule.repository.GroupCapsuleOpenQueryRepository; import site.timecapsulearchive.core.domain.capsule.group_capsule.repository.GroupCapsuleOpenRepository; import site.timecapsulearchive.core.domain.capsule.group_capsule.repository.GroupCapsuleQueryRepository; -import site.timecapsulearchive.core.domain.capsuleskin.entity.CapsuleSkin; import site.timecapsulearchive.core.domain.group.data.dto.GroupMemberSummaryDto; -import site.timecapsulearchive.core.domain.member.entity.Member; import site.timecapsulearchive.core.global.error.ErrorCode; class GroupCapsuleServiceTest { @@ -225,8 +217,9 @@ class GroupCapsuleServiceTest { Long memberId = 1L; Long capsuleId = 1L; given(groupCapsuleOpenRepository.findByMemberIdAndCapsuleId(anyLong(), anyLong())) - .willReturn(groupCapsuleOpen()); - given(groupCapsuleOpenQueryRepository.findIsOpenedByMemberIdAndCapsuleId(anyLong())) + + .willReturn(GroupCapsuleOpenFixture.groupCapsuleOpen(memberId.intValue())); + given(groupCapsuleOpenQueryRepository.findIsOpenedByCapsuleId(anyLong())) .willReturn(List.of(Boolean.FALSE, Boolean.FALSE, Boolean.TRUE)); //when @@ -236,27 +229,14 @@ class GroupCapsuleServiceTest { verifyNoInteractions(capsuleRepository); } - private Optional groupCapsuleOpen() { - Member member = MemberFixture.member(0); - CapsuleSkin capsuleSkin = CapsuleSkinFixture.capsuleSkin(member); - - return Optional.of( - GroupCapsuleOpenFixture.groupCapsuleOpen( - MemberFixture.member(0), - CapsuleFixture.capsule(member, capsuleSkin, CapsuleType.GROUP), - Boolean.FALSE - ) - ); - } - @Test void 모든_그룹원이_캡슐을_개봉한_경우_캡슐은_개봉된다() { //given Long memberId = 1L; Long capsuleId = 1L; given(groupCapsuleOpenRepository.findByMemberIdAndCapsuleId(anyLong(), anyLong())) - .willReturn(groupCapsuleOpen()); - given(groupCapsuleOpenQueryRepository.findIsOpenedByMemberIdAndCapsuleId(anyLong())) + .willReturn(GroupCapsuleOpenFixture.groupCapsuleOpen(memberId.intValue())); + given(groupCapsuleOpenQueryRepository.findIsOpenedByCapsuleId(anyLong())) .willReturn(List.of(Boolean.TRUE, Boolean.TRUE, Boolean.TRUE)); //when