Skip to content

Commit

Permalink
test : 기존 테스트 통합
Browse files Browse the repository at this point in the history
  • Loading branch information
seokho-1116 committed May 29, 2024
1 parent 0d57236 commit f3f5f39
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<GroupMemberDto> groupMemberDtos = groupDetail.members();

//then
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(groupMemberDtos)
.noneMatch(member -> member.memberId().equals(groupMemberId));
});
}

@Test
void 그룹_아이디로_그룹을_상세정보를_조회하면_그룹의_상세정보를_볼_수_있다() {
//given
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -67,9 +66,6 @@ void setup(@Autowired EntityManager entityManager) {
groups.add(group);
}

//사용자가 그룹장인 그룹아이디
ownerGroupId = groups.get(0).getId();

//그룹원들
List<Member> members = MemberFixture.members(4, 2);
members.forEach(entityManager::persist);
Expand Down Expand Up @@ -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<GroupMemberDto> groupMemberDtos = groupDetail.members();

//then
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(groupMemberDtos)
.noneMatch(member -> member.memberId().equals(memberId));
});
}
}

0 comments on commit f3f5f39

Please sign in to comment.