From 900ed51d09fcbfaf0dcc04aebbb60396f042240a Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Sat, 14 Sep 2024 11:45:59 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20Repository=E5=AE=9F=E8=A3=85?= =?UTF-8?q?=E3=81=AE=E3=82=AF=E3=83=A9=E3=82=B9=E5=90=8D=E3=82=92=E7=B5=B1?= =?UTF-8?q?=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ryImpl.kt => ExposedCustomEmojiRepository.kt} | 4 ++-- ...itoryImpl.kt => ExposedInstanceRepository.kt} | 4 ++-- ...oryImpl.kt => ExposedUserDetailRepository.kt} | 4 ++-- ...lTest.kt => ExposedInstanceRepositoryTest.kt} | 16 ++++++++-------- ...est.kt => ExposedUserDetailRepositoryTest.kt} | 4 ++-- .../test/kotlin/utils/AbstractRepositoryTest.kt | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) rename hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/{CustomEmojiRepositoryImpl.kt => ExposedCustomEmojiRepository.kt} (96%) rename hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/{InstanceRepositoryImpl.kt => ExposedInstanceRepository.kt} (96%) rename hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/{UserDetailRepositoryImpl.kt => ExposedUserDetailRepository.kt} (95%) rename hideout-core/src/test/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/{InstanceRepositoryImplTest.kt => ExposedInstanceRepositoryTest.kt} (94%) rename hideout-core/src/test/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/{UserDetailRepositoryImplTest.kt => ExposedUserDetailRepositoryTest.kt} (99%) diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/CustomEmojiRepositoryImpl.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedCustomEmojiRepository.kt similarity index 96% rename from hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/CustomEmojiRepositoryImpl.kt rename to hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedCustomEmojiRepository.kt index e3ca9079..d96f7a0c 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/CustomEmojiRepositoryImpl.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedCustomEmojiRepository.kt @@ -31,7 +31,7 @@ import org.springframework.stereotype.Repository import java.net.URI @Repository -class CustomEmojiRepositoryImpl : CustomEmojiRepository, +class ExposedCustomEmojiRepository : CustomEmojiRepository, AbstractRepository() { override val logger: Logger get() = Companion.logger @@ -76,7 +76,7 @@ class CustomEmojiRepositoryImpl : CustomEmojiRepository, } companion object { - private val logger = LoggerFactory.getLogger(CustomEmojiRepositoryImpl::class.java) + private val logger = LoggerFactory.getLogger(ExposedCustomEmojiRepository::class.java) } } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/InstanceRepositoryImpl.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedInstanceRepository.kt similarity index 96% rename from hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/InstanceRepositoryImpl.kt rename to hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedInstanceRepository.kt index 09c2b9be..1f4e35f4 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/InstanceRepositoryImpl.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedInstanceRepository.kt @@ -28,7 +28,7 @@ import java.net.URI import dev.usbharu.hideout.core.domain.model.instance.Instance as InstanceEntity @Repository -class InstanceRepositoryImpl : InstanceRepository, +class ExposedInstanceRepository : InstanceRepository, AbstractRepository() { override val logger: Logger get() = Companion.logger @@ -66,7 +66,7 @@ class InstanceRepositoryImpl : InstanceRepository, } companion object { - private val logger = LoggerFactory.getLogger(InstanceRepositoryImpl::class.java) + private val logger = LoggerFactory.getLogger(ExposedInstanceRepository::class.java) } } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/UserDetailRepositoryImpl.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedUserDetailRepository.kt similarity index 95% rename from hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/UserDetailRepositoryImpl.kt rename to hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedUserDetailRepository.kt index 2f4a22df..cacaa922 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/UserDetailRepositoryImpl.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedUserDetailRepository.kt @@ -32,7 +32,7 @@ import org.slf4j.LoggerFactory import org.springframework.stereotype.Repository @Repository -class UserDetailRepositoryImpl(override val domainEventPublisher: DomainEventPublisher) : +class ExposedUserDetailRepository(override val domainEventPublisher: DomainEventPublisher) : UserDetailRepository, AbstractRepository(), DomainEventPublishableRepository { @@ -105,7 +105,7 @@ class UserDetailRepositoryImpl(override val domainEventPublisher: DomainEventPub ) companion object { - private val logger = LoggerFactory.getLogger(UserDetailRepositoryImpl::class.java) + private val logger = LoggerFactory.getLogger(ExposedUserDetailRepository::class.java) } } diff --git a/hideout-core/src/test/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/InstanceRepositoryImplTest.kt b/hideout-core/src/test/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedInstanceRepositoryTest.kt similarity index 94% rename from hideout-core/src/test/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/InstanceRepositoryImplTest.kt rename to hideout-core/src/test/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedInstanceRepositoryTest.kt index 6bcb52fb..1b6c47b5 100644 --- a/hideout-core/src/test/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/InstanceRepositoryImplTest.kt +++ b/hideout-core/src/test/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedInstanceRepositoryTest.kt @@ -20,12 +20,12 @@ import kotlin.test.assertNull import dev.usbharu.hideout.core.infrastructure.exposedrepository.Instance as InstanceTable @TestInstance(TestInstance.Lifecycle.PER_CLASS) -class InstanceRepositoryImplTest : AbstractRepositoryTest(InstanceTable) { +class ExposedInstanceRepositoryTest : AbstractRepositoryTest(InstanceTable) { @Test fun save_idが同じレコードがない場合はinsertされる() = runTest { - InstanceRepositoryImpl().save( + ExposedInstanceRepository().save( Instance( id = InstanceId(1), name = InstanceName("test"), @@ -78,7 +78,7 @@ class InstanceRepositoryImplTest : AbstractRepositoryTest(InstanceTable) { }.launch() - InstanceRepositoryImpl().save( + ExposedInstanceRepository().save( Instance( id = InstanceId(1), name = InstanceName("test"), @@ -130,7 +130,7 @@ class InstanceRepositoryImplTest : AbstractRepositoryTest(InstanceTable) { } }.launch() - val actual = InstanceRepositoryImpl().findById(InstanceId(1)) + val actual = ExposedInstanceRepository().findById(InstanceId(1)) val expected = Instance( id = InstanceId(1), name = InstanceName("test"), @@ -151,7 +151,7 @@ class InstanceRepositoryImplTest : AbstractRepositoryTest(InstanceTable) { @Test fun findById_指定したIDで存在しないとnull() = runTest { - assertNull(InstanceRepositoryImpl().findById(InstanceId(1))) + assertNull(ExposedInstanceRepository().findById(InstanceId(1))) } @Test @@ -178,7 +178,7 @@ class InstanceRepositoryImplTest : AbstractRepositoryTest(InstanceTable) { } }.launch() - val actual = InstanceRepositoryImpl().findByUrl(URI.create("https://www.example.com")) + val actual = ExposedInstanceRepository().findByUrl(URI.create("https://www.example.com")) val expected = Instance( id = InstanceId(1), name = InstanceName("test"), @@ -199,7 +199,7 @@ class InstanceRepositoryImplTest : AbstractRepositoryTest(InstanceTable) { @Test fun findByUrl_指定したURLで存在しないとnull() = runTest { - assertNull(InstanceRepositoryImpl().findByUrl(URI.create("https://www.example.com"))) + assertNull(ExposedInstanceRepository().findByUrl(URI.create("https://www.example.com"))) } @Test @@ -243,7 +243,7 @@ class InstanceRepositoryImplTest : AbstractRepositoryTest(InstanceTable) { change.setStartPointNow() - InstanceRepositoryImpl().delete(instance) + ExposedInstanceRepository().delete(instance) change.setEndPointNow() diff --git a/hideout-core/src/test/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/UserDetailRepositoryImplTest.kt b/hideout-core/src/test/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedUserDetailRepositoryTest.kt similarity index 99% rename from hideout-core/src/test/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/UserDetailRepositoryImplTest.kt rename to hideout-core/src/test/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedUserDetailRepositoryTest.kt index 35bf81a5..532cbda6 100644 --- a/hideout-core/src/test/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/UserDetailRepositoryImplTest.kt +++ b/hideout-core/src/test/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedUserDetailRepositoryTest.kt @@ -25,10 +25,10 @@ import kotlin.test.assertNotNull import kotlin.test.assertNull @ExtendWith(MockitoExtension::class) -class UserDetailRepositoryImplTest : AbstractRepositoryTest(UserDetails) { +class ExposedUserDetailRepositoryTest : AbstractRepositoryTest(UserDetails) { @InjectMocks - lateinit var userDetailRepository: UserDetailRepositoryImpl + lateinit var userDetailRepository: ExposedUserDetailRepository @Mock lateinit var domainEventPublisher: DomainEventPublisher diff --git a/hideout-core/src/test/kotlin/utils/AbstractRepositoryTest.kt b/hideout-core/src/test/kotlin/utils/AbstractRepositoryTest.kt index 569cfa60..4499081a 100644 --- a/hideout-core/src/test/kotlin/utils/AbstractRepositoryTest.kt +++ b/hideout-core/src/test/kotlin/utils/AbstractRepositoryTest.kt @@ -49,7 +49,7 @@ abstract class AbstractRepositoryTest(private val exposedTable: org.jetbrains.ex fun tearDown() { dbSetup(to = dataSource) { execute(Operations.sql("SET REFERENTIAL_INTEGRITY TRUE")) - } + }.launch() transaction.rollback() transaction.close() }