diff --git a/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/application/service/CalculateMajorGraduationService.java b/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/application/service/CalculateMajorGraduationService.java index 9b22860f..8e64866f 100644 --- a/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/application/service/CalculateMajorGraduationService.java +++ b/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/application/service/CalculateMajorGraduationService.java @@ -45,111 +45,142 @@ public boolean supports(GraduationCategory graduationCategory) { } @Override - public DetailGraduationResult calculateSingleDetailGraduation(User user, + public DetailGraduationResult calculateSingleDetailGraduation( + User user, GraduationCategory graduationCategory, - TakenLectureInventory takenLectureInventory, GraduationRequirement graduationRequirement) { + TakenLectureInventory takenLectureInventory, GraduationRequirement graduationRequirement + ) { MajorType majorType = MajorType.from(graduationCategory); if (majorType == MajorType.SUB) { return generateSubMajorDetailGraduationResult(user, takenLectureInventory, - graduationRequirement); + graduationRequirement + ); } DetailGraduationResult majorDetailGraduationResult = generateMajorDetailGraduationResult( user, - majorType, takenLectureInventory, graduationRequirement); + majorType, takenLectureInventory, graduationRequirement + ); - boolean isMandatory = graduationCategory.checkMandatoryIfSeperatedByMandatoryAndElective(); + boolean isMandatory = graduationCategory.checkMandatoryIfSeparatedByMandatoryAndElective(); if (isMandatory) { DetailCategoryResult majorDetailCategoryResult = separateMandatoryMajor( graduationCategory, - majorDetailGraduationResult); + majorDetailGraduationResult + ); return DetailGraduationResult.create(graduationCategory, - majorDetailCategoryResult.getTotalCredits(), List.of(majorDetailCategoryResult)); + majorDetailCategoryResult.getTotalCredits(), List.of(majorDetailCategoryResult) + ); } - DetailCategoryResult majorDetailCategoryResult = separateElectiveMajor(graduationCategory, - majorDetailGraduationResult); + DetailCategoryResult majorDetailCategoryResult = separateElectiveMajor( + graduationCategory, + majorDetailGraduationResult + ); return DetailGraduationResult.create(graduationCategory, - majorDetailCategoryResult.getTotalCredits(), List.of(majorDetailCategoryResult)); + majorDetailCategoryResult.getTotalCredits(), List.of(majorDetailCategoryResult) + ); } - public List calculateAllDetailGraduation(User user, - TakenLectureInventory takenLectureInventory, GraduationRequirement graduationRequirement) { + public List calculateAllDetailGraduation( + User user, + TakenLectureInventory takenLectureInventory, GraduationRequirement graduationRequirement + ) { DetailGraduationResult primaryMajorDetailGraduationResult = generateMajorDetailGraduationResult( user, - MajorType.PRIMARY, takenLectureInventory, graduationRequirement); + MajorType.PRIMARY, takenLectureInventory, graduationRequirement + ); DetailGraduationResult primaryMandatoryMajorDetailGraduationResult = isolateMandatoryMajorDetailGraduation( PRIMARY_MANDATORY_MAJOR, primaryMajorDetailGraduationResult); DetailGraduationResult primaryElectiveMajorDetailGraduationResult = isolateElectiveMajorDetailGraduation( PRIMARY_ELECTIVE_MAJOR, primaryMajorDetailGraduationResult); List majorGraduationResults = new ArrayList<>( - List.of(primaryMandatoryMajorDetailGraduationResult, - primaryElectiveMajorDetailGraduationResult)); + List.of( + primaryMandatoryMajorDetailGraduationResult, + primaryElectiveMajorDetailGraduationResult + )); if (user.getStudentCategory() == StudentCategory.DUAL_MAJOR) { DetailGraduationResult dualMajorDetailGraduationResult = generateMajorDetailGraduationResult( user, - MajorType.DUAL, takenLectureInventory, graduationRequirement); + MajorType.DUAL, takenLectureInventory, graduationRequirement + ); DetailGraduationResult dualMandatoryMajorDetailGraduationResult = isolateMandatoryMajorDetailGraduation( DUAL_MANDATORY_MAJOR, dualMajorDetailGraduationResult); DetailGraduationResult dualElectiveMajorDetailGraduationResult = isolateElectiveMajorDetailGraduation( DUAL_ELECTIVE_MAJOR, dualMajorDetailGraduationResult); majorGraduationResults.addAll( - List.of(dualMandatoryMajorDetailGraduationResult, - dualElectiveMajorDetailGraduationResult)); + List.of( + dualMandatoryMajorDetailGraduationResult, + dualElectiveMajorDetailGraduationResult + )); } if (user.getStudentCategory() == StudentCategory.SUB_MAJOR) { majorGraduationResults.add( generateSubMajorDetailGraduationResult(user, takenLectureInventory, - graduationRequirement)); + graduationRequirement + )); } return majorGraduationResults; } - private DetailGraduationResult generateMajorDetailGraduationResult(User user, + private DetailGraduationResult generateMajorDetailGraduationResult( + User user, MajorType majorType, TakenLectureInventory takenLectureInventory, - GraduationRequirement graduationRequirement) { + GraduationRequirement graduationRequirement + ) { Set graduationMajorLectures = findMajorPort.findMajor( user.getMajorByMajorType(majorType)); return majorGraduationManager.createDetailGraduationResult(user, majorType, takenLectureInventory, graduationMajorLectures, - graduationRequirement.getMajorCreditByMajorType(majorType)); + graduationRequirement.getMajorCreditByMajorType(majorType) + ); } - private DetailGraduationResult generateSubMajorDetailGraduationResult(User user, + private DetailGraduationResult generateSubMajorDetailGraduationResult( + User user, TakenLectureInventory takenLectureInventory, - GraduationRequirement graduationRequirement) { + GraduationRequirement graduationRequirement + ) { Set graduationSubMajorLectures = findMajorPort.findMajor(user.getSubMajor()); return subMajorGraduationManager.createDetailGraduationResult(user, takenLectureInventory, graduationSubMajorLectures, - graduationRequirement.getSubMajorCredit()); + graduationRequirement.getSubMajorCredit() + ); } private DetailGraduationResult isolateMandatoryMajorDetailGraduation( - GraduationCategory graduationCategory, DetailGraduationResult majorDetailGraduationResult) { + GraduationCategory graduationCategory, DetailGraduationResult majorDetailGraduationResult + ) { DetailCategoryResult mandatoryMajorDetailCategoryResult = separateMandatoryMajor( graduationCategory, majorDetailGraduationResult); - return DetailGraduationResult.create(graduationCategory, + return DetailGraduationResult.create( + graduationCategory, mandatoryMajorDetailCategoryResult.getTotalCredits(), - List.of(mandatoryMajorDetailCategoryResult)); + List.of(mandatoryMajorDetailCategoryResult) + ); } private DetailGraduationResult isolateElectiveMajorDetailGraduation( - GraduationCategory graduationCategory, DetailGraduationResult majorDetailGraduationResult) { + GraduationCategory graduationCategory, DetailGraduationResult majorDetailGraduationResult + ) { DetailCategoryResult electiveMajorDetailCategoryResult = separateElectiveMajor( graduationCategory, majorDetailGraduationResult); - return DetailGraduationResult.create(graduationCategory, + return DetailGraduationResult.create( + graduationCategory, electiveMajorDetailCategoryResult.getTotalCredits(), - List.of(electiveMajorDetailCategoryResult)); + List.of(electiveMajorDetailCategoryResult) + ); } private DetailCategoryResult separateMandatoryMajor( - GraduationCategory graduationCategory, DetailGraduationResult majorDetailGraduationResult) { + GraduationCategory graduationCategory, DetailGraduationResult majorDetailGraduationResult + ) { DetailCategoryResult mandatoryMajorDetailCategoryResult = majorDetailGraduationResult.getDetailCategory() .stream() .filter(detailCategoryResult -> detailCategoryResult.getDetailCategoryName() @@ -161,7 +192,8 @@ private DetailCategoryResult separateMandatoryMajor( } private DetailCategoryResult separateElectiveMajor( - GraduationCategory graduationCategory, DetailGraduationResult majorDetailGraduationResult) { + GraduationCategory graduationCategory, DetailGraduationResult majorDetailGraduationResult + ) { DetailCategoryResult electiveMajorDetailCategoryResult = majorDetailGraduationResult.getDetailCategory() .stream() .filter(detailCategoryResult -> detailCategoryResult.getDetailCategoryName() diff --git a/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/model/GraduationCategory.java b/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/model/GraduationCategory.java index 26010558..80c63e20 100644 --- a/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/model/GraduationCategory.java +++ b/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/model/GraduationCategory.java @@ -32,7 +32,7 @@ public static GraduationCategory of(String name) { .orElseThrow(() -> new IllegalArgumentException("해당 카테고리를 찾을 수 없습니다.")); } - public boolean checkMandatoryIfSeperatedByMandatoryAndElective() { + public boolean checkMandatoryIfSeparatedByMandatoryAndElective() { return this == PRIMARY_MANDATORY_MAJOR || this == DUAL_MANDATORY_MAJOR; } } diff --git a/src/main/java/com/plzgraduate/myongjigraduatebe/parsing/application/service/ParsingTextService.java b/src/main/java/com/plzgraduate/myongjigraduatebe/parsing/application/service/ParsingTextService.java index 52ef96f7..62038ba7 100644 --- a/src/main/java/com/plzgraduate/myongjigraduatebe/parsing/application/service/ParsingTextService.java +++ b/src/main/java/com/plzgraduate/myongjigraduatebe/parsing/application/service/ParsingTextService.java @@ -35,7 +35,6 @@ class ParsingTextService implements ParsingTextUseCase { private final UpdateStudentInformationUseCase updateStudentInformationUseCase; private final SaveTakenLectureFromParsingTextUseCase saveTakenLectureFromParsingTextUseCase; private final DeleteTakenLectureUseCase deleteTakenLectureByUserUseCase; - private final GenerateOrModifyCompletedCreditUseCase generateOrModifyCompletedCreditUseCase; @Override @@ -63,20 +62,19 @@ private void deleteTakenLecturesIfAlreadyEnrolled(User user) { private void saveTakenLectures(User user, ParsingInformation parsingInformation) { List parsingTakenLectureDtoList = parsingInformation.getTakenLectureInformation(); - List saveTakenLectureCommand = getSaveTakenLectureCommand( - parsingTakenLectureDtoList); + List saveTakenLectureCommand = + getSaveTakenLectureCommand(parsingTakenLectureDtoList); saveTakenLectureFromParsingTextUseCase.saveTakenLectures(user, saveTakenLectureCommand); } private User updateUser(User user, ParsingInformation parsingInformation) { - UpdateStudentInformationCommand updateStudentInfoCommand = UpdateStudentInformationCommand.of( - user, parsingInformation); + UpdateStudentInformationCommand updateStudentInfoCommand = + UpdateStudentInformationCommand.of(user, parsingInformation); return updateStudentInformationUseCase.updateUser(updateStudentInfoCommand); } private void validateParsingText(String parsingText) { - if (parsingText.trim() - .isEmpty()) { + if (parsingText.trim().isEmpty()) { throw new InvalidPdfException("PDF를 인식하지 못했습니다. 채널톡으로 문의 바랍니다."); } } @@ -88,13 +86,15 @@ private void validateStudentNumber(User user, ParsingInformation parsingInformat } private List getSaveTakenLectureCommand( - List parsingTakenLectureDtoList) { + List parsingTakenLectureDtoList + ) { return parsingTakenLectureDtoList.stream() .map(parsingTakenLectureDto -> TakenLectureInformation.createTakenLectureInformation( parsingTakenLectureDto.getLectureCode(), parsingTakenLectureDto.getYear(), - parsingTakenLectureDto.getSemester()) + parsingTakenLectureDto.getSemester() + ) ) .collect(Collectors.toList()); } @@ -105,5 +105,4 @@ private void checkUnSupportedUser(ParsingInformation parsingInformation) { throw new IllegalArgumentException(ErrorCode.UNSUPPORTED_STUDENT_CATEGORY.toString()); } } - } diff --git a/src/main/java/com/plzgraduate/myongjigraduatebe/parsing/domain/ParsingInformation.java b/src/main/java/com/plzgraduate/myongjigraduatebe/parsing/domain/ParsingInformation.java index 101217bb..8f825f52 100644 --- a/src/main/java/com/plzgraduate/myongjigraduatebe/parsing/domain/ParsingInformation.java +++ b/src/main/java/com/plzgraduate/myongjigraduatebe/parsing/domain/ParsingInformation.java @@ -2,9 +2,12 @@ import com.plzgraduate.myongjigraduatebe.takenlecture.domain.model.Semester; import com.plzgraduate.myongjigraduatebe.user.domain.model.StudentCategory; +import com.plzgraduate.myongjigraduatebe.user.domain.model.TransferCredit; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.regex.Pattern; +import java.util.stream.Collectors; import lombok.Builder; import lombok.Getter; @@ -19,13 +22,22 @@ public class ParsingInformation { private final String dualMajor; private final String associatedMajor; private final StudentCategory studentCategory; + private final TransferCredit transferCredit; private final List takenLectureInformation; @Builder - public ParsingInformation(String studentName, String studentNumber, String major, - String changeMajor, String subMajor, String dualMajor, - String associatedMajor, StudentCategory studentCategory, - List takenLectureInformation) { + public ParsingInformation( + String studentName, + String studentNumber, + String major, + String changeMajor, + String subMajor, + String dualMajor, + String associatedMajor, + StudentCategory studentCategory, + TransferCredit transferCredit, + List takenLectureInformation + ) { this.studentName = studentName; this.studentNumber = studentNumber; this.major = major; @@ -34,6 +46,7 @@ public ParsingInformation(String studentName, String studentNumber, String major this.subMajor = subMajor; this.associatedMajor = associatedMajor; this.studentCategory = studentCategory; + this.transferCredit = transferCredit; this.takenLectureInformation = takenLectureInformation; } @@ -49,6 +62,7 @@ public static ParsingInformation parsing(String parsingText) { .subMajor(parsingStudentCategoryDto.getSubMajor()) .associatedMajor(parsingStudentCategoryDto.getAssociatedMajor()) .studentCategory(parsingStudentCategoryDto.getStudentCategory()) + .transferCredit(parsingStudentCategoryDto.getTransferCredit()) .takenLectureInformation(parseTakenLectureInformation(splitText)) .build(); } @@ -80,11 +94,14 @@ private static ParsingStudentCategoryDto parseStudentCategory(String[] splitText String subMajor = null; String associatedMajor = null; StudentCategory studentCategory; + TransferCredit transferCredit; String secondLineText = splitText[2]; String thirdLineText = splitText[3]; + String fourthLineText = splitText[4]; List categories = new ArrayList<>(); String[] parts = secondLineText.split(", "); String[] thirdLineParts = thirdLineText.split(", "); + if (thirdLineParts.length == 4) { String part = thirdLineParts[3]; if (part.startsWith("전과내역 -")) { @@ -105,16 +122,25 @@ private static ParsingStudentCategoryDto parseStudentCategory(String[] splitText associatedMajor = part.substring("연계전공 - ".length()); } } + studentCategory = StudentCategory.from(categories); - return ParsingStudentCategoryDto.of(changeMajor, subMajor, dualMajor, associatedMajor, - studentCategory); + + String fourthLine = fourthLineText.substring("편입생 인정학점 - ".length()); + transferCredit = TransferCredit.from(Arrays.stream(fourthLine.split(",")) + .map(s -> s.replaceAll("[^0-9]", "")) + .collect(Collectors.joining("/"))); + + return ParsingStudentCategoryDto.of( + changeMajor, subMajor, dualMajor, associatedMajor, studentCategory, transferCredit + ); } private static List parseTakenLectureInformation(String[] splitText) { List takenLectureInformation = new ArrayList<>(); for (int i = 16; i < splitText.length; i += 7) { - if (i + 3 < splitText.length && !Pattern.matches("^[A-Z]+$", - splitText[i + 3].substring(0, 1))) { + if (i + 3 < splitText.length && !Pattern.matches( + "^[A-Z]+$", splitText[i + 3].substring(0, 1) + )) { return takenLectureInformation; } int year = Integer.parseInt(splitText[i + 1].split(" ")[0].substring(0, 4)); diff --git a/src/main/java/com/plzgraduate/myongjigraduatebe/parsing/domain/ParsingStudentCategoryDto.java b/src/main/java/com/plzgraduate/myongjigraduatebe/parsing/domain/ParsingStudentCategoryDto.java index cf0dd16e..ec8d60a9 100644 --- a/src/main/java/com/plzgraduate/myongjigraduatebe/parsing/domain/ParsingStudentCategoryDto.java +++ b/src/main/java/com/plzgraduate/myongjigraduatebe/parsing/domain/ParsingStudentCategoryDto.java @@ -1,6 +1,7 @@ package com.plzgraduate.myongjigraduatebe.parsing.domain; import com.plzgraduate.myongjigraduatebe.user.domain.model.StudentCategory; +import com.plzgraduate.myongjigraduatebe.user.domain.model.TransferCredit; import lombok.Builder; import lombok.Getter; @@ -12,27 +13,40 @@ class ParsingStudentCategoryDto { private final String subMajor; private final String associatedMajor; private final StudentCategory studentCategory; + private final TransferCredit transferCredit; @Builder - private ParsingStudentCategoryDto(String changeMajor, String dualMajor, String subMajor, + private ParsingStudentCategoryDto( + String changeMajor, + String dualMajor, + String subMajor, String associatedMajor, - StudentCategory studentCategory) { + StudentCategory studentCategory, + TransferCredit transferCredit + ) { this.changeMajor = changeMajor; this.dualMajor = dualMajor; this.subMajor = subMajor; this.associatedMajor = associatedMajor; this.studentCategory = studentCategory; + this.transferCredit = transferCredit; } - public static ParsingStudentCategoryDto of(String changeMajor, String subMajor, + public static ParsingStudentCategoryDto of( + String changeMajor, + String subMajor, String dualMajor, - String associatedMajor, StudentCategory studentCategory) { + String associatedMajor, + StudentCategory studentCategory, + TransferCredit transferCredit + ) { return ParsingStudentCategoryDto.builder() .changeMajor(changeMajor) .dualMajor(dualMajor) .subMajor(subMajor) .associatedMajor(associatedMajor) .studentCategory(studentCategory) + .transferCredit(transferCredit) .build(); } } diff --git a/src/main/java/com/plzgraduate/myongjigraduatebe/user/application/service/signup/SignUpService.java b/src/main/java/com/plzgraduate/myongjigraduatebe/user/application/service/signup/SignUpService.java index 4953ec8c..7d7aa581 100644 --- a/src/main/java/com/plzgraduate/myongjigraduatebe/user/application/service/signup/SignUpService.java +++ b/src/main/java/com/plzgraduate/myongjigraduatebe/user/application/service/signup/SignUpService.java @@ -29,9 +29,12 @@ class SignUpService implements SignUpUseCase { public void signUp(SignUpCommand signUpCommand) { checkDuplicateUser(signUpCommand); String encodedPassword = passwordEncoder.encode(signUpCommand.getPassword()); - User newUser = User.create(signUpCommand.getAuthId(), encodedPassword, + User newUser = User.create( + signUpCommand.getAuthId(), + encodedPassword, signUpCommand.getEngLv(), - signUpCommand.getStudentNumber()); + signUpCommand.getStudentNumber() + ); checkStudentNumberOver16(newUser); saveUserPort.saveUser(newUser); } diff --git a/src/main/java/com/plzgraduate/myongjigraduatebe/user/domain/model/College.java b/src/main/java/com/plzgraduate/myongjigraduatebe/user/domain/model/College.java index 40430cfd..b134cd80 100644 --- a/src/main/java/com/plzgraduate/myongjigraduatebe/user/domain/model/College.java +++ b/src/main/java/com/plzgraduate/myongjigraduatebe/user/domain/model/College.java @@ -9,23 +9,41 @@ @RequiredArgsConstructor public enum College { - HUMANITIES("인문대", - List.of("국어국문학과", "문예창작학과", "영어영문학과", "중어중문학과", "일어일문학과", "문헌정보학과", "미술사학과", "아랍지역학과", - "사학과", "철학과")), - SOCIAL_SCIENCE("사회과학대", List.of("행정학과", "경제학과", "정치외교학과", "디지털미디어학과", "아동학과", "청소년지도학과")), - BUSINESS("경영대", List.of("경영학과", "경영정보학과", "국제통상학과")), - LAW("법대", List.of("법학과")), - ICT("ICT융합대", List.of("디지털콘텐츠디자인학과", "응용소프트웨어전공", "데이터테크놀로지전공")); + HUMANITIES( + "인문대", + List.of( + "국어국문학과", + "문예창작학과", + "영어영문학과", + "중어중문학과", + "일어일문학과", + "문헌정보학과", + "미술사학과", + "아랍지역학과", + "사학과", + "철학과" + ) + ), + SOCIAL_SCIENCE( + "사회과학대", List.of("행정학과", "경제학과", "정치외교학과", "디지털미디어학과", "아동학과", "청소년지도학과") + ), + BUSINESS( + "경영대", List.of("경영학과", "경영정보학과", "국제통상학과") + ), + LAW( + "법대", List.of("법학과") + ), + ICT( + "ICT융합대", List.of("디지털콘텐츠디자인학과", "응용소프트웨어전공", "데이터테크놀로지전공") + ); private final String name; private final List holdingMajors; public static College findBelongingCollege(String major) { return Arrays.stream(College.values()) - .filter(college -> college.getHoldingMajors() - .contains(major)) + .filter(college -> college.getHoldingMajors().contains(major)) .findFirst() .orElseThrow(() -> new IllegalArgumentException("소속 단과대가 존재하지 않습니다.")); } - } diff --git a/src/main/java/com/plzgraduate/myongjigraduatebe/user/domain/model/StudentCategory.java b/src/main/java/com/plzgraduate/myongjigraduatebe/user/domain/model/StudentCategory.java index a11fe513..382ba296 100644 --- a/src/main/java/com/plzgraduate/myongjigraduatebe/user/domain/model/StudentCategory.java +++ b/src/main/java/com/plzgraduate/myongjigraduatebe/user/domain/model/StudentCategory.java @@ -24,35 +24,93 @@ @Getter @RequiredArgsConstructor public enum StudentCategory { - NORMAL(List.of(), - List.of(COMMON_CULTURE, CORE_CULTURE, PRIMARY_BASIC_ACADEMICAL_CULTURE, + NORMAL( + List.of(), + List.of( + COMMON_CULTURE, + CORE_CULTURE, + PRIMARY_BASIC_ACADEMICAL_CULTURE, PRIMARY_MANDATORY_MAJOR, - PRIMARY_ELECTIVE_MAJOR, NORMAL_CULTURE, FREE_ELECTIVE, CHAPEL)), - CHANGE_MAJOR(List.of("전과"), - List.of(COMMON_CULTURE, CORE_CULTURE, PRIMARY_BASIC_ACADEMICAL_CULTURE, + PRIMARY_ELECTIVE_MAJOR, + NORMAL_CULTURE, + FREE_ELECTIVE, + CHAPEL + ) + ), CHANGE_MAJOR( + List.of("전과"), + List.of( + COMMON_CULTURE, + CORE_CULTURE, + PRIMARY_BASIC_ACADEMICAL_CULTURE, PRIMARY_MANDATORY_MAJOR, - PRIMARY_ELECTIVE_MAJOR, NORMAL_CULTURE, FREE_ELECTIVE, CHAPEL)), - SUB_MAJOR(List.of("부전공"), - List.of(COMMON_CULTURE, CORE_CULTURE, PRIMARY_BASIC_ACADEMICAL_CULTURE, + PRIMARY_ELECTIVE_MAJOR, + NORMAL_CULTURE, + FREE_ELECTIVE, + CHAPEL + ) + ), SUB_MAJOR( + List.of("부전공"), + List.of( + COMMON_CULTURE, + CORE_CULTURE, + PRIMARY_BASIC_ACADEMICAL_CULTURE, PRIMARY_MANDATORY_MAJOR, - PRIMARY_ELECTIVE_MAJOR, GraduationCategory.SUB_MAJOR, NORMAL_CULTURE, FREE_ELECTIVE, - CHAPEL)), - DUAL_MAJOR(List.of("복수전공"), - List.of(COMMON_CULTURE, CORE_CULTURE, PRIMARY_BASIC_ACADEMICAL_CULTURE, + PRIMARY_ELECTIVE_MAJOR, + GraduationCategory.SUB_MAJOR, + NORMAL_CULTURE, + FREE_ELECTIVE, + CHAPEL + ) + ), DUAL_MAJOR( + List.of("복수전공"), + List.of( + COMMON_CULTURE, + CORE_CULTURE, + PRIMARY_BASIC_ACADEMICAL_CULTURE, DUAL_BASIC_ACADEMICAL_CULTURE, - PRIMARY_MANDATORY_MAJOR, PRIMARY_ELECTIVE_MAJOR, DUAL_MANDATORY_MAJOR, - DUAL_ELECTIVE_MAJOR, NORMAL_CULTURE, - FREE_ELECTIVE, CHAPEL)), - ASSOCIATED_MAJOR(List.of("연계전공"), - // 현재 미지원 - List.of(COMMON_CULTURE, CORE_CULTURE, PRIMARY_BASIC_ACADEMICAL_CULTURE, PRIMARY_MANDATORY_MAJOR, - PRIMARY_ELECTIVE_MAJOR, NORMAL_CULTURE, FREE_ELECTIVE, CHAPEL)), - DOUBLE_SUB(List.of("복수전공", "부전공"), - // 현재 미지원 - List.of(COMMON_CULTURE, CORE_CULTURE, PRIMARY_BASIC_ACADEMICAL_CULTURE, + PRIMARY_ELECTIVE_MAJOR, + DUAL_MANDATORY_MAJOR, + DUAL_ELECTIVE_MAJOR, + NORMAL_CULTURE, + FREE_ELECTIVE, + CHAPEL + ) + ), ASSOCIATED_MAJOR( + List.of("연계전공"), // 현재 미지원 + List.of( + COMMON_CULTURE, + CORE_CULTURE, + PRIMARY_BASIC_ACADEMICAL_CULTURE, PRIMARY_MANDATORY_MAJOR, - PRIMARY_ELECTIVE_MAJOR, NORMAL_CULTURE, FREE_ELECTIVE, CHAPEL)); + PRIMARY_ELECTIVE_MAJOR, + NORMAL_CULTURE, + FREE_ELECTIVE, + CHAPEL + ) + ), DOUBLE_SUB( + List.of("복수전공", "부전공"), // 현재 미지원 + List.of( + COMMON_CULTURE, + CORE_CULTURE, + PRIMARY_BASIC_ACADEMICAL_CULTURE, + PRIMARY_MANDATORY_MAJOR, + PRIMARY_ELECTIVE_MAJOR, + NORMAL_CULTURE, + FREE_ELECTIVE, + CHAPEL + ) + ), TRANSFER( + List.of("편입"), + List.of( + COMMON_CULTURE, + PRIMARY_MANDATORY_MAJOR, + PRIMARY_ELECTIVE_MAJOR, + NORMAL_CULTURE, + FREE_ELECTIVE, + CHAPEL + ) + ); private final List categories; private final List includedGraduationCategories; @@ -60,8 +118,7 @@ public enum StudentCategory { public static StudentCategory from(List categories) { return Arrays.stream(StudentCategory.values()) .filter(studentCategory -> Objects.equals(studentCategory.getCategories(), categories)) - .findFirst() - .orElseThrow(() -> new PdfParsingException("PDF 정보 추출에 실패했습니다.")); + .findFirst().orElseThrow(() -> new PdfParsingException("PDF 정보 추출에 실패했습니다.")); } public void validateGraduationCategoryInclusion(GraduationCategory graduationCategory) { @@ -69,5 +126,4 @@ public void validateGraduationCategoryInclusion(GraduationCategory graduationCat throw new IllegalArgumentException(ErrorCode.UNFITTED_GRADUATION_CATEGORY.toString()); } } - } diff --git a/src/main/java/com/plzgraduate/myongjigraduatebe/user/domain/model/TransferCredit.java b/src/main/java/com/plzgraduate/myongjigraduatebe/user/domain/model/TransferCredit.java new file mode 100644 index 00000000..940fc0be --- /dev/null +++ b/src/main/java/com/plzgraduate/myongjigraduatebe/user/domain/model/TransferCredit.java @@ -0,0 +1,65 @@ +package com.plzgraduate.myongjigraduatebe.user.domain.model; + +import java.util.Objects; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +@AllArgsConstructor +public class TransferCredit { + + private int normalCulture; + private int majorLecture; + private int freeElective; + private int christianLecture; + + public static TransferCredit empty() { + return new TransferCredit(0, 0, 0, 0); + } + + public static TransferCredit from(String input) { + if (isValid(input)) { + String[] parts = input.split("/"); + int normalCulture = Integer.parseInt(parts[0]); + int majorLecture = Integer.parseInt(parts[1]); + int freeElective = Integer.parseInt(parts[2]); + int christianLecture = Integer.parseInt(parts[3]); + + return new TransferCredit(normalCulture, majorLecture, freeElective, christianLecture); + } else { + throw new IllegalArgumentException("잘못된 형식입니다."); + } + } + + private static boolean isValid(String input) { + return input.matches("^\\d+/\\d+/\\d+/\\d+$"); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TransferCredit that = (TransferCredit) o; + return normalCulture == that.normalCulture && majorLecture == that.majorLecture + && freeElective == that.freeElective && christianLecture == that.christianLecture; + } + + @Override + public int hashCode() { + return Objects.hash(normalCulture, majorLecture, freeElective, christianLecture); + } + + @Override + public String toString() { + return normalCulture + "/" + + majorLecture + "/" + + freeElective + "/" + + christianLecture; + } +} diff --git a/src/main/java/com/plzgraduate/myongjigraduatebe/user/domain/model/User.java b/src/main/java/com/plzgraduate/myongjigraduatebe/user/domain/model/User.java index b2804fcd..75a1b8e2 100644 --- a/src/main/java/com/plzgraduate/myongjigraduatebe/user/domain/model/User.java +++ b/src/main/java/com/plzgraduate/myongjigraduatebe/user/domain/model/User.java @@ -20,6 +20,7 @@ public class User { private final int entryYear; private final Instant createdAt; private final Instant updatedAt; + private final TransferCredit transferCredit; private String password; private String name; private String primaryMajor; @@ -31,12 +32,25 @@ public class User { private boolean graduated; @Builder - private User(Long id, String authId, String password, EnglishLevel englishLevel, String name, + private User( + Long id, + String authId, + String password, + EnglishLevel englishLevel, + String name, String studentNumber, - int entryYear, String primaryMajor, String subMajor, String dualMajor, + int entryYear, + String primaryMajor, + String subMajor, + String dualMajor, StudentCategory studentCategory, - int totalCredit, double takenCredit, boolean graduated, Instant createdAt, - Instant updatedAt) { + TransferCredit transferCredit, + int totalCredit, + double takenCredit, + boolean graduated, + Instant createdAt, + Instant updatedAt + ) { this.id = id; this.authId = authId; this.password = password; @@ -48,6 +62,7 @@ private User(Long id, String authId, String password, EnglishLevel englishLevel, this.subMajor = subMajor; this.dualMajor = dualMajor; this.studentCategory = studentCategory; + this.transferCredit = transferCredit != null ? transferCredit : TransferCredit.empty(); this.totalCredit = totalCredit; this.takenCredit = takenCredit; this.graduated = graduated; @@ -55,8 +70,9 @@ private User(Long id, String authId, String password, EnglishLevel englishLevel, this.updatedAt = updatedAt; } - public static User create(String authId, String password, EnglishLevel englishLevel, - String studentNumber) { + public static User create( + String authId, String password, EnglishLevel englishLevel, String studentNumber + ) { return User.builder() .authId(authId) .password(password) @@ -73,9 +89,16 @@ private static int parseEntryYearInStudentNumber(String studentNumber) { return Integer.parseInt(studentNumber.substring(2, 4)); } - public void updateStudentInformation(String name, String major, String dualMajor, + public void updateStudentInformation( + String name, + String major, + String dualMajor, String subMajor, - StudentCategory studentCategory, int totalCredit, double takenCredit, boolean graduate) { + StudentCategory studentCategory, + int totalCredit, + double takenCredit, + boolean graduate + ) { this.name = name; this.primaryMajor = major; this.dualMajor = dualMajor; @@ -132,8 +155,8 @@ public boolean equals(Object o) { return false; } User user = (User) o; - return Objects.equals(authId, user.authId) && Objects.equals(studentNumber, - user.studentNumber); + return Objects.equals(authId, user.authId) + && Objects.equals(studentNumber, user.studentNumber); } @Override diff --git a/src/main/java/com/plzgraduate/myongjigraduatebe/user/infrastructure/adapter/persistence/entity/UserJpaEntity.java b/src/main/java/com/plzgraduate/myongjigraduatebe/user/infrastructure/adapter/persistence/entity/UserJpaEntity.java index 36953356..5c8c9b31 100644 --- a/src/main/java/com/plzgraduate/myongjigraduatebe/user/infrastructure/adapter/persistence/entity/UserJpaEntity.java +++ b/src/main/java/com/plzgraduate/myongjigraduatebe/user/infrastructure/adapter/persistence/entity/UserJpaEntity.java @@ -58,4 +58,5 @@ public class UserJpaEntity extends TimeBaseEntity { @Enumerated(value = EnumType.STRING) private StudentCategory studentCategory; + private String transferCredit; } diff --git a/src/main/java/com/plzgraduate/myongjigraduatebe/user/infrastructure/adapter/persistence/mapper/UserMapper.java b/src/main/java/com/plzgraduate/myongjigraduatebe/user/infrastructure/adapter/persistence/mapper/UserMapper.java index 42cdd1cd..f2baddfc 100644 --- a/src/main/java/com/plzgraduate/myongjigraduatebe/user/infrastructure/adapter/persistence/mapper/UserMapper.java +++ b/src/main/java/com/plzgraduate/myongjigraduatebe/user/infrastructure/adapter/persistence/mapper/UserMapper.java @@ -1,5 +1,6 @@ package com.plzgraduate.myongjigraduatebe.user.infrastructure.adapter.persistence.mapper; +import com.plzgraduate.myongjigraduatebe.user.domain.model.TransferCredit; import com.plzgraduate.myongjigraduatebe.user.domain.model.User; import com.plzgraduate.myongjigraduatebe.user.infrastructure.adapter.persistence.entity.UserJpaEntity; import org.springframework.stereotype.Component; @@ -20,6 +21,7 @@ public User mapToDomainEntity(UserJpaEntity user) { .dualMajor(user.getDualMajor()) .subMajor(user.getSubMajor()) .studentCategory(user.getStudentCategory()) + .transferCredit(TransferCredit.from(user.getTransferCredit())) .totalCredit(user.getTotalCredit()) .takenCredit(user.getTakenCredit()) .graduated(user.isGraduated()) @@ -29,7 +31,6 @@ public User mapToDomainEntity(UserJpaEntity user) { } public UserJpaEntity mapToJpaEntity(User user) { - return UserJpaEntity.builder() .id(user.getId()) .authId(user.getAuthId()) @@ -42,6 +43,7 @@ public UserJpaEntity mapToJpaEntity(User user) { .dualMajor(user.getDualMajor()) .subMajor(user.getSubMajor()) .studentCategory(user.getStudentCategory()) + .transferCredit(user.getTransferCredit().toString()) .totalCredit(user.getTotalCredit()) .takenCredit(user.getTakenCredit()) .graduated(user.isGraduated()) @@ -49,5 +51,4 @@ public UserJpaEntity mapToJpaEntity(User user) { .updatedAt(user.getUpdatedAt()) .build(); } - } diff --git a/src/test/java/com/plzgraduate/myongjigraduatebe/graduation/domain/model/GraduationCategoryTest.java b/src/test/java/com/plzgraduate/myongjigraduatebe/graduation/domain/model/GraduationCategoryTest.java index fc1f5d42..6f2b899f 100644 --- a/src/test/java/com/plzgraduate/myongjigraduatebe/graduation/domain/model/GraduationCategoryTest.java +++ b/src/test/java/com/plzgraduate/myongjigraduatebe/graduation/domain/model/GraduationCategoryTest.java @@ -14,7 +14,7 @@ class GraduationCategoryTest { @ParameterizedTest void checkMandatoryOrElective(GraduationCategory graduationCategory, boolean isMandatory) { //when - boolean result = graduationCategory.checkMandatoryIfSeperatedByMandatoryAndElective(); + boolean result = graduationCategory.checkMandatoryIfSeparatedByMandatoryAndElective(); //then assertThat(result).isEqualTo(isMandatory); diff --git a/src/test/java/com/plzgraduate/myongjigraduatebe/parsing/domain/ParsingInformationTest.java b/src/test/java/com/plzgraduate/myongjigraduatebe/parsing/domain/ParsingInformationTest.java index 62dc534d..30388265 100644 --- a/src/test/java/com/plzgraduate/myongjigraduatebe/parsing/domain/ParsingInformationTest.java +++ b/src/test/java/com/plzgraduate/myongjigraduatebe/parsing/domain/ParsingInformationTest.java @@ -3,6 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import com.plzgraduate.myongjigraduatebe.user.domain.model.StudentCategory; +import com.plzgraduate.myongjigraduatebe.user.domain.model.TransferCredit; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -25,10 +26,14 @@ void createParsingInformation() { ParsingInformation parsingInformation = ParsingInformation.parsing(parsingText); //then - assertThat(parsingInformation) - .extracting("studentName", "studentNumber", "major", "subMajor", "associatedMajor", - "studentCategory") - .contains("이아현", "60191000", "경영학과", null, null, StudentCategory.NORMAL); + assertThat(parsingInformation).extracting( + "studentName", + "studentNumber", + "major", + "subMajor", + "associatedMajor", + "studentCategory" + ).contains("이아현", "60191000", "경영학과", null, null, StudentCategory.NORMAL); } @DisplayName("복수전공을 할 경우 StudentCategory는 DUAL MAJOR이다.") @@ -46,10 +51,14 @@ void createParsingInformation() { //when ParsingInformation parsingInformation = ParsingInformation.parsing(parsingText); //then - assertThat(parsingInformation) - .extracting("studentName", "studentNumber", "major", "dualMajor", "associatedMajor", - "studentCategory") - .contains("이인구", "60161000", "정치외교학과", "경제학과", null, StudentCategory.DUAL_MAJOR); + assertThat(parsingInformation).extracting( + "studentName", + "studentNumber", + "major", + "dualMajor", + "associatedMajor", + "studentCategory" + ).contains("이인구", "60161000", "정치외교학과", "경제학과", null, StudentCategory.DUAL_MAJOR); } @DisplayName("전과을 할 경우 StudentCategory는 CHANGE_MAJOR이다.") @@ -59,7 +68,8 @@ void createParsingInformation() { String parsingText = "출력일자 : 2023/12/08|1/1" + "|ICT융합대학 융합소프트웨어학부 데이터테크놀로지전공, 나경호(60202455), 현학적 - 재학, 이수 - 3, 입학 - 신입학(2020/03/02)" + "|토익 - 715, 영어교과목면제 - 면제없음, 최종학적변동 - 2/1전과(2023/01/27), 전과내역 - 기계공학과" - + "|편입생 인정학점 - 교양 0, 전공 0, 자유선택 0, 성경과인간이해 0|교환학생 인정학점 - 학문기초교양 0, 일반교양 0, 전공 0, 복수전공학문기초교양 0, 복수전공 0, 연계전공 0, 부전공 0, 자유선택 0" + + "|편입생 인정학점 - 교양 0, 전공 0, 자유선택 0, 성경과인간이해 0" + + "|교환학생 인정학점 - 학문기초교양 0, 일반교양 0, 전공 0, 복수전공학문기초교양 0, 복수전공 0, 연계전공 0, 부전공 0, 자유선택 0" + "|공통교양 16.5, 핵심교양 6, 학문기초교양 6, 일반교양 12, 전공 9, 복수전공 0, 연계전공 0, 부전공 0, 교직 0, 자유선택 7" + "|총 취득학점 - 56.5, 총점 - 230.5, 평균평점 - 4.43" + "|이수구분|수강년도/학기|한글코드|과목코드|과목명|학점|등급|중복|공통교양|2020년 2학기|교필141|KMA02141|4차산업혁명과미래사회진로선택|2|P|공통교양|2020년 2학기|교필122|KMA02122|기독교와문화|2|A+|공통교양|2023년 1학기|교필105|KMA02105|발표와토의|3|A0|공통교양|2020년 1학기|교필127|KMA00101|성서와인간이해|2|A+|공통교양|2020년 1학기|교필123|KMA02123|영어3|2|A+|공통교양|2020년 2학기|교필124|KMA02124|영어4|2|A+|공통교양|2020년 1학기|교필125|KMA02125|영어회화3|1|A0|공통교양|2020년 2학기|교필126|KMA02126|영어회화4|1|A+|공통교양|2020년 1학기|교필101|KMA02101|채플|0.5|P|공통교양|2020년 2학기|교필101|KMA02101|채플|0.5|P|공통교양|2023년 1학기|교필101|KMA02101|채플|0.5|P|핵심교양|2023년 1학기|교선128|KMA02128|글로벌문화|3|A0|핵심교양|2023년 1학기|교선114|KMA02114|민주주의와현대사회|3|A+|학문기초교양|2020년 1학기|기자111|KME02111|물리학1|3|A+|학문기초교양|2020년 1학기|기자101|KME02101|미적분학1|3|A+|일반교양|2020년 2학기|기자112|KME02112|물리학2|3|A+|일반교양|2020년 1학기|기자113|KME02113|물리학실험1|1|A+|일반교양|2020년 2학기|기자114|KME02114|물리학실험2|1|A+|일반교양|2020년 2학기|기자102|KME02102|미적분학2|3|A+|일반교양|2020년 1학기|기자121|KME02121|일반화학|3|A+|일반교양|2020년 1학기|기자122|KME02122|일반화학실험|1|A+|전공1단계|2023년 1학기|데테202|HED01202|R통계분석|3|A+|전공1단계|2023년 1학기|융소102|HEB01102|기초프로그래밍|3|A+|전공1단계|2023년 1학기|데테201|HED01201|자료구조|3|A+|자유선택|2020년 2학기|공과100|JEA00100|공학입문설계|3|A+|자유선택|2020년 1학기|기계207|JEP01207|기계신입생세미나|1|P|자유선택|2020년 2학기|기계209|JEP02209|정역학|3|A+|"; @@ -68,10 +78,14 @@ void createParsingInformation() { ParsingInformation parsingInformation = ParsingInformation.parsing(parsingText); //then - assertThat(parsingInformation) - .extracting("studentName", "studentNumber", "major", "subMajor", "associatedMajor", - "studentCategory") - .contains("나경호", "60202455", "데이터테크놀로지전공", null, null, StudentCategory.CHANGE_MAJOR); + assertThat(parsingInformation).extracting( + "studentName", + "studentNumber", + "major", + "subMajor", + "associatedMajor", + "studentCategory" + ).contains("나경호", "60202455", "데이터테크놀로지전공", null, null, StudentCategory.CHANGE_MAJOR); } @DisplayName("전과을 할 경우 StudentCategory는 CHANGE_MAJOR이다.") @@ -91,11 +105,14 @@ void createParsingInformation() { ParsingInformation parsingInformation = ParsingInformation.parsing(parsingText); //then - assertThat(parsingInformation) - .extracting("studentName", "studentNumber", "major", "subMajor", "associatedMajor", - "studentCategory") - .contains("정지환", "60181666", "데이터테크놀로지전공", null, "응용소프트웨어전공", - StudentCategory.SUB_MAJOR); + assertThat(parsingInformation).extracting( + "studentName", + "studentNumber", + "major", + "subMajor", + "associatedMajor", + "studentCategory" + ).contains("정지환", "60181666", "데이터테크놀로지전공", null, "응용소프트웨어전공", StudentCategory.SUB_MAJOR); } @@ -114,11 +131,60 @@ void createParsingInformation() { //when ParsingInformation parsingInformation = ParsingInformation.parsing(parsingText); //then - assertThat(parsingInformation) - .extracting("studentName", "studentNumber", "major", "subMajor", "associatedMajor", - "studentCategory") - .contains("정지환", "60181666", "데이터테크놀로지전공", null, null, StudentCategory.NORMAL); + assertThat(parsingInformation).extracting( + "studentName", + "studentNumber", + "major", + "subMajor", + "associatedMajor", + "studentCategory" + ).contains("정지환", "60181666", "데이터테크놀로지전공", null, null, StudentCategory.NORMAL); assertThat(parsingInformation.getTakenLectureInformation()).hasSize(46); } + @DisplayName("편입생의 편입생 인정학점이 정상적으로 추출된다.") + @Test + void 편입생_인정학점_추출() { + String parsingText = "출력일자 : 2023/12/08|1/1" + + "|사회과학대학 경제학과, 최나영(60195521), 현학적 - 재학, 이수 - 7, 입학 - 일반3/1편입(2021/03/02)" + + "|토익 - , 영어교과목면제 - 면제없음, 최종학적변동 - 일반복학(2024/07/08)" + + "|편입생 인정학점 - 교양 51, 전공 0, 자유선택 13, 성경과인간이해 0" + + "|교환학생 인정학점 - 학문기초교양 0, 일반교양 0, 전공 0, 복수전공 0, 융합전공 0, 부전공 0, 자유선택 0" + + "|공통교양 2.5, 핵심교양 0, 학문기초교양 0, 일반교양 3, 전공 54, 복수전공 0, 융합전공 0, 부전공 0, 교직 0, 자유선택 0" + + "|총 취득학점 - 59.5, 총점 - 224.0, 평균평점 - 3.96" + + "|이수구분|수강년도/학기|한글코드|과목코드|과목명|학점|등급|중복|공통교양|2021년 1학기|교필127|KMA00101|성서와인간이해|2|A0"; + //given + //when + ParsingInformation parsingInformation = ParsingInformation.parsing(parsingText); + //then + assertThat(parsingInformation).extracting( + "studentName", + "studentNumber", + "major", + "transferCredit" + ).contains("최나영", "60195521", "경제학과", TransferCredit.from("51/0/13/0")); + } + + @DisplayName("비편입생의 편입생 인정학점이 정상적으로 추출된다.") + @Test + void 비편입생_인정학점_추출() { + //given + String parsingText = "출력일자 : 2023/09/01|1/1" + + "|ICT융합대학 융합소프트웨어학부 데이터테크놀로지전공, 부전공 - 응용소프트웨어전공, 정지환(60181666), 현학적 - 재학, 이수 - 7, 입학 - 신입학(2018/03/02)" + + "|토익 - 570, 영어교과목면제 - 면제없음, 최종학적변동 - 불일치복학(2022/07/15)" + + "|편입생 인정학점 - 교양 0, 전공 0, 자유선택 0, 성경과인간이해 0" + + "|교환학생 인정학점 - 학문기초교양 0, 일반교양 0, 전공 0, 복수전공학문기초교양 0, 복수전공 0, 연계전공 0, 부전공 0, 자유선택 0" + + "|공통교양 17, 핵심교양 12, 학문기초교양 18, 일반교양 5, 전공 63, 복수전공 0, 연계전공 0, 부전공 0, 교직 0, 자유선택 3" + + "|총 취득학점 - 118, 총점 - 436, 평균평점 - 3.82" + + "|이수구분|수강년도/학기|한글코드|과목코드|과목명|학점|등급|중복|공통교양|2019년 2학기|교필137|KMA02137|4차산업혁명시대의진로선택|2|P"; + //when + ParsingInformation parsingInformation = ParsingInformation.parsing(parsingText); + //then + assertThat(parsingInformation).extracting( + "studentName", + "studentNumber", + "major", + "transferCredit" + ).contains("정지환", "60181666", "데이터테크놀로지전공", TransferCredit.from("0/0/0/0")); + } } diff --git a/src/test/java/com/plzgraduate/myongjigraduatebe/parsing/domain/ParsingTextHistoryTest.java b/src/test/java/com/plzgraduate/myongjigraduatebe/parsing/domain/ParsingTextHistoryTest.java index e3c4256b..22c9a605 100644 --- a/src/test/java/com/plzgraduate/myongjigraduatebe/parsing/domain/ParsingTextHistoryTest.java +++ b/src/test/java/com/plzgraduate/myongjigraduatebe/parsing/domain/ParsingTextHistoryTest.java @@ -35,6 +35,5 @@ void fail() { assertThat(parsingTextHistory) .extracting("parsingText", "parsingResult") .contains(text, ParsingResult.FAIL); - } } diff --git a/src/test/java/com/plzgraduate/myongjigraduatebe/user/infrastructure/adapter/persistence/UserPersistenceAdapterTest.java b/src/test/java/com/plzgraduate/myongjigraduatebe/user/infrastructure/adapter/persistence/UserPersistenceAdapterTest.java index b135bc4e..f82dc7ea 100644 --- a/src/test/java/com/plzgraduate/myongjigraduatebe/user/infrastructure/adapter/persistence/UserPersistenceAdapterTest.java +++ b/src/test/java/com/plzgraduate/myongjigraduatebe/user/infrastructure/adapter/persistence/UserPersistenceAdapterTest.java @@ -3,6 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import com.plzgraduate.myongjigraduatebe.support.PersistenceTestSupport; +import com.plzgraduate.myongjigraduatebe.user.domain.model.TransferCredit; import com.plzgraduate.myongjigraduatebe.user.domain.model.User; import com.plzgraduate.myongjigraduatebe.user.infrastructure.adapter.persistence.entity.UserJpaEntity; import com.plzgraduate.myongjigraduatebe.user.infrastructure.adapter.persistence.repository.UserRepository; @@ -110,8 +111,7 @@ void deleteUser() { } private User createUser(String authId, String password, String studentNumber) { - return User - .builder() + return User.builder() .authId(authId) .password(password) .studentNumber(studentNumber) @@ -119,11 +119,11 @@ private User createUser(String authId, String password, String studentNumber) { } private UserJpaEntity createUserEntity(String authId, String password, String studentNumber) { - return UserJpaEntity - .builder() + return UserJpaEntity.builder() .authId(authId) .password(password) .studentNumber(studentNumber) + .transferCredit(TransferCredit.empty().toString()) .build(); } } diff --git a/src/test/java/com/plzgraduate/myongjigraduatebe/user/infrastructure/adapter/persistence/mapper/UserMapperTest.java b/src/test/java/com/plzgraduate/myongjigraduatebe/user/infrastructure/adapter/persistence/mapper/UserMapperTest.java index 5bede63c..6518e368 100644 --- a/src/test/java/com/plzgraduate/myongjigraduatebe/user/infrastructure/adapter/persistence/mapper/UserMapperTest.java +++ b/src/test/java/com/plzgraduate/myongjigraduatebe/user/infrastructure/adapter/persistence/mapper/UserMapperTest.java @@ -5,6 +5,7 @@ import com.plzgraduate.myongjigraduatebe.support.PersistenceTestSupport; import com.plzgraduate.myongjigraduatebe.user.domain.model.EnglishLevel; import com.plzgraduate.myongjigraduatebe.user.domain.model.StudentCategory; +import com.plzgraduate.myongjigraduatebe.user.domain.model.TransferCredit; import com.plzgraduate.myongjigraduatebe.user.domain.model.User; import com.plzgraduate.myongjigraduatebe.user.infrastructure.adapter.persistence.entity.UserJpaEntity; import org.junit.jupiter.api.DisplayName; @@ -26,13 +27,35 @@ void mapToDomainEntityTest() { User user = userMapper.mapToDomainEntity(userJpaEntity); //then - assertThat(user) - .extracting("id", "authId", "password", "englishLevel", "name", "studentNumber", - "entryYear", - "primaryMajor", "subMajor", "studentCategory", "totalCredit", "takenCredit", - "graduated") - .contains(1L, "mju1000", "mju1000!", EnglishLevel.ENG12, "김명지", - "60211111", 21, "경영", null, StudentCategory.NORMAL, 100, 40.0, false); + assertThat(user).extracting( + "id", + "authId", + "password", + "englishLevel", + "name", + "studentNumber", + "entryYear", + "primaryMajor", + "subMajor", + "studentCategory", + "totalCredit", + "takenCredit", + "graduated" + ).contains( + 1L, + "mju1000", + "mju1000!", + EnglishLevel.ENG12, + "김명지", + "60211111", + 21, + "경영", + null, + StudentCategory.NORMAL, + 100, + 40.0, + false + ); } @DisplayName("도메인 엔티티를 JPA 엔티티 변환한다.") @@ -45,12 +68,35 @@ void mapToJpaEntityTest() { UserJpaEntity userJpaEntity = userMapper.mapToJpaEntity(user); //then - assertThat(userJpaEntity) - .extracting("id", "authId", "password", "englishLevel", "name", "studentNumber", - "entryYear", "major", - "subMajor", "studentCategory", "totalCredit", "takenCredit", "graduated") - .contains(1L, "mju1000", "mju1000!", EnglishLevel.ENG12, "김명지", - "60211111", 21, "경영", null, StudentCategory.NORMAL, 100, 40.0, false); + assertThat(userJpaEntity).extracting( + "id", + "authId", + "password", + "englishLevel", + "name", + "studentNumber", + "entryYear", + "major", + "subMajor", + "studentCategory", + "totalCredit", + "takenCredit", + "graduated" + ).contains( + 1L, + "mju1000", + "mju1000!", + EnglishLevel.ENG12, + "김명지", + "60211111", + 21, + "경영", + null, + StudentCategory.NORMAL, + 100, + 40.0, + false + ); } private User createUser() { @@ -65,6 +111,7 @@ private User createUser() { .primaryMajor("경영") .dualMajor(null) .subMajor(null) + .transferCredit(TransferCredit.empty()) .totalCredit(100) .takenCredit(40) .graduated(false) @@ -83,6 +130,7 @@ private UserJpaEntity createUserJpaEntity() { .englishLevel(EnglishLevel.ENG12) .major("경영") .dualMajor("복수전공") + .transferCredit(TransferCredit.empty().toString()) .totalCredit(100) .takenCredit(40) .graduated(false)