diff --git a/src/main/kotlin/com/petqua/domain/auth/token/AuthToken.kt b/src/main/kotlin/com/petqua/domain/auth/token/AuthToken.kt index 00b22609..42f59ee7 100644 --- a/src/main/kotlin/com/petqua/domain/auth/token/AuthToken.kt +++ b/src/main/kotlin/com/petqua/domain/auth/token/AuthToken.kt @@ -1,6 +1,5 @@ package com.petqua.domain.auth.token - private const val EMPTY_TOKEN = "" class AuthToken private constructor( diff --git a/src/main/kotlin/com/petqua/domain/fish/FishCustomRepositoryImpl.kt b/src/main/kotlin/com/petqua/domain/fish/FishCustomRepositoryImpl.kt index 89dd4910..7fa6c1d9 100644 --- a/src/main/kotlin/com/petqua/domain/fish/FishCustomRepositoryImpl.kt +++ b/src/main/kotlin/com/petqua/domain/fish/FishCustomRepositoryImpl.kt @@ -23,6 +23,7 @@ class FishCustomRepositoryImpl( ).whereAnd( path(Fish::species)(Species::name).like(pattern = "%${speciesName}%") ).orderBy( + locate(speciesName, path(Fish::species)(Species::name)).asc(), length(path(Fish::species)(Species::name)).asc(), path(Fish::species)(Species::name).asc() ) diff --git a/src/main/kotlin/com/petqua/domain/member/TankName.kt b/src/main/kotlin/com/petqua/domain/member/TankName.kt index 0a8d463f..d55a20c7 100644 --- a/src/main/kotlin/com/petqua/domain/member/TankName.kt +++ b/src/main/kotlin/com/petqua/domain/member/TankName.kt @@ -7,8 +7,6 @@ import jakarta.persistence.Column import jakarta.persistence.Embeddable import java.util.regex.Pattern -private const val WHITESPACE = " " - @Embeddable data class TankName( @Column(nullable = false, name = "name") @@ -28,19 +26,20 @@ data class TankName( } private fun validateConsecutiveWhitespaces() { - throwExceptionWhen(whitespacePattern.toRegex().containsMatchIn(value)) { + throwExceptionWhen(WHITESPACE_PATTERN.toRegex().containsMatchIn(value)) { MemberException(INVALID_MEMBER_FISH_TANK_NAME) } } private fun validateCharactersAndLength() { - throwExceptionWhen(!wordPattern.matcher(value).matches()) { + throwExceptionWhen(!WORD_PATTERN.matcher(value).matches()) { MemberException(INVALID_MEMBER_FISH_TANK_NAME) } } companion object { - private val wordPattern = Pattern.compile("^[a-zA-Z0-9가-힣,/_ ]{2,18}\$") - private val whitespacePattern = Pattern.compile("$WHITESPACE{2,}") + private const val WHITESPACE = " " + private val WORD_PATTERN = Pattern.compile("^[a-zA-Z0-9가-힣,/_ ]{2,18}\$") + private val WHITESPACE_PATTERN = Pattern.compile("$WHITESPACE{2,}") } } diff --git a/src/test/kotlin/com/petqua/application/fish/FishServiceTest.kt b/src/test/kotlin/com/petqua/application/fish/FishServiceTest.kt index ec0f09ac..dade7398 100644 --- a/src/test/kotlin/com/petqua/application/fish/FishServiceTest.kt +++ b/src/test/kotlin/com/petqua/application/fish/FishServiceTest.kt @@ -36,9 +36,9 @@ class FishServiceTest( Then("관련된 어종 목록을 조회할 수 있다") { responses shouldBe listOf( SpeciesSearchResponse(fishA.id, fishA.species.name), - SpeciesSearchResponse(fishD.id, fishD.species.name), SpeciesSearchResponse(fishB.id, fishB.species.name), SpeciesSearchResponse(fishC.id, fishC.species.name), + SpeciesSearchResponse(fishD.id, fishD.species.name), ) } } @@ -54,7 +54,7 @@ class FishServiceTest( Then("입력한 개수만큼 관련된 어종 목록을 조회할 수 있다") { responses shouldBe listOf( SpeciesSearchResponse(fishA.id, fishA.species.name), - SpeciesSearchResponse(fishD.id, fishD.species.name), + SpeciesSearchResponse(fishB.id, fishB.species.name), ) } } diff --git a/src/test/kotlin/com/petqua/domain/fish/FishCustomRepositoryImplTest.kt b/src/test/kotlin/com/petqua/domain/fish/FishCustomRepositoryImplTest.kt index adb35b42..97224c40 100644 --- a/src/test/kotlin/com/petqua/domain/fish/FishCustomRepositoryImplTest.kt +++ b/src/test/kotlin/com/petqua/domain/fish/FishCustomRepositoryImplTest.kt @@ -25,15 +25,15 @@ class FishCustomRepositoryImplTest( Then("관련된 어종 목록을 조회할 수 있다") { fishes.map { it.species.name } shouldBe listOf( fishA.species.name, - fishD.species.name, fishB.species.name, - fishC.species.name + fishC.species.name, + fishD.species.name ) fishes.map { it.id } shouldBe listOf( fishA.id, - fishD.id, fishB.id, - fishC.id + fishC.id, + fishD.id ) } } diff --git a/src/test/kotlin/com/petqua/presentation/fish/FishControllerTest.kt b/src/test/kotlin/com/petqua/presentation/fish/FishControllerTest.kt index 9354c478..845d86d9 100644 --- a/src/test/kotlin/com/petqua/presentation/fish/FishControllerTest.kt +++ b/src/test/kotlin/com/petqua/presentation/fish/FishControllerTest.kt @@ -35,9 +35,9 @@ class FishControllerTest( response.statusCode shouldBe OK.value() speciesSearchResponses shouldBe listOf( SpeciesSearchResponse(fishA.id, fishA.species.name), - SpeciesSearchResponse(fishD.id, fishD.species.name), SpeciesSearchResponse(fishB.id, fishB.species.name), SpeciesSearchResponse(fishC.id, fishC.species.name), + SpeciesSearchResponse(fishD.id, fishD.species.name), ) } } @@ -53,7 +53,7 @@ class FishControllerTest( response.statusCode shouldBe OK.value() speciesSearchResponses shouldBe listOf( SpeciesSearchResponse(fishA.id, fishA.species.name), - SpeciesSearchResponse(fishD.id, fishD.species.name), + SpeciesSearchResponse(fishB.id, fishB.species.name), ) } }