Skip to content

Commit

Permalink
Merge branch 'develop' into feat/#98
Browse files Browse the repository at this point in the history
  • Loading branch information
cabbage16 authored Aug 5, 2024
2 parents cc6f9b9 + 68e7ad9 commit 9f2088b
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/docs/asciidoc/form.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,8 @@ include::{snippets}/form-controller-test/정상적으로_2차_전형_점수를_
===== 파일 양식이 잘못된 경우
include::{snippets}/form-controller-test/잘못된_양식의_2차_전형_점수를_입력하면_에러가_발생한다/http-response.adoc[]

===== 입력한 점수가 범위를 초과한 경우
include::{snippets}/form-controller-test/입력한_2차_전형_점수가_범위를_초과한_경우_에러가_발생한다/http-response.adoc[]


=== 최종 합격자 명단 다운로드
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public Resource execute() throws IOException {

Cell showCell = row.createCell(6);
showCell.setCellStyle(cellStyle);
showCell.setCellFormula(String.format("IF(C%1$d=\"마이스터인재전형\", IF(OR(ISBLANK(D%1$d), ISBLANK(E%1$d), ISBLANK(F%1$d)), FALSE, TRUE), IF(OR(ISBLANK(D%1$d), ISBLANK(E%1$d)), FALSE, TRUE))", xlsxIndex));
showCell.setCellFormula(String.format("IF(C%1$d=\"마이스터인재전형\", IF(OR(D%1$d=\"불참\", E%1$d=\"불참\", F%1$d=\"불참\"), FALSE, TRUE), IF(OR(D%1$d=\"불참\", E%1$d=\"불참\"), FALSE, TRUE))", xlsxIndex));

}

return xlsxService.convertToByteArrayResource(workbook);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.bamdoliro.maru.domain.form.domain.type.FormStatus;
import com.bamdoliro.maru.domain.form.domain.type.FormType;
import com.bamdoliro.maru.domain.form.exception.InvalidFileException;
import com.bamdoliro.maru.domain.form.exception.WrongScoreException;
import com.bamdoliro.maru.infrastructure.persistence.form.FormRepository;
import com.bamdoliro.maru.shared.annotation.UseCase;
import lombok.AllArgsConstructor;
Expand Down Expand Up @@ -89,6 +90,20 @@ private void validateRow(Row row) {
)) {
throw new InvalidFileException();
}

if (isShow &&
((row.getCell(2).getStringCellValue().equals("마이스터인재전형") &&
((row.getCell(3).getNumericCellValue() > 120 || row.getCell(4).getNumericCellValue() > 40 || row.getCell(5).getNumericCellValue() > 80) ||
(row.getCell(3).getNumericCellValue() < 0 || row.getCell(4).getNumericCellValue() < 0 || row.getCell(5).getNumericCellValue() < 0))) ||
(row.getCell(2).getStringCellValue().equals("사회통합전형") &&
((row.getCell(3).getNumericCellValue() > 200 || row.getCell(4).getNumericCellValue() > 40) ||
(row.getCell(3).getNumericCellValue() < 0 || row.getCell(4).getNumericCellValue() < 0))) ||
(!row.getCell(2).getStringCellValue().equals("마이스터인재전형") &&
!row.getCell(2).getStringCellValue().equals("사회통합전형") &&
((row.getCell(3).getNumericCellValue() > 120 || row.getCell(4).getNumericCellValue() > 40) ||
(row.getCell(3).getNumericCellValue() < 0 || row.getCell(4).getNumericCellValue() < 0))))) {
throw new WrongScoreException();
}
}

private FormType.Category getFormType(String description) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.bamdoliro.maru.domain.form.exception;

import com.bamdoliro.maru.domain.form.exception.error.FormErrorProperty;
import com.bamdoliro.maru.shared.error.MaruException;

public class WrongScoreException extends MaruException {

public WrongScoreException() {
super(FormErrorProperty.WRONG_SCORE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public enum FormErrorProperty implements ErrorProperty {
INVALID_FORM_STATUS(HttpStatus.CONFLICT, "원서 상태가 유효하지 않습니다."),
INVALID_FILE(HttpStatus.BAD_REQUEST, "잘못된 파일입니다."),
MISSING_TOTAL_SCORE(HttpStatus.PRECONDITION_FAILED, "최종 점수가 입력되지 않은 원서가 존재합니다.")
WRONG_SCORE(HttpStatus.BAD_REQUEST, "점수 범위를 초과했습니다."),
;

private final HttpStatus status;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1631,6 +1631,32 @@ class FormControllerTest extends RestDocsTestSupport {
verify(updateSecondRoundScoreUseCase, times(1)).execute(any(MultipartFile.class));
}

@Test
void 입력한_2_전형_점수가_범위를_초과한_경우_에러가_발생한다() throws Exception {
User user = UserFixture.createAdminUser();
MockMultipartFile file = new MockMultipartFile(
"xlsx",
"2차전형점수양식.xlsx",
String.valueOf(MediaType.parseMediaType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")),
"<<file>>".getBytes()
);

given(authenticationArgumentResolver.supportsParameter(any(MethodParameter.class))).willReturn(true);
given(authenticationArgumentResolver.resolveArgument(any(), any(), any(), any())).willReturn(user);
doThrow(new WrongScoreException()).when(updateSecondRoundScoreUseCase).execute(any(MultipartFile.class));

mockMvc.perform(multipartPatch("/form/second-round/score")
.file(file)
.header(HttpHeaders.AUTHORIZATION, AuthFixture.createAuthHeader())
.contentType(MediaType.MULTIPART_FORM_DATA))

.andExpect(status().isBadRequest())

.andDo(restDocs.document());

verify(updateSecondRoundScoreUseCase, times(1)).execute(any(MultipartFile.class));
}

@Test
void 정상적으로_최종_합격자를_다운로드한다() throws Exception {
User user = UserFixture.createAdminUser();
Expand Down

0 comments on commit 9f2088b

Please sign in to comment.