From e7b0df8afb72c27ef68c706b581e5c650b085824 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Fri, 2 Jun 2023 17:31:54 +0900 Subject: [PATCH] =?UTF-8?q?style:=20=E3=82=B9=E3=82=BF=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 2 +- .../hideout/domain/model/ap/UndoTest.kt | 3 ++- .../hideout/plugins/ActivityPubKtTest.kt | 12 ++++++++++ .../JwtRefreshTokenRepositoryImplTest.kt | 22 ++++++++++++------- .../ContentTypeRouteSelectorTest.kt | 12 +++++----- .../routing/api/internal/v1/PostsTest.kt | 17 +++++++++----- .../routing/api/internal/v1/UsersTest.kt | 18 ++++++++++----- .../hideout/service/MetaServiceImplTest.kt | 1 - .../ServerInitialiseServiceImplTest.kt | 14 ++++++------ 9 files changed, 66 insertions(+), 35 deletions(-) diff --git a/gradle.properties b/gradle.properties index 56d141a1..9ee92fa5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,6 +6,6 @@ exposed_version=0.41.1 h2_version=2.1.214 koin_version=3.3.1 org.gradle.parallel=true -#org.gradle.configureondemand=true +org.gradle.configureondemand=true org.gradle.caching=true org.gradle.jvmargs=-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError -XX:+UseParallelGC diff --git a/src/test/kotlin/dev/usbharu/hideout/domain/model/ap/UndoTest.kt b/src/test/kotlin/dev/usbharu/hideout/domain/model/ap/UndoTest.kt index 0e34e75e..cc02183e 100644 --- a/src/test/kotlin/dev/usbharu/hideout/domain/model/ap/UndoTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/domain/model/ap/UndoTest.kt @@ -30,7 +30,8 @@ class UndoTest { @Test fun Undoをデシリアライズ出来る() { - @Language("JSON") val json = """ + @Language("JSON") + val json = """ { "@context": [ "https://www.w3.org/ns/activitystreams", diff --git a/src/test/kotlin/dev/usbharu/hideout/plugins/ActivityPubKtTest.kt b/src/test/kotlin/dev/usbharu/hideout/plugins/ActivityPubKtTest.kt index e788e4bb..c00503c6 100644 --- a/src/test/kotlin/dev/usbharu/hideout/plugins/ActivityPubKtTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/plugins/ActivityPubKtTest.kt @@ -92,6 +92,18 @@ class ActivityPubKtTest { TODO("Not yet implemented") } + override suspend fun addFollowRequest(id: Long, follower: Long) { + TODO("Not yet implemented") + } + + override suspend fun deleteFollowRequest(id: Long, follower: Long) { + TODO("Not yet implemented") + } + + override suspend fun findFollowRequestsById(id: Long, follower: Long): Boolean { + TODO("Not yet implemented") + } + override suspend fun nextId(): Long { TODO("Not yet implemented") } diff --git a/src/test/kotlin/dev/usbharu/hideout/repository/JwtRefreshTokenRepositoryImplTest.kt b/src/test/kotlin/dev/usbharu/hideout/repository/JwtRefreshTokenRepositoryImplTest.kt index 396ecc08..ce44343f 100644 --- a/src/test/kotlin/dev/usbharu/hideout/repository/JwtRefreshTokenRepositoryImplTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/repository/JwtRefreshTokenRepositoryImplTest.kt @@ -41,11 +41,14 @@ class JwtRefreshTokenRepositoryImplTest { @Test fun `save 存在しない場合はinsertする`() = runTest { - val repository = JwtRefreshTokenRepositoryImpl(db, object : IdGenerateService { - override suspend fun generateId(): Long { - TODO("Not yet implemented") + val repository = JwtRefreshTokenRepositoryImpl( + db, + object : IdGenerateService { + override suspend fun generateId(): Long { + TODO("Not yet implemented") + } } - }) + ) val now = Instant.now(Clock.tickMillis(ZoneId.systemDefault())) val expiresAt = now.plus(10, ChronoUnit.MINUTES) @@ -57,11 +60,14 @@ class JwtRefreshTokenRepositoryImplTest { @Test fun `save 存在する場合はupdateする`() = runTest { - val repository = JwtRefreshTokenRepositoryImpl(db, object : IdGenerateService { - override suspend fun generateId(): Long { - TODO("Not yet implemented") + val repository = JwtRefreshTokenRepositoryImpl( + db, + object : IdGenerateService { + override suspend fun generateId(): Long { + TODO("Not yet implemented") + } } - }) + ) transaction { JwtRefreshTokens.insert { it[id] = 1L diff --git a/src/test/kotlin/dev/usbharu/hideout/routing/activitypub/ContentTypeRouteSelectorTest.kt b/src/test/kotlin/dev/usbharu/hideout/routing/activitypub/ContentTypeRouteSelectorTest.kt index 71513fef..b10e2a07 100644 --- a/src/test/kotlin/dev/usbharu/hideout/routing/activitypub/ContentTypeRouteSelectorTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/routing/activitypub/ContentTypeRouteSelectorTest.kt @@ -30,7 +30,7 @@ class ContentTypeRouteSelectorTest { } } - client.get("/test"){ + client.get("/test") { accept(ContentType.Text.Html) }.apply { assertEquals("NG", bodyAsText()) @@ -60,7 +60,7 @@ class ContentTypeRouteSelectorTest { } } - client.get("/test"){ + client.get("/test") { accept(ContentType.Text.Html) }.apply { assertEquals("NG", bodyAsText()) @@ -85,7 +85,7 @@ class ContentTypeRouteSelectorTest { } } - client.get("/test"){ + client.get("/test") { accept(ContentType.Text.Html) }.apply { assertEquals("NG", bodyAsText()) @@ -114,18 +114,18 @@ class ContentTypeRouteSelectorTest { } } - client.get("/test"){ + client.get("/test") { accept(ContentType.Text.Html) }.apply { assertEquals("OK", bodyAsText()) } - client.get("/test"){ + client.get("/test") { accept(ContentType.Application.Json) }.apply { assertEquals("OK", bodyAsText()) } - client.get("/test"){ + client.get("/test") { accept(ContentType.Application.Xml) }.apply { assertEquals("NG", bodyAsText()) diff --git a/src/test/kotlin/dev/usbharu/hideout/routing/api/internal/v1/PostsTest.kt b/src/test/kotlin/dev/usbharu/hideout/routing/api/internal/v1/PostsTest.kt index 901acc89..5b878534 100644 --- a/src/test/kotlin/dev/usbharu/hideout/routing/api/internal/v1/PostsTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/routing/api/internal/v1/PostsTest.kt @@ -158,8 +158,12 @@ class PostsTest { config = ApplicationConfig("empty.conf") } val post = Post( - 12345, 1234, text = "aaa", visibility = Visibility.PUBLIC, - createdAt = Instant.now().toEpochMilli(), url = "https://example.com/posts/1" + 12345, + 1234, + text = "aaa", + visibility = Visibility.PUBLIC, + createdAt = Instant.now().toEpochMilli(), + url = "https://example.com/posts/1" ) val postService = mock { onBlocking { findByIdForUser(any(), anyOrNull()) } doReturn post @@ -185,8 +189,12 @@ class PostsTest { config = ApplicationConfig("empty.conf") } val post = Post( - 12345, 1234, text = "aaa", visibility = Visibility.FOLLOWERS, - createdAt = Instant.now().toEpochMilli(), url = "https://example.com/posts/1" + 12345, + 1234, + text = "aaa", + visibility = Visibility.FOLLOWERS, + createdAt = Instant.now().toEpochMilli(), + url = "https://example.com/posts/1" ) val postService = mock { onBlocking { findByIdForUser(any(), isNotNull()) } doReturn post @@ -247,7 +255,6 @@ class PostsTest { } application { authentication { - bearer(TOKEN_AUTH) { authenticate { println("aaaaaaaaaaaa") diff --git a/src/test/kotlin/dev/usbharu/hideout/routing/api/internal/v1/UsersTest.kt b/src/test/kotlin/dev/usbharu/hideout/routing/api/internal/v1/UsersTest.kt index 91da7b03..dffe7ab8 100644 --- a/src/test/kotlin/dev/usbharu/hideout/routing/api/internal/v1/UsersTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/routing/api/internal/v1/UsersTest.kt @@ -290,7 +290,8 @@ class UsersTest { "test User", "https://example.com/test", Instant.now().toEpochMilli() - ), UserResponse( + ), + UserResponse( 1236, "follower2", "example.com", @@ -334,7 +335,8 @@ class UsersTest { "test User", "https://example.com/test", Instant.now().toEpochMilli() - ), UserResponse( + ), + UserResponse( 1236, "follower2", "example.com", @@ -378,7 +380,8 @@ class UsersTest { "test User", "https://example.com/test", Instant.now().toEpochMilli() - ), UserResponse( + ), + UserResponse( 1236, "follower2", "example.com", @@ -572,7 +575,8 @@ class UsersTest { "test User", "https://example.com/test", Instant.now().toEpochMilli() - ), UserResponse( + ), + UserResponse( 1236, "follower2", "example.com", @@ -616,7 +620,8 @@ class UsersTest { "test User", "https://example.com/test", Instant.now().toEpochMilli() - ), UserResponse( + ), + UserResponse( 1236, "follower2", "example.com", @@ -660,7 +665,8 @@ class UsersTest { "test User", "https://example.com/test", Instant.now().toEpochMilli() - ), UserResponse( + ), + UserResponse( 1236, "follower2", "example.com", diff --git a/src/test/kotlin/dev/usbharu/hideout/service/MetaServiceImplTest.kt b/src/test/kotlin/dev/usbharu/hideout/service/MetaServiceImplTest.kt index 46ab3715..f484d51f 100644 --- a/src/test/kotlin/dev/usbharu/hideout/service/MetaServiceImplTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/service/MetaServiceImplTest.kt @@ -37,7 +37,6 @@ class MetaServiceImplTest { @Test fun `updateMeta メタデータを保存できる`() = runTest { - val meta = Meta("1.0.1", Jwt(UUID.randomUUID(), "sdfsdjk", "adafda")) val metaRepository = mock { onBlocking { save(any()) } doReturn Unit diff --git a/src/test/kotlin/dev/usbharu/hideout/service/ServerInitialiseServiceImplTest.kt b/src/test/kotlin/dev/usbharu/hideout/service/ServerInitialiseServiceImplTest.kt index 791e349a..3b6e34c0 100644 --- a/src/test/kotlin/dev/usbharu/hideout/service/ServerInitialiseServiceImplTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/service/ServerInitialiseServiceImplTest.kt @@ -23,23 +23,23 @@ class ServerInitialiseServiceImplTest { val serverInitialiseServiceImpl = ServerInitialiseServiceImpl(metaRepository) serverInitialiseServiceImpl.init() - verify(metaRepository,times(1)).save(any()) + verify(metaRepository, times(1)).save(any()) } @Test fun `init メタデータが存在して同じバージョンのときは何もしない`() = runTest { - val meta = Meta(ServerUtil.getImplementationVersion(), Jwt(UUID.randomUUID(),"aaafafd","afafasdf")) + val meta = Meta(ServerUtil.getImplementationVersion(), Jwt(UUID.randomUUID(), "aaafafd", "afafasdf")) val metaRepository = mock { onBlocking { get() } doReturn meta } val serverInitialiseServiceImpl = ServerInitialiseServiceImpl(metaRepository) serverInitialiseServiceImpl.init() - verify(metaRepository,times(0)).save(any()) + verify(metaRepository, times(0)).save(any()) } @Test fun `init メタデータが存在して違うバージョンのときはバージョンを変更する`() = runTest { - val meta = Meta("1.0.0", Jwt(UUID.randomUUID(),"aaafafd","afafasdf")) + val meta = Meta("1.0.0", Jwt(UUID.randomUUID(), "aaafafd", "afafasdf")) val metaRepository = mock { onBlocking { get() } doReturn meta onBlocking { save(any()) } doReturn Unit @@ -47,10 +47,10 @@ class ServerInitialiseServiceImplTest { val serverInitialiseServiceImpl = ServerInitialiseServiceImpl(metaRepository) serverInitialiseServiceImpl.init() - verify(metaRepository,times(1)).save(any()) + verify(metaRepository, times(1)).save(any()) argumentCaptor { - verify(metaRepository,times(1)).save(capture()) - assertEquals(ServerUtil.getImplementationVersion(),firstValue.version) + verify(metaRepository, times(1)).save(capture()) + assertEquals(ServerUtil.getImplementationVersion(), firstValue.version) } } }