Skip to content

Commit

Permalink
test(#119): 접수증 발급 test 추가
Browse files Browse the repository at this point in the history
- FormControllerTest에 접수증 발급 테스트 코드를 작성했어요.
  • Loading branch information
jyj1289 committed Sep 6, 2024
1 parent 5ceb3db commit 3cc4d5c
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1443,6 +1443,77 @@ class FormControllerTest extends RestDocsTestSupport {
verify(generateAdmissionTicketUseCase, times(1)).execute(user);
}

@Test
void 접수증을_발급받는다() throws Exception {
User user = UserFixture.createUser();
MockMultipartFile file = new MockMultipartFile(
"proof-of-application",
"proof-of-application.pdf",
MediaType.APPLICATION_PDF_VALUE,
"<<file>>".getBytes()
);

given(authenticationArgumentResolver.supportsParameter(any(MethodParameter.class))).willReturn(true);
given(authenticationArgumentResolver.resolveArgument(any(), any(), any(), any())).willReturn(user);
given(generateAdmissionTicketUseCase.execute(user)).willReturn(new ByteArrayResource(file.getBytes()));

mockMvc.perform(get("/form/proof-of-application")
.header(HttpHeaders.AUTHORIZATION, AuthFixture.createAuthHeader())
.accept(MediaType.APPLICATION_PDF)
)

.andExpect(status().isOk())

.andDo(restDocs.document(
requestHeaders(
headerWithName(HttpHeaders.AUTHORIZATION)
.description("Bearer token")
)
));

verify(generateProofOfApplicationUseCase, times(1)).execute(user);
}

@Test
void 접수증를을발급받을__원서상태가_최종제출이_아니라면_에러가_발생한다() throws Exception {
User user = UserFixture.createUser();

given(authenticationArgumentResolver.supportsParameter(any(MethodParameter.class))).willReturn(true);
given(authenticationArgumentResolver.resolveArgument(any(), any(), any(), any())).willReturn(user);
willThrow(new InvalidFormStatusException()).given(generateProofOfApplicationUseCase).execute(user);

mockMvc.perform(get("/form/proof-of-application")
.header(HttpHeaders.AUTHORIZATION, AuthFixture.createAuthHeader())
.accept(MediaType.APPLICATION_JSON)
)

.andExpect(status().isConflict())

.andDo(restDocs.document());

verify(generateProofOfApplicationUseCase, times(1)).execute(user);
}

@Test
void 접수증을_발급받을__원서를_접수하지_않았다면_에러가_발생한다() throws Exception {
User user = UserFixture.createUser();

given(authenticationArgumentResolver.supportsParameter(any(MethodParameter.class))).willReturn(true);
given(authenticationArgumentResolver.resolveArgument(any(), any(), any(), any())).willReturn(user);
willThrow(new FormNotFoundException()).given(generateProofOfApplicationUseCase).execute(user);

mockMvc.perform(get("/form/proof-of-application")
.header(HttpHeaders.AUTHORIZATION, AuthFixture.createAuthHeader())
.accept(MediaType.APPLICATION_JSON)
)

.andExpect(status().isNotFound())

.andDo(restDocs.document());

verify(generateProofOfApplicationUseCase, times(1)).execute(user);
}

@Test
void 정상적으로_2_전형_점수_양식을_다운로드한다() throws Exception {
User user = UserFixture.createAdminUser();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ public abstract class ControllerTest {
@MockBean
protected GenerateAdmissionTicketUseCase generateAdmissionTicketUseCase;

@MockBean
protected GenerateProofOfApplicationUseCase generateProofOfApplicationUseCase;

@MockBean
protected DownloadSecondRoundScoreFormatUseCase downloadSecondRoundScoreFormatUseCase;

Expand Down

0 comments on commit 3cc4d5c

Please sign in to comment.