-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9ea2512
commit 2c92e8c
Showing
3 changed files
with
131 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
...k-api/src/test/java/com/heachi/housework/api/service/group/info/GroupInfoServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package com.heachi.housework.api.service.group.info; | ||
|
||
import com.heachi.housework.TestConfig; | ||
import com.heachi.housework.api.service.group.info.response.GroupInfoUserGroupServiceResponse; | ||
import com.heachi.mysql.define.group.info.GroupInfo; | ||
import com.heachi.mysql.define.group.info.repository.GroupInfoRepository; | ||
import com.heachi.mysql.define.group.member.GroupMember; | ||
import com.heachi.mysql.define.group.member.repository.GroupMemberRepository; | ||
import com.heachi.mysql.define.housework.category.HouseworkCategory; | ||
import com.heachi.mysql.define.housework.category.repository.HouseworkCategoryRepository; | ||
import com.heachi.mysql.define.housework.info.HouseworkInfo; | ||
import com.heachi.mysql.define.housework.info.repository.HouseworkInfoRepository; | ||
import com.heachi.mysql.define.housework.member.HouseworkMember; | ||
import com.heachi.mysql.define.housework.member.repository.HouseworkMemberRepository; | ||
import com.heachi.mysql.define.housework.todo.HouseworkTodo; | ||
import com.heachi.mysql.define.housework.todo.repository.HouseworkTodoRepository; | ||
import com.heachi.mysql.define.user.User; | ||
import com.heachi.mysql.define.user.repository.UserRepository; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
@SpringBootTest | ||
class GroupInfoServiceTest extends TestConfig { | ||
|
||
@Autowired private GroupMemberRepository groupMemberRepository; | ||
@Autowired private UserRepository userRepository; | ||
@Autowired private GroupInfoRepository groupInfoRepository; | ||
@Autowired private HouseworkCategoryRepository houseworkCategoryRepository; | ||
@Autowired private HouseworkInfoRepository houseworkInfoRepository; | ||
@Autowired private HouseworkTodoRepository houseworkTodoRepository; | ||
@Autowired private HouseworkMemberRepository houseworkMemberRepository; | ||
|
||
@Autowired private GroupInfoService groupInfoService; | ||
|
||
@AfterEach | ||
void tearDown() { | ||
houseworkTodoRepository.deleteAllInBatch(); | ||
houseworkMemberRepository.deleteAllInBatch(); | ||
houseworkInfoRepository.deleteAllInBatch(); | ||
houseworkCategoryRepository.deleteAllInBatch(); | ||
groupMemberRepository.deleteAllInBatch(); | ||
groupInfoRepository.deleteAllInBatch(); | ||
userRepository.deleteAllInBatch(); | ||
} | ||
|
||
@Test | ||
@DisplayName("유저의 email을 통해 유저가 속한 그룹과 각 그룹의 멤버, 해당 날짜의 그룹별 집안일 진행상황을 나타낸다.") | ||
void userGroupInfoList() { | ||
// given | ||
User user = userRepository.save(generateUser()); | ||
User user2 = userRepository.save(generateCustomUser("[email protected]", "010-1111-1111")); | ||
User user3 = userRepository.save(generateCustomUser("[email protected]", "010-2222-2222")); | ||
GroupInfo groupInfo = groupInfoRepository.save(generateGroupInfo(user)); | ||
GroupInfo groupInfo2 = groupInfoRepository.save(generateGroupInfo(user2)); | ||
GroupInfo groupInfo3 = groupInfoRepository.save(generateGroupInfo(user3)); | ||
GroupMember groupMember = groupMemberRepository.save(generateGroupMember(user, groupInfo)); | ||
groupMemberRepository.save(generateGroupMember(user2, groupInfo)); | ||
groupMemberRepository.save(generateGroupMember(user3, groupInfo)); | ||
groupMemberRepository.save(generateGroupMember(user, groupInfo3)); | ||
groupMemberRepository.save(generateGroupMember(user3, groupInfo2)); | ||
|
||
HouseworkCategory houseworkCategory = houseworkCategoryRepository.save(generateHouseworkCategory()); | ||
HouseworkInfo houseworkInfo = houseworkInfoRepository.save(generateHouseworkInfo(houseworkCategory)); | ||
HouseworkInfo houseworkInfo2 = houseworkInfoRepository.save(generateHouseworkInfo(houseworkCategory)); | ||
HouseworkInfo houseworkInfo3 = houseworkInfoRepository.save(generateHouseworkInfo(houseworkCategory)); | ||
|
||
HouseworkMember houseworkMember = houseworkMemberRepository.save(generateHouseworkMember(groupMember, houseworkInfo)); | ||
HouseworkInfo findHouseworkInfo = houseworkInfoRepository.findHouseworkInfoByIdJoinFetchHouseworkMembers(houseworkInfo.getId()).get(); | ||
HouseworkInfo findHouseworkInfo2 = houseworkInfoRepository.findHouseworkInfoByIdJoinFetchHouseworkMembers(houseworkInfo2.getId()).get(); | ||
HouseworkInfo findHouseworkInfo3 = houseworkInfoRepository.findHouseworkInfoByIdJoinFetchHouseworkMembers(houseworkInfo3.getId()).get(); | ||
|
||
HouseworkTodo houseworkTodo = houseworkTodoRepository.save(generateHouseworkTodo(findHouseworkInfo, groupInfo, LocalDate.now())); | ||
HouseworkTodo houseworkTodo2 = houseworkTodoRepository.save(generateHouseworkTodo(findHouseworkInfo2, groupInfo2, LocalDate.now())); | ||
HouseworkTodo houseworkTodo3 = houseworkTodoRepository.save(generateHouseworkTodo(findHouseworkInfo3, groupInfo3, LocalDate.now())); | ||
|
||
// when | ||
List<GroupInfoUserGroupServiceResponse> groupServiceResponses = groupInfoService.userGroupInfoList(user.getEmail()); | ||
groupServiceResponses.forEach(System.out::println); | ||
|
||
// then | ||
assertThat(groupServiceResponses.get(0).getGroupMembers().size()).isEqualTo(3); | ||
assertThat(groupServiceResponses.get(0).getRemainTodoListCnt()).isEqualTo(1); | ||
assertThat(groupServiceResponses.get(0).getProgressPercent()).isEqualTo(0); | ||
|
||
assertThat(groupServiceResponses.get(1).getGroupMembers().size()).isEqualTo(1); | ||
assertThat(groupServiceResponses.get(1).getRemainTodoListCnt()).isEqualTo(1); | ||
assertThat(groupServiceResponses.get(1).getProgressPercent()).isEqualTo(0); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -151,7 +151,7 @@ void test3() { | |
void test4() { | ||
// given | ||
User user = userRepository.save(generateUser()); | ||
User user2 = userRepository.save(generateUser("[email protected]", "010-1111-1111")); | ||
User user2 = userRepository.save(generateCustomUser("[email protected]", "010-1111-1111")); | ||
GroupInfo groupInfo = groupInfoRepository.save(generateGroupInfo(user)); | ||
GroupMember groupMember = groupMemberRepository.save(generateGroupMember(user, groupInfo)); | ||
GroupMember groupMember2 = groupMemberRepository.save(generateGroupMember(user2, groupInfo)); | ||
|