From a1678709a3f88c25e08eb150df07e84da380fd92 Mon Sep 17 00:00:00 2001 From: LDY Date: Sun, 7 Jul 2024 15:15:08 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=ED=8F=B4=EB=8D=94=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80,=20=EC=83=89=EC=83=81=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=20#23?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/DirectoryService.java | 3 +- .../server/directory/domain/Directory.java | 19 ++++++++-- .../directory/domain/type/DirectoryColor.java | 12 ++++++ .../directory/domain/type/DirectoryIcon.java | 8 ++++ .../dto/request/DirectoryInitRequest.java | 10 ++++- .../dto/response/DirectoryResponse.java | 6 ++- .../presentation/DirectoryController.java | 2 +- .../repository/DirectoryRepositoryImpl.java | 3 +- .../repository/init/DirectoryInitializer.java | 37 +++++++++++++------ .../goat/server/directory/util/EnumValid.java | 19 ++++++++++ .../server/directory/util/EnumValidator.java | 23 ++++++++++++ 11 files changed, 121 insertions(+), 21 deletions(-) create mode 100644 src/main/java/com/goat/server/directory/domain/type/DirectoryColor.java create mode 100644 src/main/java/com/goat/server/directory/domain/type/DirectoryIcon.java create mode 100644 src/main/java/com/goat/server/directory/util/EnumValid.java create mode 100644 src/main/java/com/goat/server/directory/util/EnumValidator.java diff --git a/src/main/java/com/goat/server/directory/application/DirectoryService.java b/src/main/java/com/goat/server/directory/application/DirectoryService.java index b42a068..656b6e1 100644 --- a/src/main/java/com/goat/server/directory/application/DirectoryService.java +++ b/src/main/java/com/goat/server/directory/application/DirectoryService.java @@ -13,6 +13,7 @@ import com.goat.server.mypage.domain.User; import com.goat.server.review.application.ReviewService; import com.goat.server.review.dto.response.ReviewSimpleResponse; +import jakarta.validation.Valid; import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -86,7 +87,7 @@ public void deleteDirectoryPermanent(Long userId, Long directoryId) { * 폴더 생성 */ @Transactional - public void initDirectory(Long userId, DirectoryInitRequest directoryInitRequest) { + public void initDirectory(Long userId, @Valid DirectoryInitRequest directoryInitRequest) { User user = userService.findUser(userId); Directory parentDirectory = getParentDirectory(directoryInitRequest); diff --git a/src/main/java/com/goat/server/directory/domain/Directory.java b/src/main/java/com/goat/server/directory/domain/Directory.java index 8e0d48a..f1a19f1 100644 --- a/src/main/java/com/goat/server/directory/domain/Directory.java +++ b/src/main/java/com/goat/server/directory/domain/Directory.java @@ -1,11 +1,15 @@ package com.goat.server.directory.domain; +import com.goat.server.directory.domain.type.DirectoryColor; +import com.goat.server.directory.domain.type.DirectoryIcon; import com.goat.server.global.domain.BaseTimeEntity; import com.goat.server.mypage.domain.User; import com.goat.server.review.domain.Review; import jakarta.persistence.CascadeType; import jakarta.persistence.Column; import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; import jakarta.persistence.FetchType; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; @@ -33,8 +37,11 @@ public class Directory extends BaseTimeEntity { @Column(name = "directory_title", length = 100) private String title; - @Column(name = "directory_color", length = 50) - private String directoryColor; + @Enumerated(EnumType.STRING) + private DirectoryIcon directoryIcon; + + @Enumerated(EnumType.STRING) + private DirectoryColor directoryColor; @Column(name = "depth") private Long depth; @@ -54,14 +61,20 @@ public class Directory extends BaseTimeEntity { private List reviewList = new ArrayList<>(); @Builder - public Directory(String title, String directoryColor, Long depth, User user, Directory parentDirectory) { + public Directory(String title, + DirectoryIcon directoryIcon, + DirectoryColor directoryColor, + Long depth, User user, + Directory parentDirectory) { this.title = title; + this.directoryIcon = directoryIcon; this.directoryColor = directoryColor; this.depth = depth; this.user = user; this.parentDirectory = parentDirectory; } + public void updateParentDirectory(Directory parentDirectory) { this.parentDirectory = parentDirectory; this.depth = parentDirectory.getDepth() + 1; diff --git a/src/main/java/com/goat/server/directory/domain/type/DirectoryColor.java b/src/main/java/com/goat/server/directory/domain/type/DirectoryColor.java new file mode 100644 index 0000000..baf00b5 --- /dev/null +++ b/src/main/java/com/goat/server/directory/domain/type/DirectoryColor.java @@ -0,0 +1,12 @@ +package com.goat.server.directory.domain.type; + +public enum DirectoryColor { + RED, + ORANGE, + YELLOW, + PINK, + GREEN, + CYAN, + BLUE, + PURPLE, +} diff --git a/src/main/java/com/goat/server/directory/domain/type/DirectoryIcon.java b/src/main/java/com/goat/server/directory/domain/type/DirectoryIcon.java new file mode 100644 index 0000000..73b1b0a --- /dev/null +++ b/src/main/java/com/goat/server/directory/domain/type/DirectoryIcon.java @@ -0,0 +1,8 @@ +package com.goat.server.directory.domain.type; + +public enum DirectoryIcon { + PENCIL, + BOOK, + INSIGHT, + BOOK2 +} diff --git a/src/main/java/com/goat/server/directory/dto/request/DirectoryInitRequest.java b/src/main/java/com/goat/server/directory/dto/request/DirectoryInitRequest.java index 7dfdc19..bd16e56 100644 --- a/src/main/java/com/goat/server/directory/dto/request/DirectoryInitRequest.java +++ b/src/main/java/com/goat/server/directory/dto/request/DirectoryInitRequest.java @@ -1,12 +1,17 @@ package com.goat.server.directory.dto.request; import com.goat.server.directory.domain.Directory; +import com.goat.server.directory.domain.type.DirectoryColor; +import com.goat.server.directory.domain.type.DirectoryIcon; +import com.goat.server.directory.util.EnumValid; import com.goat.server.mypage.domain.User; public record DirectoryInitRequest( String directoryName, Long parentDirectoryId, - String directoryColor + @EnumValid(enumClass = DirectoryColor.class) String directoryColor, + @EnumValid(enumClass = DirectoryIcon.class) String directoryIcon, + String directoryDescription ) { public Directory toEntity(User user, Directory parentDirectory) { return Directory.builder() @@ -14,7 +19,8 @@ public Directory toEntity(User user, Directory parentDirectory) { .parentDirectory(parentDirectory) .depth(parentDirectory == null ? 1 : parentDirectory.getDepth() + 1) .title(directoryName) - .directoryColor(directoryColor) + .directoryColor(DirectoryColor.valueOf(directoryColor)) + .directoryIcon(DirectoryIcon.valueOf(directoryIcon)) .build(); } } \ No newline at end of file diff --git a/src/main/java/com/goat/server/directory/dto/response/DirectoryResponse.java b/src/main/java/com/goat/server/directory/dto/response/DirectoryResponse.java index 9d530ab..e5112b6 100644 --- a/src/main/java/com/goat/server/directory/dto/response/DirectoryResponse.java +++ b/src/main/java/com/goat/server/directory/dto/response/DirectoryResponse.java @@ -1,13 +1,16 @@ package com.goat.server.directory.dto.response; import com.goat.server.directory.domain.Directory; +import com.goat.server.directory.domain.type.DirectoryColor; +import com.goat.server.directory.domain.type.DirectoryIcon; import lombok.Builder; @Builder public record DirectoryResponse( Long directoryId, String directoryName, - String directoryColor + DirectoryColor directoryColor, + DirectoryIcon directoryIcon ) { public static DirectoryResponse from(Directory directory) { @@ -15,6 +18,7 @@ public static DirectoryResponse from(Directory directory) { .directoryId(directory.getId()) .directoryName(directory.getTitle()) .directoryColor(directory.getDirectoryColor()) + .directoryIcon(directory.getDirectoryIcon()) .build(); } } diff --git a/src/main/java/com/goat/server/directory/presentation/DirectoryController.java b/src/main/java/com/goat/server/directory/presentation/DirectoryController.java index 9f228f5..6a84db9 100644 --- a/src/main/java/com/goat/server/directory/presentation/DirectoryController.java +++ b/src/main/java/com/goat/server/directory/presentation/DirectoryController.java @@ -56,7 +56,7 @@ public ResponseEntity> getDirectorySubList( @PostMapping public ResponseEntity> initDirectory( @AuthenticationPrincipal Long userId, - @RequestBody DirectoryInitRequest directoryInitRequest) { + @Valid @RequestBody DirectoryInitRequest directoryInitRequest) { directoryService.initDirectory(userId, directoryInitRequest); diff --git a/src/main/java/com/goat/server/directory/repository/DirectoryRepositoryImpl.java b/src/main/java/com/goat/server/directory/repository/DirectoryRepositoryImpl.java index efe5580..2d88fde 100644 --- a/src/main/java/com/goat/server/directory/repository/DirectoryRepositoryImpl.java +++ b/src/main/java/com/goat/server/directory/repository/DirectoryRepositoryImpl.java @@ -27,7 +27,8 @@ public List findAllDirectoryResponseBySortAndSearch( .select(Projections.constructor(DirectoryResponse.class, directory.id, directory.title, - directory.directoryColor)) + directory.directoryColor, + directory.directoryIcon)) .from(directory) .where(directory.user.userId.eq(userId), isSearchExpression(parentDirectoryId, search)) .orderBy(sortExpression(sort)) diff --git a/src/main/java/com/goat/server/directory/repository/init/DirectoryInitializer.java b/src/main/java/com/goat/server/directory/repository/init/DirectoryInitializer.java index 16c9746..b53f24b 100644 --- a/src/main/java/com/goat/server/directory/repository/init/DirectoryInitializer.java +++ b/src/main/java/com/goat/server/directory/repository/init/DirectoryInitializer.java @@ -1,5 +1,7 @@ package com.goat.server.directory.repository.init; +import com.goat.server.directory.domain.type.DirectoryColor; +import com.goat.server.directory.domain.type.DirectoryIcon; import com.goat.server.global.util.LocalDummyDataInit; import com.goat.server.directory.domain.Directory; import com.goat.server.directory.repository.DirectoryRepository; @@ -41,21 +43,23 @@ public void run(ApplicationArguments args) { Directory DUMMY_TRASH_DIRECTORY1 = Directory.builder() .title("trash_directory") - .directoryColor("#FF00FF") + .directoryColor(DirectoryColor.CYAN) + .directoryIcon(DirectoryIcon.BOOK) .depth(1L) .parentDirectory(null) .user(admin) .build(); Directory DUMMY_TRASH_DIRECTORY2 = Directory.builder() .title("trash_directory") - .directoryColor("#FF00FF") + .directoryColor(DirectoryColor.PINK) + .directoryIcon(DirectoryIcon.BOOK) .depth(1L) .parentDirectory(null) .user(user) .build(); Directory DUMMY_TRASH_DIRECTORY3 = Directory.builder() .title("trash_directory") - .directoryColor("#FF00FF") + .directoryColor(DirectoryColor.CYAN) .depth(1L) .parentDirectory(null) .user(guest) @@ -63,21 +67,24 @@ public void run(ApplicationArguments args) { Directory DUMMY_PARENT_DIRECTORY1 = Directory.builder() .title("dummyDirectory1") - .directoryColor("#FF00FF") + .directoryColor(DirectoryColor.CYAN) + .directoryIcon(DirectoryIcon.BOOK) .depth(1L) .parentDirectory(null) .user(user) .build(); Directory DUMMY_PARENT_DIRECTORY2 = Directory.builder() .title("dummyDirectory2") - .directoryColor("#FF00FF") + .directoryColor(DirectoryColor.CYAN) + .directoryIcon(DirectoryIcon.BOOK) .depth(1L) .parentDirectory(null) .user(user) .build(); Directory DUMMY_PARENT_DIRECTORY3 = Directory.builder() .title("dummyDirectory3") - .directoryColor("#FF000F") + .directoryColor(DirectoryColor.CYAN) + .directoryIcon(DirectoryIcon.BOOK) .depth(1L) .parentDirectory(null) .user(admin) @@ -85,21 +92,24 @@ public void run(ApplicationArguments args) { Directory DUMMY_CHILD_DIRECTORY1 = Directory.builder() .title("dummyDirectory4") - .directoryColor("#FF00FF") + .directoryColor(DirectoryColor.CYAN) + .directoryIcon(DirectoryIcon.BOOK) .depth(2L) .parentDirectory(DUMMY_PARENT_DIRECTORY1) .user(user) .build(); Directory DUMMY_CHILD_DIRECTORY2 = Directory.builder() .title("dummyDirectory5") - .directoryColor("#FF00FF") + .directoryColor(DirectoryColor.CYAN) + .directoryIcon(DirectoryIcon.BOOK) .depth(2L) .parentDirectory(DUMMY_PARENT_DIRECTORY1) .user(user) .build(); Directory DUMMY_CHILD_DIRECTORY3 = Directory.builder() .title("dummyDirectory6") - .directoryColor("#FF00FF") + .directoryColor(DirectoryColor.CYAN) + .directoryIcon(DirectoryIcon.BOOK) .depth(2L) .parentDirectory(DUMMY_CHILD_DIRECTORY2) .user(user) @@ -107,21 +117,24 @@ public void run(ApplicationArguments args) { Directory DUMMY_STORAGE_DIRECTORY1 = Directory.builder() .title("storage_directory") - .directoryColor("#FF00FF") + .directoryColor(DirectoryColor.CYAN) + .directoryIcon(DirectoryIcon.BOOK) .depth(1L) .parentDirectory(null) .user(admin) .build(); Directory DUMMY_STORAGE_DIRECTORY2 = Directory.builder() .title("storage_directory") - .directoryColor("#FF00FF") + .directoryColor(DirectoryColor.CYAN) + .directoryIcon(DirectoryIcon.BOOK) .depth(1L) .parentDirectory(null) .user(user) .build(); Directory DUMMY_STORAGE_DIRECTORY3 = Directory.builder() .title("storage_directory") - .directoryColor("#FF00FF") + .directoryColor(DirectoryColor.CYAN) + .directoryIcon(DirectoryIcon.BOOK) .depth(1L) .parentDirectory(null) .user(guest) diff --git a/src/main/java/com/goat/server/directory/util/EnumValid.java b/src/main/java/com/goat/server/directory/util/EnumValid.java new file mode 100644 index 0000000..2833260 --- /dev/null +++ b/src/main/java/com/goat/server/directory/util/EnumValid.java @@ -0,0 +1,19 @@ +package com.goat.server.directory.util; + +import jakarta.validation.Constraint; +import jakarta.validation.Payload; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.FIELD, ElementType.PARAMETER}) +@Retention(RetentionPolicy.RUNTIME) +@Constraint(validatedBy = EnumValidator.class) +public @interface EnumValid { + + Class> enumClass(); + String message() default "지정되지 않은 Enum 값입니다."; + Class[] groups() default {}; + Class[] payload() default {}; +} diff --git a/src/main/java/com/goat/server/directory/util/EnumValidator.java b/src/main/java/com/goat/server/directory/util/EnumValidator.java new file mode 100644 index 0000000..49cf05d --- /dev/null +++ b/src/main/java/com/goat/server/directory/util/EnumValidator.java @@ -0,0 +1,23 @@ +package com.goat.server.directory.util; + +import jakarta.validation.ConstraintValidator; +import jakarta.validation.ConstraintValidatorContext; +import java.util.Arrays; +import java.util.Set; +import java.util.stream.Collectors; + +public class EnumValidator implements ConstraintValidator { + private Set acceptedValues; + + @Override + public void initialize(EnumValid enumAnnotation) { + acceptedValues = Arrays.stream(enumAnnotation.enumClass().getEnumConstants()) + .map(Enum::name) + .collect(Collectors.toSet()); + } + + @Override + public boolean isValid(String value, ConstraintValidatorContext context) { + return acceptedValues.contains(value); + } +} From 2ad456b109e8cf9d880a61b11679e291978aa888 Mon Sep 17 00:00:00 2001 From: LDY Date: Mon, 8 Jul 2024 17:30:43 +0900 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=EB=B9=84=EC=A6=88=EB=8B=88?= =?UTF-8?q?=EC=8A=A4=20=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95=EC=97=90=20?= =?UTF-8?q?=EB=94=B0=EB=A5=B8=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/DirectoryServiceTest.java | 20 ++++++++------ .../directory/fixture/DirectoryFixture.java | 26 ++++++++++++------- .../presentation/DirectoryControllerTest.java | 5 ++-- 3 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/test/java/com/goat/server/directory/application/DirectoryServiceTest.java b/src/test/java/com/goat/server/directory/application/DirectoryServiceTest.java index 8819e78..dba84a9 100644 --- a/src/test/java/com/goat/server/directory/application/DirectoryServiceTest.java +++ b/src/test/java/com/goat/server/directory/application/DirectoryServiceTest.java @@ -59,8 +59,10 @@ void getDirectoryListTest() { //given given(directoryRepository.existsById(PARENT_DIRECTORY1.getId())) .willReturn(true); - given(directoryRepository.findAllDirectoryResponseBySortAndSearch(eq(USER_USER.getUserId()), eq(PARENT_DIRECTORY1.getId()), any(), any())) - .willReturn(List.of(DirectoryResponse.from(CHILD_DIRECTORY1), DirectoryResponse.from(CHILD_DIRECTORY2))); + given(directoryRepository.findAllDirectoryResponseBySortAndSearch(eq(USER_USER.getUserId()), + eq(PARENT_DIRECTORY1.getId()), any(), any())) + .willReturn( + List.of(DirectoryResponse.from(CHILD_DIRECTORY1), DirectoryResponse.from(CHILD_DIRECTORY2))); given(reviewService.getReviewSimpleResponseList(any(), eq(PARENT_DIRECTORY1.getId()), any(), any())).willReturn( List.of(ReviewSimpleResponse.from(DUMMY_REVIEW1), ReviewSimpleResponse.from(DUMMY_REVIEW2))); @@ -82,8 +84,10 @@ void getDirectoryListTest() { @DisplayName("과목과 폴더 가져 오기 테스트 - 루트 폴더") void getDirectoryListTest2() { //given - given(directoryRepository.findAllDirectoryResponseBySortAndSearch(eq(USER_USER.getUserId()), eq(0L), any(), any())) - .willReturn(List.of(DirectoryResponse.from(PARENT_DIRECTORY1), DirectoryResponse.from(PARENT_DIRECTORY2))); + given(directoryRepository.findAllDirectoryResponseBySortAndSearch(eq(USER_USER.getUserId()), eq(0L), any(), + any())) + .willReturn( + List.of(DirectoryResponse.from(PARENT_DIRECTORY1), DirectoryResponse.from(PARENT_DIRECTORY2))); //when DirectoryTotalShowResponse directorySubList = @@ -118,7 +122,7 @@ void deleteDirectoryTemporalTest() { void initDirectoryTest() { //given DirectoryInitRequest directoryInitRequest = - new DirectoryInitRequest("폴더", 0L, "#FF0000"); + new DirectoryInitRequest("폴더", 0L, "BLUE", "PENCIL", "description"); given(userService.findUser(USER_USER.getUserId())).willReturn(USER_USER); @@ -131,7 +135,7 @@ void initDirectoryTest() { Directory savedDirectory = directoryCaptor.getValue(); assertThat(savedDirectory.getTitle()).isEqualTo(directoryInitRequest.directoryName()); assertThat(savedDirectory.getParentDirectory()).isNull(); - assertThat(savedDirectory.getDirectoryColor()).isEqualTo(directoryInitRequest.directoryColor()); + assertThat(savedDirectory.getDirectoryColor().toString()).isEqualTo(directoryInitRequest.directoryColor()); } @Test @@ -139,7 +143,7 @@ void initDirectoryTest() { void initDirectoryTest2() { //given DirectoryInitRequest directoryInitRequest = - new DirectoryInitRequest("폴더", PARENT_DIRECTORY1.getId(), "#FF0000"); + new DirectoryInitRequest("폴더", PARENT_DIRECTORY1.getId(), "BLUE", "PENCIL", "description"); given(userService.findUser(USER_USER.getUserId())).willReturn(USER_USER); given(directoryRepository.findById(PARENT_DIRECTORY1.getId())) @@ -154,7 +158,7 @@ void initDirectoryTest2() { Directory savedDirectory = directoryCaptor.getValue(); assertThat(savedDirectory.getTitle()).isEqualTo(directoryInitRequest.directoryName()); assertThat(savedDirectory.getParentDirectory()).isEqualTo(PARENT_DIRECTORY1); - assertThat(savedDirectory.getDirectoryColor()).isEqualTo(directoryInitRequest.directoryColor()); + assertThat(savedDirectory.getDirectoryColor().toString()).isEqualTo(directoryInitRequest.directoryColor()); } @Test diff --git a/src/test/java/com/goat/server/directory/fixture/DirectoryFixture.java b/src/test/java/com/goat/server/directory/fixture/DirectoryFixture.java index eab7fc7..814580a 100644 --- a/src/test/java/com/goat/server/directory/fixture/DirectoryFixture.java +++ b/src/test/java/com/goat/server/directory/fixture/DirectoryFixture.java @@ -1,6 +1,8 @@ package com.goat.server.directory.fixture; import com.goat.server.directory.domain.Directory; +import com.goat.server.directory.domain.type.DirectoryColor; +import com.goat.server.directory.domain.type.DirectoryIcon; import com.goat.server.mypage.fixture.UserFixture; import org.springframework.test.util.ReflectionTestUtils; @@ -8,7 +10,8 @@ public class DirectoryFixture { public static final Directory TRASH_DIRECTORY = Directory.builder() .title("trash_directory") - .directoryColor("#FF00FF") + .directoryColor(DirectoryColor.BLUE) + .directoryIcon(DirectoryIcon.BOOK) .depth(1L) .parentDirectory(null) .user(UserFixture.USER_USER) @@ -16,14 +19,16 @@ public class DirectoryFixture { public static final Directory PARENT_DIRECTORY1 = Directory.builder() .title("directory1") - .directoryColor("#FF00FF") + .directoryColor(DirectoryColor.BLUE) + .directoryIcon(DirectoryIcon.BOOK) .parentDirectory(null) .depth(1L) .user(UserFixture.USER_USER) .build(); public static final Directory PARENT_DIRECTORY2 = Directory.builder() .title("directory2") - .directoryColor("#FF00FF") + .directoryColor(DirectoryColor.BLUE) + .directoryIcon(DirectoryIcon.BOOK) .parentDirectory(null) .depth(1L) .user(UserFixture.USER_USER) @@ -31,23 +36,26 @@ public class DirectoryFixture { public static final Directory CHILD_DIRECTORY1 = Directory.builder() .title("directory3") - .directoryColor("#FF00FF") + .directoryColor(DirectoryColor.BLUE) + .directoryIcon(DirectoryIcon.BOOK) .parentDirectory(PARENT_DIRECTORY1) .depth(2L) .user(UserFixture.USER_USER) .build(); public static final Directory CHILD_DIRECTORY2 = Directory.builder() .title("directory3") - .directoryColor("#FF00FF") + .directoryColor(DirectoryColor.BLUE) + .directoryIcon(DirectoryIcon.BOOK) .parentDirectory(PARENT_DIRECTORY1) .depth(2L) .user(UserFixture.USER_USER) .build(); static { - ReflectionTestUtils.setField(PARENT_DIRECTORY1, "id", 1L); - ReflectionTestUtils.setField(PARENT_DIRECTORY2, "id", 2L); - ReflectionTestUtils.setField(CHILD_DIRECTORY1, "id", 3L); - ReflectionTestUtils.setField(CHILD_DIRECTORY2, "id", 4L); + ReflectionTestUtils.setField(TRASH_DIRECTORY, "id", 1L); + ReflectionTestUtils.setField(PARENT_DIRECTORY1, "id", 2L); + ReflectionTestUtils.setField(PARENT_DIRECTORY2, "id", 3L); + ReflectionTestUtils.setField(CHILD_DIRECTORY1, "id", 4L); + ReflectionTestUtils.setField(CHILD_DIRECTORY2, "id", 5L); } } diff --git a/src/test/java/com/goat/server/directory/presentation/DirectoryControllerTest.java b/src/test/java/com/goat/server/directory/presentation/DirectoryControllerTest.java index e98cab1..e674d3c 100644 --- a/src/test/java/com/goat/server/directory/presentation/DirectoryControllerTest.java +++ b/src/test/java/com/goat/server/directory/presentation/DirectoryControllerTest.java @@ -58,7 +58,8 @@ void getDirectoryListTest() throws Exception { List reviewSimpleResponseList = List.of(ReviewSimpleResponse.from(DUMMY_REVIEW1), ReviewSimpleResponse.from(DUMMY_REVIEW2)); DirectoryTotalShowResponse directoryTotalShowResponse = - DirectoryTotalShowResponse.of(PARENT_DIRECTORY1.getId(), directoryResponseList, reviewSimpleResponseList); + DirectoryTotalShowResponse.of(PARENT_DIRECTORY1.getId(), directoryResponseList, + reviewSimpleResponseList); given(directoryService.getDirectorySubList(anyLong(), eq(PARENT_DIRECTORY1.getId()), any(), any())) .willReturn(directoryTotalShowResponse); @@ -88,7 +89,7 @@ void getDirectoryListTest() throws Exception { void initDirectoryTest() throws Exception { //given DirectoryInitRequest request = - new DirectoryInitRequest("폴더 이름", PARENT_DIRECTORY1.getId(), "#FFFFFF"); + new DirectoryInitRequest("폴더 이름", PARENT_DIRECTORY1.getId(), "BLUE", "PENCIL", "설명"); //when ResultActions resultActions =