Skip to content

Commit

Permalink
Merge pull request #403 from Team-Ampersand/feat/logginghttp
Browse files Browse the repository at this point in the history
Feat/logginghttp
  • Loading branch information
esperar authored Aug 8, 2024
2 parents 293f4d4 + bf82bd8 commit aee6901
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 41 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.dotori.v2.domain.selfstudy.util

import com.dotori.v2.domain.selfstudy.properties.SelfStudyProperties
import com.dotori.v2.domain.selfstudy.exception.NotSelfStudyApplyDayException
import com.dotori.v2.domain.selfstudy.exception.NotSelfStudyApplyHourException
import com.dotori.v2.domain.selfstudy.exception.NotSelfStudyCancelDayException
Expand All @@ -13,7 +12,6 @@ import java.time.LocalDateTime

@Component
class ValidDayOfWeekAndHourUtil(
private val selfStudyProperties: SelfStudyProperties,
private val environment: Environment
) {

Expand All @@ -23,16 +21,14 @@ class ValidDayOfWeekAndHourUtil(
val hour = currentTime.hour
val minute = currentTime.minute

if (!isDevProfile() && (dayOfWeek == DayOfWeek.FRIDAY || dayOfWeek == DayOfWeek.SATURDAY || dayOfWeek == DayOfWeek.SUNDAY)) {
if (!isDevProfile() && (dayOfWeek == DayOfWeek.FRIDAY ||
dayOfWeek == DayOfWeek.SATURDAY || dayOfWeek == DayOfWeek.SUNDAY)) {
throw NotSelfStudyApplyDayException()
}

val allowedStartTime = selfStudyProperties.allowedStartTime.split(":").map { it.toInt() }.toIntArray()
val allowedEndTime = selfStudyProperties.allowedEndTime.split(":").map { it.toInt() }.toIntArray()
if(isDevProfile()) return

// 시간은 start hour: start minute ~ end 사이이면서
if (hour >= allowedStartTime[0] && minute >= allowedStartTime[1] && hour <= allowedEndTime[0] && minute <= allowedEndTime[1])
return
if(hour == 20 && minute >= 0) return

throw NotSelfStudyApplyHourException()
}
Expand All @@ -43,15 +39,14 @@ class ValidDayOfWeekAndHourUtil(
val hour = currentTime.hour
val minute = currentTime.minute

if (!isDevProfile() && (dayOfWeek == DayOfWeek.FRIDAY || dayOfWeek == DayOfWeek.SATURDAY || dayOfWeek == DayOfWeek.SUNDAY)) {
if (!isDevProfile() && (dayOfWeek == DayOfWeek.FRIDAY ||
dayOfWeek == DayOfWeek.SATURDAY || dayOfWeek == DayOfWeek.SUNDAY)) {
throw NotSelfStudyCancelDayException()
}

val allowedStartTime = selfStudyProperties.allowedStartTime.split(":").map { it.toInt() }.toIntArray()
val allowedEndTime = selfStudyProperties.allowedEndTime.split(":").map { it.toInt() }.toIntArray()
if(isDevProfile()) return

if (hour >= allowedStartTime[0] && minute >= allowedStartTime[1] && hour <= allowedEndTime[0] && minute <= allowedEndTime[1])
return
if(hour == 20 && minute >= 0) return

throw NotSelfStudyCancelHourException()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.dotori.v2.global.config

import com.dotori.v2.domain.selfstudy.properties.SelfStudyProperties
import com.dotori.v2.global.config.gauth.properties.GAuthProperties
import com.dotori.v2.global.security.jwt.properties.JwtProperties
import com.dotori.v2.global.security.jwt.properties.JwtTimeProperties
Expand All @@ -12,8 +11,7 @@ import org.springframework.context.annotation.Configuration
basePackageClasses = [
GAuthProperties::class,
JwtProperties::class,
JwtTimeProperties::class,
SelfStudyProperties::class
JwtTimeProperties::class
]
)
class ConfigurationPropertiesScanConfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.dotori.v2.domain.selfstudy.exception.NotSelfStudyApplyDayException
import com.dotori.v2.domain.selfstudy.exception.NotSelfStudyApplyHourException
import com.dotori.v2.domain.selfstudy.exception.NotSelfStudyCancelDayException
import com.dotori.v2.domain.selfstudy.exception.NotSelfStudyCancelHourException
import com.dotori.v2.domain.selfstudy.properties.SelfStudyProperties
import io.kotest.assertions.throwables.shouldThrow
import io.kotest.core.spec.style.BehaviorSpec
import io.kotest.matchers.shouldBe
Expand Down Expand Up @@ -136,20 +135,11 @@ class ValidDayOfWeekAndHourTest : BehaviorSpec({

private fun validDayOfWeekAndHourUtil(year: Int, month: Int, day: Int, hour: Int, minute: Int, second: Int, profile: String): ValidDayOfWeekAndHourUtil {
val testDate = LocalDateTime.of(year, month, day, hour, minute, second)
val selfStudyProperties = mockk<SelfStudyProperties>()
val environment = mockk<Environment>()

every { environment.activeProfiles } returns arrayOf(profile)

if (profile == "dev") {
every { selfStudyProperties.allowedStartTime } returns "00:00"
every { selfStudyProperties.allowedEndTime } returns "23:59"
} else if (profile == "prod") {
every { selfStudyProperties.allowedStartTime } returns "20:00"
every { selfStudyProperties.allowedEndTime } returns "20:59"
}

every { LocalDateTime.now() } returns testDate

return ValidDayOfWeekAndHourUtil(selfStudyProperties, environment)
return ValidDayOfWeekAndHourUtil(environment)
}

0 comments on commit aee6901

Please sign in to comment.