From 14df8c693db4c56e984d9184068d2f70b8e3155e Mon Sep 17 00:00:00 2001 From: Do Yeop Kim <113661364+Dobby-Kim@users.noreply.github.com> Date: Wed, 25 Sep 2024 16:02:43 +0900 Subject: [PATCH 1/2] =?UTF-8?q?test(ApplyFormFacadeTest):=20=EB=88=84?= =?UTF-8?q?=EB=9D=BD=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?-=20read?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../applyform/facade/ApplyFormFacadeTest.java | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/backend/src/test/java/com/cruru/applyform/facade/ApplyFormFacadeTest.java b/backend/src/test/java/com/cruru/applyform/facade/ApplyFormFacadeTest.java index 80ec5e075..ae9f9eef0 100644 --- a/backend/src/test/java/com/cruru/applyform/facade/ApplyFormFacadeTest.java +++ b/backend/src/test/java/com/cruru/applyform/facade/ApplyFormFacadeTest.java @@ -10,6 +10,7 @@ import com.cruru.applyform.controller.request.AnswerCreateRequest; import com.cruru.applyform.controller.request.ApplyFormSubmitRequest; import com.cruru.applyform.controller.request.ApplyFormWriteRequest; +import com.cruru.applyform.controller.response.ApplyFormResponse; import com.cruru.applyform.domain.ApplyForm; import com.cruru.applyform.domain.repository.ApplyFormRepository; import com.cruru.applyform.exception.ApplyFormNotFoundException; @@ -19,8 +20,10 @@ import com.cruru.dashboard.domain.repository.DashboardRepository; import com.cruru.process.domain.Process; import com.cruru.process.domain.repository.ProcessRepository; +import com.cruru.question.controller.response.QuestionResponse; import com.cruru.question.domain.Question; import com.cruru.question.domain.repository.AnswerRepository; +import com.cruru.question.domain.repository.ChoiceRepository; import com.cruru.question.domain.repository.QuestionRepository; import com.cruru.util.ServiceTest; import com.cruru.util.fixture.ApplyFormFixture; @@ -56,12 +59,16 @@ class ApplyFormFacadeTest extends ServiceTest { @Autowired private ApplicantRepository applicantRepository; + @Autowired + private ChoiceRepository choiceRepository; + @Autowired private ApplyFormFacade applyFormFacade; private Process firstProcess; private Process finalProcess; private ApplyForm applyForm; + private Question question1; private List answerCreateRequests; private ApplyFormSubmitRequest applyFormSubmitrequest; private ApplicantCreateRequest applicantCreateRequest; @@ -72,7 +79,7 @@ void setUp() { firstProcess = processRepository.save(ProcessFixture.applyType(dashboard)); finalProcess = processRepository.save(ProcessFixture.approveType(dashboard)); applyForm = applyFormRepository.save(ApplyFormFixture.backend(dashboard)); - Question question1 = questionRepository.save(QuestionFixture.longAnswerType(applyForm)); + question1 = questionRepository.save(QuestionFixture.longAnswerType(applyForm)); Question question2 = questionRepository.save(QuestionFixture.shortAnswerType(applyForm)); answerCreateRequests = List.of( @@ -138,10 +145,12 @@ void submit_invalidSubmitDate() { // given ApplyForm pastApplyForm = applyFormRepository.save(new ApplyForm( "지난 모집 공고", "description", - LocalDateFixture.oneWeekAgo(), LocalDateFixture.oneDayAgo(), null)); + LocalDateFixture.oneWeekAgo(), LocalDateFixture.oneDayAgo(), null + )); ApplyForm futureApplyForm = applyFormRepository.save(new ApplyForm( "미래의 모집 공고", "description", - LocalDateFixture.oneDayLater(), LocalDateFixture.oneWeekLater(), null)); + LocalDateFixture.oneDayLater(), LocalDateFixture.oneWeekLater(), null + )); // when&then assertAll( @@ -187,4 +196,26 @@ void update() { () -> assertThat(actual.getEndDate()).isEqualTo(toChangeEndDate) ); } + + @DisplayName("지원서 폼 조회에 성공한다.") + @Test + void readApplyFormById() { + // given&when + ApplyFormResponse applyFormResponse = applyFormFacade.readApplyFormById(applyForm.getId()); + + // then + assertAll( + () -> assertThat(applyFormResponse.title()).isEqualTo(applyForm.getTitle()), + () -> assertThat(applyFormResponse.startDate()).isEqualTo(applyForm.getStartDate()), + () -> assertThat(applyFormResponse.endDate()).isEqualTo(applyForm.getEndDate()), + () -> { + QuestionResponse questionResponse = applyFormResponse.questionResponses().get(0); + assertThat(questionResponse.id()).isEqualTo(question1.getId()); + assertThat(questionResponse.content()).isEqualTo(question1.getContent()); + assertThat(questionResponse.orderIndex()).isEqualTo(question1.getSequence()); + assertThat(questionResponse.required()).isEqualTo(question1.isRequired()); + assertThat(questionResponse.choiceResponses().size()).isZero(); + } + ); + } } From abef4bc9f1e79e7b97b19801c28dcd284bd2c35b Mon Sep 17 00:00:00 2001 From: Do Yeop Kim <113661364+Dobby-Kim@users.noreply.github.com> Date: Wed, 25 Sep 2024 16:15:51 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=EC=A2=8B=EC=9D=80=20=EB=A7=90=EB=A1=9C=20?= =?UTF-8?q?=ED=95=A0=20=EB=95=8C=20Approve=20=ED=95=98=EC=84=B8=EC=9A=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/cruru/applyform/facade/ApplyFormFacadeTest.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/backend/src/test/java/com/cruru/applyform/facade/ApplyFormFacadeTest.java b/backend/src/test/java/com/cruru/applyform/facade/ApplyFormFacadeTest.java index ae9f9eef0..80bca4a48 100644 --- a/backend/src/test/java/com/cruru/applyform/facade/ApplyFormFacadeTest.java +++ b/backend/src/test/java/com/cruru/applyform/facade/ApplyFormFacadeTest.java @@ -59,9 +59,6 @@ class ApplyFormFacadeTest extends ServiceTest { @Autowired private ApplicantRepository applicantRepository; - @Autowired - private ChoiceRepository choiceRepository; - @Autowired private ApplyFormFacade applyFormFacade; @@ -214,7 +211,7 @@ void readApplyFormById() { assertThat(questionResponse.content()).isEqualTo(question1.getContent()); assertThat(questionResponse.orderIndex()).isEqualTo(question1.getSequence()); assertThat(questionResponse.required()).isEqualTo(question1.isRequired()); - assertThat(questionResponse.choiceResponses().size()).isZero(); + assertThat(questionResponse.choiceResponses()).isEmpty(); } ); }