From 733f3d1775edf178a2f780b3f7b3ed45c4e63381 Mon Sep 17 00:00:00 2001 From: whitemark Date: Sun, 3 Dec 2023 23:37:13 +0900 Subject: [PATCH] =?UTF-8?q?[refactor/#179]=20questionnaire=20test=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 --- .../QuestionnaireRepositoryTest.java | 41 +++++++++++++++++++ .../QuestionnaireServiceTest.java | 19 ++++----- 2 files changed, 50 insertions(+), 10 deletions(-) create mode 100644 resource-server/src/test/java/com/inhabas/api/domain/questionnaire/repository/QuestionnaireRepositoryTest.java rename resource-server/src/test/java/com/inhabas/api/domain/questionnaire/{ => usecase}/QuestionnaireServiceTest.java (64%) diff --git a/resource-server/src/test/java/com/inhabas/api/domain/questionnaire/repository/QuestionnaireRepositoryTest.java b/resource-server/src/test/java/com/inhabas/api/domain/questionnaire/repository/QuestionnaireRepositoryTest.java new file mode 100644 index 00000000..3b5996ba --- /dev/null +++ b/resource-server/src/test/java/com/inhabas/api/domain/questionnaire/repository/QuestionnaireRepositoryTest.java @@ -0,0 +1,41 @@ +package com.inhabas.api.domain.questionnaire.repository; + +import com.inhabas.api.domain.questionnaire.domain.Questionnaire; +import com.inhabas.testAnnotataion.DefaultDataJpaTest; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.ArrayList; +import java.util.List; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + +@DefaultDataJpaTest +class QuestionnaireRepositoryTest { + + @Autowired + private QuestionnaireRepository questionnaireRepository; + + @Test + @DisplayName("idList와 일치하는것이 몇개 포함되어 있는지 확인한다.") + public void countByIdIn() { + //given + ArrayList questionnaireInDatabase = new ArrayList<>() {{ + add(new Questionnaire(1L, "지원동기 및 목표를 기술해주세요.")); + add(new Questionnaire(2L, "프로그래밍 관련 언어를 다루어 본 적이 있다면 적어주세요.")); + add(new Questionnaire(3L, "빅데이터 관련 활동 혹은 공모전 관련 경험이 있다면 적어주세요.")); + add(new Questionnaire(4L, "추후 희망하는 진로가 무엇이며, 동아리 활동이 진로에 어떠한 영향을 줄 것이라고 생각하나요?")); + add(new Questionnaire(5L, "어떤 경로로 IBAS를 알게 되셨나요?")); + }}; + questionnaireRepository.saveAll(questionnaireInDatabase); + + //when + List ids = List.of(1L, 2L, 3L); + Long shouldBeThree = questionnaireRepository.countByIdIn(ids); + + //then + assertThat(shouldBeThree).isEqualTo(3); + + } +} \ No newline at end of file diff --git a/resource-server/src/test/java/com/inhabas/api/domain/questionnaire/QuestionnaireServiceTest.java b/resource-server/src/test/java/com/inhabas/api/domain/questionnaire/usecase/QuestionnaireServiceTest.java similarity index 64% rename from resource-server/src/test/java/com/inhabas/api/domain/questionnaire/QuestionnaireServiceTest.java rename to resource-server/src/test/java/com/inhabas/api/domain/questionnaire/usecase/QuestionnaireServiceTest.java index 23fce649..fe9d5558 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/questionnaire/QuestionnaireServiceTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/questionnaire/usecase/QuestionnaireServiceTest.java @@ -1,12 +1,11 @@ -package com.inhabas.api.domain.questionnaire; +package com.inhabas.api.domain.questionnaire.usecase; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; -import com.inhabas.api.domain.questionaire.domain.Questionnaire; -import com.inhabas.api.domain.questionaire.repository.QuestionnaireRepository; -import com.inhabas.api.domain.questionaire.usecase.QuestionnaireServiceImpl; -import com.inhabas.api.domain.questionaire.dto.QuestionnaireDto; +import com.inhabas.api.domain.questionnaire.domain.Questionnaire; +import com.inhabas.api.domain.questionnaire.repository.QuestionnaireRepository; +import com.inhabas.api.domain.questionnaire.dto.QuestionnaireDto; import java.util.ArrayList; import java.util.List; import org.junit.jupiter.api.DisplayName; @@ -30,11 +29,11 @@ public class QuestionnaireServiceTest { public void getQuestionnaire() { //given ArrayList questionnaireInDatabase = new ArrayList<>(){{ - add(new Questionnaire(1, "지원동기 및 목표를 기술해주세요.")); - add(new Questionnaire(2, "프로그래밍 관련 언어를 다루어 본 적이 있다면 적어주세요.")); - add(new Questionnaire(3, "빅데이터 관련 활동 혹은 공모전 관련 경험이 있다면 적어주세요.")); - add(new Questionnaire(4, "추후 희망하는 진로가 무엇이며, 동아리 활동이 진로에 어떠한 영향을 줄 것이라고 생각하나요?")); - add(new Questionnaire(5, "어떤 경로로 IBAS를 알게 되셨나요?")); + add(new Questionnaire(1L, "지원동기 및 목표를 기술해주세요.")); + add(new Questionnaire(2L, "프로그래밍 관련 언어를 다루어 본 적이 있다면 적어주세요.")); + add(new Questionnaire(3L, "빅데이터 관련 활동 혹은 공모전 관련 경험이 있다면 적어주세요.")); + add(new Questionnaire(4L, "추후 희망하는 진로가 무엇이며, 동아리 활동이 진로에 어떠한 영향을 줄 것이라고 생각하나요?")); + add(new Questionnaire(5L, "어떤 경로로 IBAS를 알게 되셨나요?")); }}; given(questionnaireRepository.findAll()).willReturn(questionnaireInDatabase);