diff --git a/backend/core/src/test/java/site/timecapsulearchive/core/domain/group/repository/GroupQueryRepositoryImplTest.java b/backend/core/src/test/java/site/timecapsulearchive/core/domain/group/repository/GroupQueryRepositoryImplTest.java index 239a7c9a2..3b07e0ac3 100644 --- a/backend/core/src/test/java/site/timecapsulearchive/core/domain/group/repository/GroupQueryRepositoryImplTest.java +++ b/backend/core/src/test/java/site/timecapsulearchive/core/domain/group/repository/GroupQueryRepositoryImplTest.java @@ -18,6 +18,7 @@ import site.timecapsulearchive.core.common.fixture.domain.MemberFixture; import site.timecapsulearchive.core.common.fixture.domain.MemberGroupFixture; import site.timecapsulearchive.core.domain.group.data.dto.GroupDetailDto; +import site.timecapsulearchive.core.domain.group.data.dto.GroupMemberDto; import site.timecapsulearchive.core.domain.group.entity.Group; import site.timecapsulearchive.core.domain.member.entity.Member; import site.timecapsulearchive.core.domain.member_group.entity.MemberGroup; @@ -59,6 +60,69 @@ void setup(@Autowired EntityManager entityManager) { groupMemberId = members.get(0).getId(); } + @Test + void 그룹_아이디와_멤버_아이디로_그룹을_조회하면_그룹_상세가_반환된다() { + //given + //when + GroupDetailDto groupDetail = groupQueryRepository.findGroupDetailByGroupIdAndMemberId( + groupId, ownerId).orElseThrow(); + + //then + assertThat(groupDetail).isNotNull(); + } + + @Test + void 그룹_아이디와_멤버_아이디로_그룹을_조회하면_그룹_정보를_볼_수_있다() { + //given + //when + GroupDetailDto groupDetail = groupQueryRepository.findGroupDetailByGroupIdAndMemberId( + groupId, ownerId).orElseThrow(); + + //then + SoftAssertions.assertSoftly(softly -> { + assertThat(groupDetail.groupName()).isNotBlank(); + assertThat(groupDetail.groupDescription()).isNotBlank(); + assertThat(groupDetail.groupProfileUrl()).isNotBlank(); + assertThat(groupDetail.createdAt()).isNotNull(); + }); + } + + @Test + void 그룹_아이디와_멤버_아이디_그룹을_조회하면_그룹원들의_정보를_볼_수_있다() { + //given + //when + GroupDetailDto groupDetail = groupQueryRepository.findGroupDetailByGroupIdAndMemberId( + groupId, groupMemberId).orElseThrow(); + + //then + SoftAssertions.assertSoftly(softly -> { + assertThat(groupDetail.members()).isNotEmpty(); + assertThat(groupDetail.members()).allSatisfy(m -> assertThat(m.memberId()).isNotNull()); + assertThat(groupDetail.members()).allSatisfy(m -> assertThat(m.tag()).isNotBlank()); + assertThat(groupDetail.members()).allSatisfy( + m -> assertThat(m.nickname()).isNotBlank()); + assertThat(groupDetail.members()).allSatisfy( + m -> assertThat(m.profileUrl()).isNotBlank()); + assertThat(groupDetail.members()).allSatisfy(m -> assertThat(m.isOwner()).isNotNull()); + }); + } + + @Test + void 그룹_아이디와_멤버_아이디로_그룹을_조회하면_본인은_포함되어_조회되지_않는다() { + //given + //when + GroupDetailDto groupDetail = groupQueryRepository.findGroupDetailByGroupIdAndMemberId( + groupId, groupMemberId).orElseThrow(); + + List groupMemberDtos = groupDetail.members(); + + //then + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(groupMemberDtos) + .noneMatch(member -> member.memberId().equals(groupMemberId)); + }); + } + @Test void 그룹_아이디로_그룹을_상세정보를_조회하면_그룹의_상세정보를_볼_수_있다() { //given diff --git a/backend/core/src/test/java/site/timecapsulearchive/core/domain/member_group/repository/MemberGroupQueryRepositoryTest.java b/backend/core/src/test/java/site/timecapsulearchive/core/domain/member_group/repository/MemberGroupQueryRepositoryTest.java index fc4856904..c0a2329ef 100644 --- a/backend/core/src/test/java/site/timecapsulearchive/core/domain/member_group/repository/MemberGroupQueryRepositoryTest.java +++ b/backend/core/src/test/java/site/timecapsulearchive/core/domain/member_group/repository/MemberGroupQueryRepositoryTest.java @@ -40,7 +40,6 @@ class MemberGroupQueryRepositoryTest extends RepositoryTest { private Long memberId; private Long memberIdWithNoGroup; - private Long ownerGroupId; MemberGroupQueryRepositoryTest(JPAQueryFactory jpaQueryFactory) { this.groupQueryRepository = new GroupQueryRepositoryImpl(jpaQueryFactory); @@ -67,9 +66,6 @@ void setup(@Autowired EntityManager entityManager) { groups.add(group); } - //사용자가 그룹장인 그룹아이디 - ownerGroupId = groups.get(0).getId(); - //그룹원들 List members = MemberFixture.members(4, 2); members.forEach(entityManager::persist); @@ -150,67 +146,4 @@ void setup(@Autowired EntityManager entityManager) { //then assertThat(groupsSlice.isEmpty()).isTrue(); } - - @Test - void 그룹_아이디와_멤버_아이디로_그룹을_조회하면_그룹_상세가_반환된다() { - //given - //when - GroupDetailDto groupDetail = groupQueryRepository.findGroupDetailByGroupIdAndMemberId( - ownerGroupId, memberId).orElseThrow(); - - //then - assertThat(groupDetail).isNotNull(); - } - - @Test - void 그룹_아이디와_멤버_아이디로_그룹을_조회하면_그룹_정보를_볼_수_있다() { - //given - //when - GroupDetailDto groupDetail = groupQueryRepository.findGroupDetailByGroupIdAndMemberId( - ownerGroupId, memberId).orElseThrow(); - - //then - SoftAssertions.assertSoftly(softly -> { - assertThat(groupDetail.groupName()).isNotBlank(); - assertThat(groupDetail.groupDescription()).isNotBlank(); - assertThat(groupDetail.groupProfileUrl()).isNotBlank(); - assertThat(groupDetail.createdAt()).isNotNull(); - }); - } - - @Test - void 그룹_아이디와_멤버_아이디_그룹을_조회하면_그룹원들의_정보를_볼_수_있다() { - //given - //when - GroupDetailDto groupDetail = groupQueryRepository.findGroupDetailByGroupIdAndMemberId( - ownerGroupId, memberId).orElseThrow(); - - //then - SoftAssertions.assertSoftly(softly -> { - assertThat(groupDetail.members()).isNotEmpty(); - assertThat(groupDetail.members()).allSatisfy(m -> assertThat(m.memberId()).isNotNull()); - assertThat(groupDetail.members()).allSatisfy(m -> assertThat(m.tag()).isNotBlank()); - assertThat(groupDetail.members()).allSatisfy( - m -> assertThat(m.nickname()).isNotBlank()); - assertThat(groupDetail.members()).allSatisfy( - m -> assertThat(m.profileUrl()).isNotBlank()); - assertThat(groupDetail.members()).allSatisfy(m -> assertThat(m.isOwner()).isNotNull()); - }); - } - - @Test - void 그룹_아이디와_멤버_아이디로_그룹을_조회하면_본인은_포함되어_조회되지_않는다() { - //given - //when - GroupDetailDto groupDetail = groupQueryRepository.findGroupDetailByGroupIdAndMemberId( - ownerGroupId, memberId).orElseThrow(); - - List groupMemberDtos = groupDetail.members(); - - //then - SoftAssertions.assertSoftly(softly -> { - softly.assertThat(groupMemberDtos) - .noneMatch(member -> member.memberId().equals(memberId)); - }); - } } \ No newline at end of file