Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test-be(ApplyFormFacadeTest): 누락 테스트 추가 #719

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -62,6 +65,7 @@ class ApplyFormFacadeTest extends ServiceTest {
private Process firstProcess;
private Process finalProcess;
private ApplyForm applyForm;
private Question question1;
private List<AnswerCreateRequest> answerCreateRequests;
private ApplyFormSubmitRequest applyFormSubmitrequest;
private ApplicantCreateRequest applicantCreateRequest;
Expand All @@ -72,7 +76,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(
Expand Down Expand Up @@ -138,10 +142,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(
Expand Down Expand Up @@ -187,4 +193,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()).isEmpty();
}
);
}
}