From 89c72461123a8a748fc03beb5e818bfa55e13569 Mon Sep 17 00:00:00 2001 From: Sosohy Date: Wed, 19 Jun 2024 10:29:56 +0900 Subject: [PATCH 1/7] =?UTF-8?q?fix(post)=20:=20cmdPostService=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 포스트 생성 시 마다 tab 생성 및 할당으로 변경, 서비스에서 사용자 정보를 whoAmI()로 받아서 사용함으로 null로 수정 --- .../service/CmdPostServiceTests.java | 44 ++++++++++++++----- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/src/test/java/org/triumers/kmsback/post/command/Application/service/CmdPostServiceTests.java b/src/test/java/org/triumers/kmsback/post/command/Application/service/CmdPostServiceTests.java index 3551026c..63bd9e8e 100644 --- a/src/test/java/org/triumers/kmsback/post/command/Application/service/CmdPostServiceTests.java +++ b/src/test/java/org/triumers/kmsback/post/command/Application/service/CmdPostServiceTests.java @@ -14,6 +14,13 @@ import org.triumers.kmsback.common.exception.WrongInputTypeException; import org.triumers.kmsback.post.command.Application.dto.*; import org.triumers.kmsback.post.command.domain.aggregate.vo.CmdRequestPostAI; +import org.triumers.kmsback.tab.command.Application.controller.CmdTabController; +import org.triumers.kmsback.tab.command.Application.dto.CmdTabDTO; +import org.triumers.kmsback.tab.command.Application.dto.CmdTabRelationDTO; +import org.triumers.kmsback.tab.command.Application.service.CmdTabService; +import org.triumers.kmsback.tab.command.domain.aggregate.entity.CmdTabRelation; +import org.triumers.kmsback.user.command.Application.service.AuthService; +import org.triumers.kmsback.user.command.domain.aggregate.entity.Employee; import java.time.LocalDateTime; import java.util.ArrayList; @@ -28,12 +35,16 @@ public class CmdPostServiceTests { private final CmdPostService cmdPostService; private final OpenAIService openAIService; private final LoggedInUser loggedInUser; + private final AuthService authService; + private final CmdTabService cmdTabService; @Autowired - public CmdPostServiceTests(CmdPostService cmdPostService, OpenAIService openAIService, LoggedInUser loggedInUser) { + public CmdPostServiceTests(CmdPostService cmdPostService, OpenAIService openAIService, LoggedInUser loggedInUser, AuthService authService, CmdTabService cmdTabService) { this.cmdPostService = cmdPostService; this.openAIService = openAIService; this.loggedInUser = loggedInUser; + this.authService = authService; + this.cmdTabService = cmdTabService; } @BeforeEach @@ -60,10 +71,10 @@ void modifyPost() throws NotLoginException { List modifyTags = new ArrayList<>(); modifyTags.add("개발"); - modifyTags.add("tag1"); - modifyTags.add("tag2"); - modifyTags.add("tag3"); - modifyTags.add("tag4"); + modifyTags.add("tag11"); + modifyTags.add("tag12"); + modifyTags.add("tag13"); + modifyTags.add("tag14"); CmdPostAndTagsDTO modifyPost = createTestPost("modify"); modifyPost.setTags(modifyTags); @@ -90,7 +101,7 @@ void likePost() throws NotLoginException { CmdPostAndTagsDTO savedPost = cmdPostService.registPost(createTestPost()); - CmdLikeDTO like = new CmdLikeDTO(1, savedPost.getId()); + CmdLikeDTO like = new CmdLikeDTO(null, savedPost.getId()); CmdLikeDTO likePost = cmdPostService.likePost(like); assertThat(likePost.getId()).isNotNull(); @@ -103,7 +114,7 @@ void favoritePost() throws NotLoginException { CmdPostAndTagsDTO savedPost = cmdPostService.registPost(createTestPost()); - CmdFavoritesDTO favorite = new CmdFavoritesDTO(1, savedPost.getId()); + CmdFavoritesDTO favorite = new CmdFavoritesDTO(null, savedPost.getId()); CmdFavoritesDTO likePost = cmdPostService.favoritePost(favorite); assertThat(likePost.getId()).isNotNull(); @@ -131,11 +142,11 @@ void testGPT(){ cmdPostService.requestToGPT(request); } - private CmdPostAndTagsDTO createTestPost(){ + private CmdPostAndTagsDTO createTestPost() throws NotLoginException { return createTestPost(""); } - private CmdPostAndTagsDTO createTestPost(String type){ + private CmdPostAndTagsDTO createTestPost(String type) throws NotLoginException { List tags = new ArrayList<>(); tags.add("개발"); tags.add("tag1"); @@ -143,7 +154,20 @@ private CmdPostAndTagsDTO createTestPost(String type){ tags.add("tag3"); tags.add("tag4"); - return new CmdPostAndTagsDTO(type + "Title", type + "Content", null, LocalDateTime.now(), 1, 1, tags); + CmdTabRelationDTO tab = createTestTab(); + + return new CmdPostAndTagsDTO(type + "Title", type + "Content", null, LocalDateTime.now(), null, tab.getId(), tags); + } + + private CmdTabRelationDTO createTestTab() throws NotLoginException { + + CmdTabDTO top = new CmdTabDTO("testTop"); + CmdTabDTO bottom = new CmdTabDTO("testBottom"); + CmdTabRelationDTO tabRelation = new CmdTabRelationDTO(false, bottom, top); + + Employee employee = authService.whoAmI(); + + return cmdTabService.registTab(tabRelation, employee.getId()); } } From 1558d4175d5b165b0cf85505ffad552599a56228 Mon Sep 17 00:00:00 2001 From: Sosohy Date: Fri, 21 Jun 2024 10:16:09 +0900 Subject: [PATCH 2/7] =?UTF-8?q?refactor(post)=20:=20=EA=B0=9C=ED=96=89?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/CmdPostServiceImpl.java | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/triumers/kmsback/post/command/Application/service/CmdPostServiceImpl.java b/src/main/java/org/triumers/kmsback/post/command/Application/service/CmdPostServiceImpl.java index 70cec4bf..d7ff50d1 100644 --- a/src/main/java/org/triumers/kmsback/post/command/Application/service/CmdPostServiceImpl.java +++ b/src/main/java/org/triumers/kmsback/post/command/Application/service/CmdPostServiceImpl.java @@ -2,6 +2,7 @@ import jakarta.mail.MessagingException; import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; import org.jsoup.safety.Whitelist; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -87,24 +88,16 @@ public CmdPostAndTagsDTO registPost(CmdPostAndTagsDTO post) throws NotLoginExcep public static String sanitizeHTML(String html) { - // 공백, 줄바꿈 대체 - String spacePlaceholder = "___SPACE___"; - String newlinePlaceholder = "___NEWLINE___"; - String htmlWithPlaceholders = html - .replaceAll(" ", spacePlaceholder) - .replaceAll("\n", newlinePlaceholder) - .replaceAll("\r\n", newlinePlaceholder); - - Whitelist whitelist = Whitelist.relaxed(); + Whitelist whitelist = Whitelist.basic(); // 허용되지 않을 태그와 속성 추가 whitelist.removeTags("script", "style", "head", "header", "foot", "footer"); whitelist.removeAttributes("style", "onclick"); - String cleanedHtmlWithPlaceholders = Jsoup.clean(htmlWithPlaceholders, whitelist); + // 개행 사라지지 않도록 처리 + Document.OutputSettings settings = new Document.OutputSettings(); + settings.prettyPrint(false); - String cleanedHtml = cleanedHtmlWithPlaceholders - .replaceAll(spacePlaceholder, " ") - .replaceAll(newlinePlaceholder, "\n"); + String cleanedHtml = Jsoup.clean(html,"", whitelist, settings); return cleanedHtml; } From 2ead6640902b781ac217020767c6815619b96014 Mon Sep 17 00:00:00 2001 From: Sosohy Date: Fri, 21 Jun 2024 10:20:33 +0900 Subject: [PATCH 3/7] =?UTF-8?q?refactor(post)=20:=20=EC=A3=BC=EC=84=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../post/command/Application/service/CmdPostServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/triumers/kmsback/post/command/Application/service/CmdPostServiceImpl.java b/src/main/java/org/triumers/kmsback/post/command/Application/service/CmdPostServiceImpl.java index d7ff50d1..c8e9256e 100644 --- a/src/main/java/org/triumers/kmsback/post/command/Application/service/CmdPostServiceImpl.java +++ b/src/main/java/org/triumers/kmsback/post/command/Application/service/CmdPostServiceImpl.java @@ -89,7 +89,7 @@ public CmdPostAndTagsDTO registPost(CmdPostAndTagsDTO post) throws NotLoginExcep public static String sanitizeHTML(String html) { Whitelist whitelist = Whitelist.basic(); - // 허용되지 않을 태그와 속성 추가 + // 허용되지 않을 태그, 속성 추가 whitelist.removeTags("script", "style", "head", "header", "foot", "footer"); whitelist.removeAttributes("style", "onclick"); From 63055f4f3079102a462df0a4eaa27bbe6b666e5a Mon Sep 17 00:00:00 2001 From: Sosohy Date: Sat, 22 Jun 2024 21:28:11 +0900 Subject: [PATCH 4/7] =?UTF-8?q?refactor(post)=20:=20QryPost=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 사용자 참여 게시글까지 수정 완료 --- .../query/service/QryPostServiceTest.java | 41 +++++++++++++++---- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/src/test/java/org/triumers/kmsback/post/query/service/QryPostServiceTest.java b/src/test/java/org/triumers/kmsback/post/query/service/QryPostServiceTest.java index 38ac75d7..67bda822 100644 --- a/src/test/java/org/triumers/kmsback/post/query/service/QryPostServiceTest.java +++ b/src/test/java/org/triumers/kmsback/post/query/service/QryPostServiceTest.java @@ -18,6 +18,11 @@ import org.triumers.kmsback.post.command.Application.service.CmdPostService; import org.triumers.kmsback.post.query.aggregate.vo.QryRequestPost; import org.triumers.kmsback.post.query.dto.QryPostAndTagsDTO; +import org.triumers.kmsback.tab.command.Application.dto.CmdTabDTO; +import org.triumers.kmsback.tab.command.Application.dto.CmdTabRelationDTO; +import org.triumers.kmsback.tab.command.Application.service.CmdTabService; +import org.triumers.kmsback.user.command.Application.service.AuthService; +import org.triumers.kmsback.user.command.domain.aggregate.entity.Employee; import org.triumers.kmsback.user.query.dto.QryEmployeeDTO; import java.time.LocalDateTime; @@ -33,13 +38,17 @@ class QryPostServiceTest { private final QryPostService qryPostService; private final CmdPostService cmdPostService; + private final AuthService authService; + private final CmdTabService cmdTabService; private final LoggedInUser loggedInUser; @Autowired - QryPostServiceTest(QryPostService qryPostService, CmdPostService cmdPostService, LoggedInUser loggedInUser) { + QryPostServiceTest(QryPostService qryPostService, CmdPostService cmdPostService, AuthService authService, CmdTabService cmdTabService, LoggedInUser loggedInUser) { this.qryPostService = qryPostService; this.cmdPostService = cmdPostService; + this.authService = authService; + this.cmdTabService = cmdTabService; this.loggedInUser = loggedInUser; } @@ -51,11 +60,11 @@ void loginSetting() throws WrongInputTypeException { @DisplayName("tab 게시글 리스트 조회") void findPostListByTab() throws NotLoginException, WrongInputValueException { - registPost(); + CmdPostAndTagsDTO savedPost = registPost(); PageRequest pageRequest = PageRequest.of(0, 10); - QryRequestPost request = new QryRequestPost(1, null); + QryRequestPost request = new QryRequestPost(savedPost.getTabRelationId(), null); Page postList = qryPostService.findPostListByTab(request, pageRequest); @@ -66,11 +75,11 @@ void findPostListByTab() throws NotLoginException, WrongInputValueException { @DisplayName("회원이 속한 전체 게시글 리스트 조회") void findAllPostListByTab() throws NotLoginException, WrongInputValueException { - registPost(); + CmdPostAndTagsDTO savedPost = registPost(); PageRequest pageRequest = PageRequest.of(0, 10); - QryRequestPost request = new QryRequestPost(1, null); + QryRequestPost request = new QryRequestPost(null, null); Page postList = qryPostService.findAllPostListByEmployee(request, pageRequest); @@ -91,7 +100,10 @@ void findPostById() throws NotLoginException, WrongInputValueException { @DisplayName("사용자가 참여한 게시글 조회") void findPostByEmployeeId() throws NotLoginException { - List selectedPost = qryPostService.findPostByEmployeeId(1); + registPost(); + Employee employee = authService.whoAmI(); + + List selectedPost = qryPostService.findPostByEmployeeId(employee.getId()); assertThat(selectedPost).isNotNull(); } @@ -186,7 +198,7 @@ private Integer modifyPost() throws NotLoginException { return modifyPost.getOriginId(); } - private CmdPostAndTagsDTO createTestPost(){ + private CmdPostAndTagsDTO createTestPost() throws NotLoginException { List tags = new ArrayList<>(); tags.add("개발"); tags.add("tag1"); @@ -194,6 +206,19 @@ private CmdPostAndTagsDTO createTestPost(){ tags.add("tag3"); tags.add("tag4"); - return new CmdPostAndTagsDTO("newTitle", "newContent", "imgurl", LocalDateTime.now(), 1, 1, tags); + CmdTabRelationDTO tab = createTestTab(); + + return new CmdPostAndTagsDTO("newTitle", "newContent", null, LocalDateTime.now(), null, tab.getId(), tags); + } + + private CmdTabRelationDTO createTestTab() throws NotLoginException { + + CmdTabDTO top = new CmdTabDTO("testTop"); + CmdTabDTO bottom = new CmdTabDTO("testBottom"); + CmdTabRelationDTO tabRelation = new CmdTabRelationDTO(false, bottom, top); + + Employee employee = authService.whoAmI(); + + return cmdTabService.registTab(tabRelation, employee.getId()); } } \ No newline at end of file From 695071aafa28f7e35a6953a841ad07748a1ddbd4 Mon Sep 17 00:00:00 2001 From: Sosohy Date: Mon, 24 Jun 2024 21:06:21 +0900 Subject: [PATCH 5/7] =?UTF-8?q?refactor(post)=20:=20QryTest=20=EC=A6=90?= =?UTF-8?q?=EA=B2=A8=EC=B0=BE=EA=B8=B0/=EC=A2=8B=EC=95=84=EC=9A=94=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DB값 상관없이 insert하며 테스트 진행 --- .../query/service/QryPostServiceTest.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/test/java/org/triumers/kmsback/post/query/service/QryPostServiceTest.java b/src/test/java/org/triumers/kmsback/post/query/service/QryPostServiceTest.java index 67bda822..878ec8a3 100644 --- a/src/test/java/org/triumers/kmsback/post/query/service/QryPostServiceTest.java +++ b/src/test/java/org/triumers/kmsback/post/query/service/QryPostServiceTest.java @@ -112,10 +112,12 @@ void findPostByEmployeeId() throws NotLoginException { @DisplayName("사용자가 좋아요한 게시글 조회") void findLikePostByEmployeeId() throws NotLoginException { - CmdLikeDTO like = new CmdLikeDTO(1, 1); + CmdPostAndTagsDTO post = registPost(); + CmdLikeDTO like = new CmdLikeDTO(null, post.getId()); cmdPostService.likePost(like); - List likedPost = qryPostService.findLikePostByEmployeeId(1); + Employee employee = authService.whoAmI(); + List likedPost = qryPostService.findLikePostByEmployeeId(employee.getId()); assertThat(likedPost).isNotNull(); } @@ -124,10 +126,11 @@ void findLikePostByEmployeeId() throws NotLoginException { @DisplayName("게시글id로 사용자 좋아요 여부 조회") void isLikeByPostId() throws NotLoginException { - CmdLikeDTO like = new CmdLikeDTO(1, 1); + CmdPostAndTagsDTO post = registPost(); + CmdLikeDTO like = new CmdLikeDTO(null, post.getId()); cmdPostService.likePost(like); - Boolean isLiked = qryPostService.findIsLikedByPostId(1); + Boolean isLiked = qryPostService.findIsLikedByPostId(post.getId()); assertThat(isLiked).isTrue(); } @@ -136,10 +139,11 @@ void isLikeByPostId() throws NotLoginException { @DisplayName("게시글id로 사용자 즐겨찾기 여부 조회") void isFavoriteByPostId() throws NotLoginException { - CmdFavoritesDTO favorite = new CmdFavoritesDTO(1, 1); + CmdPostAndTagsDTO post = registPost(); + CmdFavoritesDTO favorite = new CmdFavoritesDTO(null, post.getId()); cmdPostService.favoritePost(favorite); - Boolean isFavorite = qryPostService.findIsFavoriteByPostId(1); + Boolean isFavorite = qryPostService.findIsFavoriteByPostId(post.getId()); assertThat(isFavorite).isTrue(); } @@ -148,9 +152,12 @@ void isFavoriteByPostId() throws NotLoginException { @DisplayName("사용자가 즐겨찾기한 게시글 조회") void findFavoritePostByEmployeeId() throws NotLoginException { - CmdFavoritesDTO favorite = new CmdFavoritesDTO(1, 1); + CmdPostAndTagsDTO post = registPost(); + CmdFavoritesDTO favorite = new CmdFavoritesDTO(null, post.getId()); cmdPostService.favoritePost(favorite); - List favoritePost = qryPostService.findFavoritePostByEmployeeId(1); + + Employee employee = authService.whoAmI(); + List favoritePost = qryPostService.findFavoritePostByEmployeeId(employee.getId()); assertThat(favoritePost).isNotNull(); } From 3b47ea2125904be2b9efbf7a4cbd52640fd5ba86 Mon Sep 17 00:00:00 2001 From: Sosohy Date: Mon, 24 Jun 2024 21:10:08 +0900 Subject: [PATCH 6/7] =?UTF-8?q?refactor(post)=20:=20QryTest=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 회원 아이디 null로 변경 -> 해당 서비스에서 whoAmI() 사용하므로 불필요 --- .../triumers/kmsback/post/query/service/QryPostServiceTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/triumers/kmsback/post/query/service/QryPostServiceTest.java b/src/test/java/org/triumers/kmsback/post/query/service/QryPostServiceTest.java index 878ec8a3..2de80e15 100644 --- a/src/test/java/org/triumers/kmsback/post/query/service/QryPostServiceTest.java +++ b/src/test/java/org/triumers/kmsback/post/query/service/QryPostServiceTest.java @@ -177,7 +177,7 @@ void findHistoryListByOriginId() throws NotLoginException, WrongInputValueExcept void findLikeListByPostId() throws NotLoginException, WrongInputValueException { CmdPostAndTagsDTO post = registPost(); - CmdFavoritesDTO favorite = new CmdFavoritesDTO(1, post.getId()); + CmdFavoritesDTO favorite = new CmdFavoritesDTO(null, post.getId()); cmdPostService.favoritePost(favorite); List likeList = qryPostService.findLikeListByPostId(post.getId()); From b452d785b90641696437cf1bfe4eb3cfb27f7288 Mon Sep 17 00:00:00 2001 From: Sosohy Date: Tue, 25 Jun 2024 10:42:16 +0900 Subject: [PATCH 7/7] =?UTF-8?q?refactor(tab)=20:=20cmdTab=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit db에 데이터 없어도 insert 후 동작하도록 수정 --- .../service/CmdTabServiceTests.java | 80 +++++++++++-------- 1 file changed, 47 insertions(+), 33 deletions(-) diff --git a/src/test/java/org/triumers/kmsback/tab/command/Application/service/CmdTabServiceTests.java b/src/test/java/org/triumers/kmsback/tab/command/Application/service/CmdTabServiceTests.java index b47fd06f..77b22588 100644 --- a/src/test/java/org/triumers/kmsback/tab/command/Application/service/CmdTabServiceTests.java +++ b/src/test/java/org/triumers/kmsback/tab/command/Application/service/CmdTabServiceTests.java @@ -6,10 +6,13 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.transaction.annotation.Transactional; +import org.triumers.kmsback.common.exception.NotLoginException; import org.triumers.kmsback.tab.command.Application.dto.CmdJoinEmployeeDTO; import org.triumers.kmsback.tab.command.Application.dto.CmdTabDTO; import org.triumers.kmsback.tab.command.Application.dto.CmdTabRelationDTO; import org.triumers.kmsback.tab.command.domain.repository.CmdJoinEmployeeRepository; +import org.triumers.kmsback.user.command.Application.service.AuthService; +import org.triumers.kmsback.user.command.domain.aggregate.entity.Employee; import static org.assertj.core.api.Assertions.assertThat; @@ -19,50 +22,61 @@ class CmdTabServiceTests { private final CmdTabService cmdTabService; private final CmdJoinEmployeeRepository cmdJoinEmployeeRepository; - - private final int EMPLOYEE_ID = 1; - private final int TAB_RELATION_ID = 999; + private final AuthService authService; @Autowired - CmdTabServiceTests(CmdTabService cmdTabService, CmdJoinEmployeeRepository cmdJoinEmployeeRepository) { + CmdTabServiceTests(CmdTabService cmdTabService, CmdJoinEmployeeRepository cmdJoinEmployeeRepository, AuthService authService) { this.cmdTabService = cmdTabService; this.cmdJoinEmployeeRepository = cmdJoinEmployeeRepository; + this.authService = authService; } -// @Test -// @DisplayName("탭 참여자 등록") -// void addEmployeeTab(){ -// -// CmdJoinEmployeeDTO employee = new CmdJoinEmployeeDTO(false, EMPLOYEE_ID, TAB_RELATION_ID); -// -// CmdJoinEmployeeDTO savedEmployee = cmdTabService.addEmployeeTab(employee); -// -// assertThat(savedEmployee.getId()).isNotNull(); -// } -// -// @Test -// @DisplayName("탭 참여자 삭제") -// void deleteEmployeeTab(){ -// -// CmdJoinEmployeeDTO employee = new CmdJoinEmployeeDTO(false, EMPLOYEE_ID, TAB_RELATION_ID); -// cmdTabService.addEmployeeTab(employee); -// -// CmdJoinEmployeeDTO deletedEmployee = cmdTabService.deleteEmployeeTab(employee); -// -// assertThat(cmdJoinEmployeeRepository.findById(deletedEmployee.getId())).isEmpty(); -// } + @Test + @DisplayName("탭 참여자 등록") + void addEmployeeTab() throws NotLoginException { + + Employee employee = authService.whoAmI(); + CmdTabRelationDTO tab = createTestTab(); + + CmdJoinEmployeeDTO joinEmployee = new CmdJoinEmployeeDTO(false, employee.getId(), tab.getId()); + + CmdJoinEmployeeDTO savedEmployee = cmdTabService.addEmployeeTab(joinEmployee); + + assertThat(savedEmployee.getId()).isNotNull(); + } @Test - @DisplayName("탭 추가") - void registTab(){ - boolean isPublic = false; - CmdTabDTO top = new CmdTabDTO("top"); - CmdTabDTO bottom = new CmdTabDTO("bottom"); + @DisplayName("탭 참여자 삭제") + void deleteEmployeeTab() throws NotLoginException { + + Employee employee = authService.whoAmI(); + CmdTabRelationDTO tab = createTestTab(); + + CmdJoinEmployeeDTO joinEmployee = new CmdJoinEmployeeDTO(false, employee.getId(), tab.getId()); + cmdTabService.addEmployeeTab(joinEmployee); - CmdTabRelationDTO tabRelation = new CmdTabRelationDTO(isPublic, bottom, top); + CmdJoinEmployeeDTO deletedEmployee = cmdTabService.deleteEmployeeTab(joinEmployee); - CmdTabRelationDTO registTab = cmdTabService.registTab(tabRelation, EMPLOYEE_ID); + assertThat(cmdJoinEmployeeRepository.findById(deletedEmployee.getId())).isEmpty(); + } + + @Test + @DisplayName("탭 추가") + void registTab() throws NotLoginException { + + CmdTabRelationDTO registTab = createTestTab(); assertThat(registTab.getId()).isNotNull(); } + + private CmdTabRelationDTO createTestTab() throws NotLoginException { + + CmdTabDTO top = new CmdTabDTO("testTop"); + CmdTabDTO bottom = new CmdTabDTO("testBottom"); + CmdTabRelationDTO tabRelation = new CmdTabRelationDTO(false, bottom, top); + + Employee employee = authService.whoAmI(); + + return cmdTabService.registTab(tabRelation, employee.getId()); + } } \ No newline at end of file