-
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
Showing
5 changed files
with
153 additions
and
5 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
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
67 changes: 67 additions & 0 deletions
67
...heachi/housework/api/service/housework/info/response/HouseworkInfoUpdatePageResponse.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,67 @@ | ||
package com.heachi.housework.api.service.housework.info.response; | ||
|
||
import com.heachi.housework.api.controller.housework.info.request.HouseworkInfoCreateRequest; | ||
import com.heachi.housework.api.service.housework.category.response.HouseworkCategoryResponse; | ||
import com.heachi.housework.api.service.housework.info.request.HouseworkInfoCreateServiceRequest; | ||
import com.heachi.mysql.define.housework.category.HouseworkCategory; | ||
import com.heachi.mysql.define.housework.info.HouseworkInfo; | ||
import com.heachi.mysql.define.housework.info.constant.HouseworkPeriodType; | ||
import com.heachi.mysql.define.housework.todo.HouseworkTodo; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.ToString; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalTime; | ||
import java.util.List; | ||
|
||
@Getter | ||
@ToString | ||
public class HouseworkInfoUpdatePageResponse { | ||
String title; | ||
Long houseworkCategoryId; | ||
List<Long> groupMemberIdList; | ||
HouseworkPeriodType type; | ||
LocalDate localDate; | ||
String weekDate; | ||
String monthDate; | ||
LocalTime endTime; | ||
|
||
@Builder | ||
public HouseworkInfoUpdatePageResponse(String title, Long houseworkCategoryId, List<Long> groupMemberIdList, HouseworkPeriodType type, LocalDate localDate, String weekDate, String monthDate, LocalTime endTime) { | ||
this.title = title; | ||
this.houseworkCategoryId = houseworkCategoryId; | ||
this.groupMemberIdList = groupMemberIdList; | ||
this.type = type; | ||
this.localDate = localDate; | ||
this.weekDate = weekDate; | ||
this.monthDate = monthDate; | ||
this.endTime = endTime; | ||
} | ||
|
||
public static HouseworkInfoUpdatePageResponse of(HouseworkTodo todo, HouseworkCategory category, List<Long> groupMemberIdList) { | ||
|
||
return HouseworkInfoUpdatePageResponse.builder() | ||
.title(todo.getTitle()) | ||
.houseworkCategoryId(category.getId()) | ||
.groupMemberIdList(groupMemberIdList) | ||
.type(HouseworkPeriodType.HOUSEWORK_PERIOD_DAY) | ||
.localDate(todo.getDate()) | ||
.endTime(todo.getEndTime()) | ||
.build(); | ||
} | ||
|
||
public static HouseworkInfoUpdatePageResponse of(HouseworkInfo info, List<Long> groupMemberIdList) { | ||
|
||
return HouseworkInfoUpdatePageResponse.builder() | ||
.title(info.getTitle()) | ||
.houseworkCategoryId(info.getHouseworkCategory().getId()) | ||
.groupMemberIdList(groupMemberIdList) | ||
.type(info.getType()) | ||
.localDate(info.getDayDate()) | ||
.weekDate(info.getWeekDate()) | ||
.monthDate(info.getMonthDate()) | ||
.endTime(info.getEndTime()) | ||
.build(); | ||
} | ||
} |
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
41 changes: 41 additions & 0 deletions
41
...om/heachi/mysql/define/housework/category/repository/HouseworkCategoryRepositoryTest.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,41 @@ | ||
package com.heachi.mysql.define.housework.category.repository; | ||
|
||
import com.heachi.mysql.TestConfig; | ||
import com.heachi.mysql.define.group.info.repository.GroupInfoRepository; | ||
import com.heachi.mysql.define.group.member.repository.GroupMemberRepository; | ||
import com.heachi.mysql.define.housework.category.HouseworkCategory; | ||
import com.heachi.mysql.define.housework.info.repository.HouseworkInfoRepository; | ||
import com.heachi.mysql.define.housework.member.repository.HouseworkMemberRepository; | ||
import com.heachi.mysql.define.housework.todo.repository.HouseworkTodoRepository; | ||
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 static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
@SpringBootTest | ||
class HouseworkCategoryRepositoryTest extends TestConfig { | ||
|
||
@Autowired | ||
private HouseworkCategoryRepository houseworkCategoryRepository; | ||
|
||
@AfterEach | ||
void tearDown() { | ||
houseworkCategoryRepository.deleteAllInBatch(); | ||
} | ||
|
||
|
||
@Test | ||
@DisplayName("카테고리 이름으로 조회 성공 테스트") | ||
void test1() { | ||
// given | ||
HouseworkCategory category = houseworkCategoryRepository.save(generateHouseworkCategory()); | ||
|
||
// when & then | ||
assertThat(houseworkCategoryRepository.findHouseworkCategoryByName(category.getName()).equals("집안일")); | ||
} | ||
} |