Skip to content
Merged
Show file tree
Hide file tree
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 @@ -37,9 +37,9 @@ class ApplicationControllerTest {
val response = controller.getLanding(10L)

assertEquals("홍길동", response.data?.applicantName)
assertEquals(APPLICATION_START_AT, response.data?.schedule?.applicationPeriod?.startAt)
assertEquals(APPLICATION_END_AT, response.data?.schedule?.applicationPeriod?.endAt)
assertEquals(RESULT_ANNOUNCED_AT, response.data?.schedule?.resultAnnouncedAt)
assertEquals(applicationStartAt, response.data?.schedule?.applicationPeriod?.startAt)
assertEquals(applicationEndAt, response.data?.schedule?.applicationPeriod?.endAt)
assertEquals(resultAnnouncedAt, response.data?.schedule?.resultAnnouncedAt)
}

private class FakeApplicationPort : ApplicationPort {
Expand All @@ -61,15 +61,15 @@ class ApplicationControllerTest {
}

private companion object {
val APPLICATION_START_AT: LocalDateTime = LocalDateTime.parse("2026-04-01T09:00:00")
val APPLICATION_END_AT: LocalDateTime = LocalDateTime.parse("2026-04-30T17:00:00")
val RESULT_ANNOUNCED_AT: LocalDateTime = LocalDateTime.parse("2026-05-15T10:00:00")
val applicationStartAt: LocalDateTime = LocalDateTime.parse("2026-10-19T09:00:00")
val applicationEndAt: LocalDateTime = LocalDateTime.parse("2026-10-23T17:00:00")
val resultAnnouncedAt: LocalDateTime = LocalDateTime.parse("2026-10-30T10:00:00")

fun scheduleProperties(): LandingScheduleProperties =
LandingScheduleProperties(
applicationStartAt = APPLICATION_START_AT,
applicationEndAt = APPLICATION_END_AT,
resultAnnouncedAt = RESULT_ANNOUNCED_AT,
applicationStartAt = applicationStartAt,
applicationEndAt = applicationEndAt,
resultAnnouncedAt = resultAnnouncedAt,
)
Comment thread
wlyoon921 marked this conversation as resolved.
}
}
2 changes: 1 addition & 1 deletion systems/application/application-application/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ kt_jvm_test(
javac_opts = "//:javac_options",
kotlinc_opts = "//:kotlinc_options",
test_class = "hs.kr.entrydsm.application.application.ApplicationApplicationModuleTest",
deps = MODULE_DEPS + TEST_DEPS,
deps = [":main"] + MODULE_DEPS + TEST_DEPS,
)
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ class ApplicationCommandService(
applicant.region = region
applicant.graduationType = graduationType
applicant.graduationDate = graduationDate
if (graduationType == GraduationType.GED) {
applicant.middleSchoolInfo = null
applicant.academicRecord?.subjectGrades?.clear()
}
saveTouched(applicant)
}

Expand Down
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
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,
)
}
}
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,
)
}
}
2 changes: 1 addition & 1 deletion systems/application/application-bootstrap/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ kt_jvm_binary(
srcs = glob(["src/main/kotlin/**/*.kt"]),
javac_opts = "//:javac_options",
kotlinc_opts = "//:kotlinc_options",
main_class = "hs.kr.entrydsm.application.ApplicationBootstrapApplicationKt",
main_class = "hs.kr.entrydsm.application.ExampleApplicationKt",
plugins = ["//:spring_allopen"],
resources = glob(["src/main/resources/**"]),
deps = MODULE_DEPS + [
Expand Down
2 changes: 2 additions & 0 deletions systems/application/application-bootstrap/deps.bzl
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
SPRING_DEPS = [
"@maven//:org_springframework_boot_spring_boot_starter_web",
"@maven//:org_springframework_boot_spring_boot_starter_actuator",
"@maven//:org_springframework_boot_spring_boot_starter_data_jpa",
]

KOTLIN_DEPS = [
"@maven//:org_jetbrains_kotlin_kotlin_reflect",
"@maven//:com_fasterxml_jackson_module_jackson_module_kotlin",
"@maven//:com_mysql_mysql_connector_j",
]

TEST_DEPS = [
Expand Down
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)
}
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}
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}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@ spring:
application:
name: application
profiles:
default: local
default: dev
main:
lazy-initialization: true

server:
shutdown: graceful

grpc:
port: ${GRPC_PORT:9090}

management:
endpoints:
web:
Expand All @@ -16,6 +21,7 @@ management:
health:
probes:
enabled: true

logging:
level:
root: INFO
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,16 @@ class ScoreCalculator {
return EMPTY_SCORE
}

val convertedAbsences = record.absentCount + floor(
val convertedAbsences = record.absentCount.toLong() + floor(
(
record.lateCount +
record.earlyLeaveCount +
record.classAbsenceCount
record.lateCount.toLong() +
record.earlyLeaveCount.toLong() +
record.classAbsenceCount.toLong()
) / ATTENDANCE_CONVERSION_UNIT.toDouble(),
).toInt()
).toLong()

return (ATTENDANCE_MAX_SCORE - convertedAbsences).coerceAtLeast(EMPTY_SCORE)
return (ATTENDANCE_MAX_SCORE - convertedAbsences)
.coerceIn(EMPTY_SCORE, ATTENDANCE_MAX_SCORE)
}

private fun calculateVolunteerScore(
Expand Down
Loading
Loading