From 73b2a7a8644b19a093011ca080f517093dc84606 Mon Sep 17 00:00:00 2001 From: kevstevie Date: Tue, 8 Aug 2023 14:08:25 +0900 Subject: [PATCH] =?UTF-8?q?test:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/acceptance/steps/TodoSteps.java | 8 ++------ .../backend/application/TodoServiceTest.java | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/backend/src/test/java/com/yigongil/backend/acceptance/steps/TodoSteps.java b/backend/src/test/java/com/yigongil/backend/acceptance/steps/TodoSteps.java index 90d5f6eb5..021b22bc6 100644 --- a/backend/src/test/java/com/yigongil/backend/acceptance/steps/TodoSteps.java +++ b/backend/src/test/java/com/yigongil/backend/acceptance/steps/TodoSteps.java @@ -31,9 +31,7 @@ public TodoSteps(ObjectMapper objectMapper, SharedContext sharedContext) { @Given("{string}가 찾은 회차에 {string}로 필수 투두를 추가한다.") public void 투두_추가(String studyMemberGithubId, String content) throws JsonProcessingException { - TodoCreateRequest request = new TodoCreateRequest( - content - ); + TodoCreateRequest request = new TodoCreateRequest(content); given().log().all() .contentType(MediaType.APPLICATION_JSON_VALUE) @@ -46,9 +44,7 @@ public TodoSteps(ObjectMapper objectMapper, SharedContext sharedContext) { @Given("{string}가 찾은 회차에 {string}로 선택 투두를 추가한다.") public void 선택_투두_추가(String studyMemberGithubId, String content) throws JsonProcessingException { - TodoCreateRequest request = new TodoCreateRequest( - content - ); + TodoCreateRequest request = new TodoCreateRequest(content); ExtractableResponse response = given().log().all() .contentType(MediaType.APPLICATION_JSON_VALUE) diff --git a/backend/src/test/java/com/yigongil/backend/application/TodoServiceTest.java b/backend/src/test/java/com/yigongil/backend/application/TodoServiceTest.java index e55aaa6f0..dd9e35336 100644 --- a/backend/src/test/java/com/yigongil/backend/application/TodoServiceTest.java +++ b/backend/src/test/java/com/yigongil/backend/application/TodoServiceTest.java @@ -13,6 +13,7 @@ import com.yigongil.backend.domain.round.Round; import com.yigongil.backend.domain.round.RoundRepository; import com.yigongil.backend.domain.roundofmember.RoundOfMember; +import com.yigongil.backend.exception.InvalidTodoLengthException; import com.yigongil.backend.exception.NecessaryTodoAlreadyExistException; import com.yigongil.backend.fixture.MemberFixture; import com.yigongil.backend.request.TodoCreateRequest; @@ -76,9 +77,21 @@ class 필수_투두 { TodoCreateRequest request = new TodoCreateRequest("필수 투두"); //when - todoService.createNecessaryTodo(member, round.getId(), request); + //then + assertDoesNotThrow(() -> todoService.createNecessaryTodo(member, round.getId(), request)); + } + + @Test + void 투두가_20자_이상이면_예외가_발생한다() { + //given + willReturn(Optional.of(round)).given(roundRepository).findById(3L); + TodoCreateRequest request = new TodoCreateRequest("필수 투두를 20글자 이상으로 만들고 있습니다 아아"); + + //when //then + assertThatThrownBy(() -> todoService.createNecessaryTodo(member, round.getId(), request)) + .isInstanceOf(InvalidTodoLengthException.class); } @Test