-
Notifications
You must be signed in to change notification settings - Fork 0
feat(application): Application 테스트 및 실행 설정 정리 #24 #64
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
Merged
wlyoon921
merged 4 commits into
feat/24-application-persistence
from
feat/24-application-bootstrap-test
Aug 27, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8f87df6
feat(application): Application 테스트 및 실행 설정 정리 #24
wlyoon921 740b5cf
fix(application): 지원 일정 설정 및 테스트 fixture 정리 #24
wlyoon921 405be20
chore(application): usecase bean 등록 구성 추가 #24
wlyoon921 e0084da
fix(application): 유스케이스 테스트 및 성적 계산 안정성 보완 #24
wlyoon921 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 10 additions & 8 deletions
18
systems/application/application-application/src/test/kotlin/hs/kr/entrydsm/TestMain.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,13 @@ | ||
| package hs.kr.entrydsm.application.application | ||
|
|
||
| import org.junit.Assert.assertTrue | ||
| import org.junit.Test | ||
| import hs.kr.entrydsm.application.application.service.ApplicationCommandServiceTest | ||
| import hs.kr.entrydsm.application.application.service.EvaluationCommandServiceTest | ||
| import org.junit.runner.RunWith | ||
| import org.junit.runners.Suite | ||
|
|
||
| class ApplicationApplicationModuleTest { | ||
| @Test | ||
| fun moduleLoads() { | ||
| assertTrue(true) | ||
| } | ||
| } | ||
| @RunWith(Suite::class) | ||
| @Suite.SuiteClasses( | ||
| ApplicationCommandServiceTest::class, | ||
| EvaluationCommandServiceTest::class, | ||
| ) | ||
| class ApplicationApplicationModuleTest |
84 changes: 84 additions & 0 deletions
84
...st/kotlin/hs/kr/entrydsm/application/application/service/ApplicationCommandServiceTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| package hs.kr.entrydsm.application.application.service | ||
|
|
||
| import hs.kr.entrydsm.application.application.port.out.ApplicantRepository | ||
| import hs.kr.entrydsm.application.domain.enum.AdmissionType | ||
| import hs.kr.entrydsm.application.domain.enum.GraduationType | ||
| import hs.kr.entrydsm.application.domain.enum.Region | ||
| import hs.kr.entrydsm.application.domain.enum.SchoolSemester | ||
| import hs.kr.entrydsm.application.domain.enum.SubjectGrade | ||
| import hs.kr.entrydsm.application.domain.model.AcademicRecord | ||
| import hs.kr.entrydsm.application.domain.model.Applicant | ||
| import hs.kr.entrydsm.application.domain.model.MiddleSchoolInfo | ||
| import hs.kr.entrydsm.application.domain.model.SubjectGrades | ||
| import org.junit.Assert.assertNull | ||
| import org.junit.Assert.assertTrue | ||
| import org.junit.Test | ||
|
|
||
| class ApplicationCommandServiceTest { | ||
| @Test | ||
| fun updateTypeClearsMiddleSchoolInfoAndSubjectGradesWhenChangedToGed() { | ||
| val repository = FakeApplicantRepository( | ||
| Applicant( | ||
| id = 1L, | ||
| accountId = 10L, | ||
| graduationType = GraduationType.PROSPECTIVE, | ||
| middleSchoolInfo = MiddleSchoolInfo( | ||
| schoolName = "대덕중학교", | ||
| studentNumber = "30101", | ||
| schoolPhone = "042-000-0000", | ||
| teacherName = "담임", | ||
| ), | ||
| academicRecord = AcademicRecord( | ||
| subjectGrades = linkedMapOf( | ||
| SchoolSemester.THIRD_GRADE_FIRST_SEMESTER to all(SubjectGrade.A), | ||
| ), | ||
| ), | ||
| ), | ||
| ) | ||
| val service = ApplicationCommandService(repository) | ||
|
|
||
| service.updateType( | ||
| applicantId = 1L, | ||
| userId = 10L, | ||
| admissionType = AdmissionType.REGULAR, | ||
| region = Region.DAEJEON, | ||
| graduationType = GraduationType.GED, | ||
| graduationDate = null, | ||
| ) | ||
|
|
||
| val savedApplicant = requireNotNull(repository.savedApplicant) | ||
| assertNull(savedApplicant.middleSchoolInfo) | ||
| assertTrue(savedApplicant.academicRecord?.subjectGrades?.isEmpty() == true) | ||
| } | ||
|
|
||
| private class FakeApplicantRepository( | ||
| private var applicant: Applicant, | ||
| ) : ApplicantRepository { | ||
| var savedApplicant: Applicant? = null | ||
|
|
||
| override fun save(applicant: Applicant): Applicant { | ||
| savedApplicant = applicant | ||
| this.applicant = applicant | ||
| return applicant | ||
| } | ||
|
|
||
| override fun findById(id: Long): Applicant? = | ||
| applicant.takeIf { it.id == id } | ||
|
|
||
| override fun findByAccountId(accountId: Long): Applicant? = | ||
| applicant.takeIf { it.accountId == accountId } | ||
| } | ||
|
|
||
| private companion object { | ||
| fun all(grade: SubjectGrade): SubjectGrades = | ||
| SubjectGrades( | ||
| koreanGrade = grade, | ||
| mathGrade = grade, | ||
| englishGrade = grade, | ||
| scienceGrade = grade, | ||
| societyGrade = grade, | ||
| technologyGrade = grade, | ||
| historyGrade = grade, | ||
| ) | ||
| } | ||
| } |
75 changes: 75 additions & 0 deletions
75
...est/kotlin/hs/kr/entrydsm/application/application/service/EvaluationCommandServiceTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| package hs.kr.entrydsm.application.application.service | ||
|
|
||
| import hs.kr.entrydsm.application.application.port.out.ApplicantRepository | ||
| import hs.kr.entrydsm.application.domain.enum.AdmissionType | ||
| import hs.kr.entrydsm.application.domain.enum.GraduationType | ||
| import hs.kr.entrydsm.application.domain.enum.SchoolSemester | ||
| import hs.kr.entrydsm.application.domain.enum.SubjectGrade | ||
| import hs.kr.entrydsm.application.domain.model.AcademicRecord | ||
| import hs.kr.entrydsm.application.domain.model.Applicant | ||
| import hs.kr.entrydsm.application.domain.model.SubjectGrades | ||
| import hs.kr.entrydsm.application.domain.service.ScoreCalculator | ||
| import org.junit.Assert.assertEquals | ||
| import org.junit.Assert.assertNotNull | ||
| import org.junit.Test | ||
|
|
||
| class EvaluationCommandServiceTest { | ||
| @Test | ||
| fun calculateResultSavesScoreForApplicantsAdmissionType() { | ||
| val repository = FakeApplicantRepository( | ||
| Applicant( | ||
| id = 1L, | ||
| accountId = 10L, | ||
| admissionType = AdmissionType.REGULAR, | ||
| graduationType = GraduationType.PROSPECTIVE, | ||
| academicRecord = AcademicRecord( | ||
| volunteerTime = 15, | ||
| isDsmAlgorithmAwarded = true, | ||
| subjectGrades = linkedMapOf( | ||
| SchoolSemester.THIRD_GRADE_FIRST_SEMESTER to all(SubjectGrade.A), | ||
| SchoolSemester.SECOND_GRADE_SECOND_SEMESTER to all(SubjectGrade.A), | ||
| SchoolSemester.SECOND_GRADE_FIRST_SEMESTER to all(SubjectGrade.A), | ||
| ), | ||
| ), | ||
| ), | ||
| ) | ||
| val service = EvaluationCommandService(repository, ScoreCalculator()) | ||
|
|
||
| service.calculateResult(userId = 10L) | ||
|
|
||
| val savedApplicant = requireNotNull(repository.savedApplicant) | ||
| assertEquals(173.0, savedApplicant.totalScore ?: 0.0, 0.0) | ||
| assertNotNull(savedApplicant.totalScoreUpdatedAt) | ||
| } | ||
|
|
||
| private class FakeApplicantRepository( | ||
| private var applicant: Applicant, | ||
| ) : ApplicantRepository { | ||
| var savedApplicant: Applicant? = null | ||
|
|
||
| override fun save(applicant: Applicant): Applicant { | ||
| savedApplicant = applicant | ||
| this.applicant = applicant | ||
| return applicant | ||
| } | ||
|
|
||
| override fun findById(id: Long): Applicant? = | ||
| applicant.takeIf { it.id == id } | ||
|
|
||
| override fun findByAccountId(accountId: Long): Applicant? = | ||
| applicant.takeIf { it.accountId == accountId } | ||
| } | ||
|
|
||
| private companion object { | ||
| fun all(grade: SubjectGrade): SubjectGrades = | ||
| SubjectGrades( | ||
| koreanGrade = grade, | ||
| mathGrade = grade, | ||
| englishGrade = grade, | ||
| scienceGrade = grade, | ||
| societyGrade = grade, | ||
| technologyGrade = grade, | ||
| historyGrade = grade, | ||
| ) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...n-bootstrap/src/main/kotlin/hs/kr/entrydsm/application/config/ApplicationUseCaseConfig.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package hs.kr.entrydsm.application.config | ||
|
|
||
| import hs.kr.entrydsm.application.application.port.`in`.ApplicationPort | ||
| import hs.kr.entrydsm.application.application.port.`in`.EvaluationPort | ||
| import hs.kr.entrydsm.application.application.port.out.ApplicantRepository | ||
| import hs.kr.entrydsm.application.application.service.ApplicationCommandService | ||
| import hs.kr.entrydsm.application.application.service.EvaluationCommandService | ||
| import hs.kr.entrydsm.application.domain.service.ScoreCalculator | ||
| import org.springframework.context.annotation.Bean | ||
| import org.springframework.context.annotation.Configuration | ||
|
|
||
| @Configuration(proxyBeanMethods = false) | ||
| class ApplicationUseCaseConfig { | ||
| @Bean | ||
| fun scoreCalculator(): ScoreCalculator = ScoreCalculator() | ||
|
|
||
| @Bean | ||
| fun applicationService( | ||
| applicantRepository: ApplicantRepository, | ||
| ): ApplicationPort = ApplicationCommandService(applicantRepository) | ||
|
|
||
| @Bean | ||
| fun evaluationService( | ||
| applicantRepository: ApplicantRepository, | ||
| scoreCalculator: ScoreCalculator, | ||
| ): EvaluationPort = EvaluationCommandService(applicantRepository, scoreCalculator) | ||
| } |
24 changes: 24 additions & 0 deletions
24
systems/application/application-bootstrap/src/main/resources/application-dev.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| spring: | ||
| config: | ||
| activate: | ||
| on-profile: dev | ||
| datasource: | ||
| url: ${DB_URL} | ||
| username: ${DB_USERNAME} | ||
| password: ${DB_PASSWORD} | ||
| driver-class-name: com.mysql.cj.jdbc.Driver | ||
| jpa: | ||
| hibernate: | ||
| ddl-auto: update | ||
| open-in-view: false | ||
| show-sql: false | ||
| properties: | ||
| hibernate: | ||
| dialect: org.hibernate.dialect.MySQLDialect | ||
|
|
||
| entrydsm: | ||
| application: | ||
| schedule: | ||
| application-start-at: ${APPLICATION_START_AT} | ||
| application-end-at: ${APPLICATION_END_AT} | ||
| result-announced-at: ${RESULT_ANNOUNCED_AT} |
24 changes: 24 additions & 0 deletions
24
systems/application/application-bootstrap/src/main/resources/application-prod.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| spring: | ||
| config: | ||
| activate: | ||
| on-profile: prod | ||
| datasource: | ||
| url: ${DB_URL} | ||
| username: ${DB_USERNAME} | ||
| password: ${DB_PASSWORD} | ||
| driver-class-name: com.mysql.cj.jdbc.Driver | ||
| jpa: | ||
| hibernate: | ||
| ddl-auto: validate | ||
| open-in-view: false | ||
| show-sql: false | ||
| properties: | ||
| hibernate: | ||
| dialect: org.hibernate.dialect.MySQLDialect | ||
|
|
||
| entrydsm: | ||
| application: | ||
| schedule: | ||
| application-start-at: ${APPLICATION_START_AT} | ||
| application-end-at: ${APPLICATION_END_AT} | ||
| result-announced-at: ${RESULT_ANNOUNCED_AT} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.