From 48bbf6a53b6871204855553b8fedfbecdf21f812 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Thu, 14 Dec 2023 14:37:36 +0900 Subject: [PATCH 1/8] =?UTF-8?q?test:=20=E3=83=86=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle.kts | 4 +- .../usbharu/hideout/EqualsAndToStringTest.kt | 38 ++++++--- .../activitypub/domain/model/CreateTest.kt | 83 +++++++++++++++++++ .../activitypub/domain/model/DocumentTest.kt | 37 +++++++++ .../domain/model/PersonSerializeTest.kt | 64 ++++++++++++++ 5 files changed, 213 insertions(+), 13 deletions(-) create mode 100644 src/test/kotlin/dev/usbharu/hideout/activitypub/domain/model/CreateTest.kt create mode 100644 src/test/kotlin/dev/usbharu/hideout/activitypub/domain/model/DocumentTest.kt diff --git a/build.gradle.kts b/build.gradle.kts index 9c892615..18d64acb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -83,7 +83,9 @@ tasks.withType { useJUnitPlatform() doFirst { jvmArgs = arrayOf( - "--add-opens", "java.base/java.lang=ALL-UNNAMED" + "--add-opens", "java.base/java.lang=ALL-UNNAMED", + "--add-opens", "java.base/java.util=ALL-UNNAMED", + "--add-opens", "java.naming/javax.naming=ALL-UNNAMED", ).toMutableList() } } diff --git a/src/test/kotlin/dev/usbharu/hideout/EqualsAndToStringTest.kt b/src/test/kotlin/dev/usbharu/hideout/EqualsAndToStringTest.kt index 62f68093..c9156b3f 100644 --- a/src/test/kotlin/dev/usbharu/hideout/EqualsAndToStringTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/EqualsAndToStringTest.kt @@ -1,10 +1,15 @@ package dev.usbharu.hideout +import com.fasterxml.jackson.module.kotlin.isKotlinClass import com.jparams.verifier.tostring.ToStringVerifier +import com.jparams.verifier.tostring.preset.Presets import nl.jqno.equalsverifier.EqualsVerifier import nl.jqno.equalsverifier.Warning import nl.jqno.equalsverifier.internal.reflection.PackageScanner +import org.junit.jupiter.api.DynamicTest +import org.junit.jupiter.api.DynamicTest.dynamicTest import org.junit.jupiter.api.Test +import org.junit.jupiter.api.TestFactory import java.lang.reflect.Modifier import kotlin.test.assertFails @@ -20,22 +25,31 @@ class EqualsAndToStringTest { } } - @Test - fun toStringTest() { + @TestFactory + fun toStringTest(): List { - PackageScanner.getClassesIn("dev.usbharu.hideout", null, true) + return PackageScanner.getClassesIn("dev.usbharu.hideout", null, true) .filter { it != null && !it.isEnum && !it.isInterface && !Modifier.isAbstract(it.modifiers) } - .forEach { - try { - ToStringVerifier.forClass(it).verify() - } catch (e: AssertionError) { - println(it.name) - e.printStackTrace() - } catch (e: Exception) { - println(it.name) - e.printStackTrace() + .filter { + val clazz = it.getMethod(it::toString.name).declaringClass + clazz != Any::class.java && clazz != Throwable::class.java + } + .filter { + it.superclass == Any::class.java || it.superclass?.packageName?.startsWith("dev.usbharu") ?: true + } + .map { + + dynamicTest(it.name) { + if (it.isKotlinClass()) { + println(" at ${it.name}.toString(${it.simpleName}.kt:1)") + } + try { + ToStringVerifier.forClass(it).withPreset(Presets.INTELLI_J).verify() + } catch (e: Exception) { + e.printStackTrace() + } } } } diff --git a/src/test/kotlin/dev/usbharu/hideout/activitypub/domain/model/CreateTest.kt b/src/test/kotlin/dev/usbharu/hideout/activitypub/domain/model/CreateTest.kt new file mode 100644 index 00000000..1baf4e45 --- /dev/null +++ b/src/test/kotlin/dev/usbharu/hideout/activitypub/domain/model/CreateTest.kt @@ -0,0 +1,83 @@ +package dev.usbharu.hideout.activitypub.domain.model + +import com.fasterxml.jackson.module.kotlin.readValue +import dev.usbharu.hideout.application.config.ActivityPubConfig +import org.intellij.lang.annotations.Language +import org.junit.jupiter.api.Test + +class CreateTest { + @Test + fun Createのデイシリアライズができる() { + @Language("JSON") val json = """{ + "@context": [ + "https://www.w3.org/ns/activitystreams", + "https://w3id.org/security/v1", + { + "manuallyApprovesFollowers": "as:manuallyApprovesFollowers", + "sensitive": "as:sensitive", + "Hashtag": "as:Hashtag", + "quoteUrl": "as:quoteUrl", + "toot": "http://joinmastodon.org/ns#", + "Emoji": "toot:Emoji", + "featured": "toot:featured", + "discoverable": "toot:discoverable", + "schema": "http://schema.org#", + "PropertyValue": "schema:PropertyValue", + "value": "schema:value", + "misskey": "https://misskey-hub.net/ns#", + "_misskey_content": "misskey:_misskey_content", + "_misskey_quote": "misskey:_misskey_quote", + "_misskey_reaction": "misskey:_misskey_reaction", + "_misskey_votes": "misskey:_misskey_votes", + "isCat": "misskey:isCat", + "vcard": "http://www.w3.org/2006/vcard/ns#" + } + ], + "id": "https://misskey.usbharu.dev/notes/9f2i9cm88e/activity", + "actor": "https://misskey.usbharu.dev/users/97ws8y3rj6", + "type": "Create", + "published": "2023-05-22T14:26:53.600Z", + "object": { + "id": "https://misskey.usbharu.dev/notes/9f2i9cm88e", + "type": "Note", + "attributedTo": "https://misskey.usbharu.dev/users/97ws8y3rj6", + "content": "

@trapezial@calckey.jp いやそういうことじゃなくて、連合先と自インスタンスで状態が狂うことが多いのでどっちに合わせるべきかと…

", + "_misskey_content": "@trapezial@calckey.jp いやそういうことじゃなくて、連合先と自インスタンスで状態が狂うことが多いのでどっちに合わせるべきかと…", + "source": { + "content": "@trapezial@calckey.jp いやそういうことじゃなくて、連合先と自インスタンスで状態が狂うことが多いのでどっちに合わせるべきかと…", + "mediaType": "text/x.misskeymarkdown" + }, + "published": "2023-05-22T14:26:53.600Z", + "to": [ + "https://misskey.usbharu.dev/users/97ws8y3rj6/followers" + ], + "cc": [ + "https://www.w3.org/ns/activitystreams#Public", + "https://calckey.jp/users/9bu1xzwjyb" + ], + "inReplyTo": "https://calckey.jp/notes/9f2i7ymf1d", + "attachment": [], + "sensitive": false, + "tag": [ + { + "type": "Mention", + "href": "https://calckey.jp/users/9bu1xzwjyb", + "name": "@trapezial@calckey.jp" + } + ] + }, + "to": [ + "https://misskey.usbharu.dev/users/97ws8y3rj6/followers" + ], + "cc": [ + "https://www.w3.org/ns/activitystreams#Public", + "https://calckey.jp/users/9bu1xzwjyb" + ] +} +""" + + val objectMapper = ActivityPubConfig().objectMapper() + + objectMapper.readValue(json) + } +} diff --git a/src/test/kotlin/dev/usbharu/hideout/activitypub/domain/model/DocumentTest.kt b/src/test/kotlin/dev/usbharu/hideout/activitypub/domain/model/DocumentTest.kt new file mode 100644 index 00000000..5257d8e8 --- /dev/null +++ b/src/test/kotlin/dev/usbharu/hideout/activitypub/domain/model/DocumentTest.kt @@ -0,0 +1,37 @@ +package dev.usbharu.hideout.activitypub.domain.model + +import com.fasterxml.jackson.module.kotlin.readValue +import dev.usbharu.hideout.application.config.ActivityPubConfig +import org.intellij.lang.annotations.Language +import org.junit.jupiter.api.Test + +class DocumentTest { + @Test + fun Documentをデシリアライズできる() { + @Language("JSON") val json = """{ + "type": "Document", + "mediaType": "image/webp", + "url": "https://s3misskey.usbharu.dev/misskey-minio/misskey-minio/data/81ec9ad1-2581-466e-b90c-d9d2350ab95c.webp", + "name": "ALTテスト" + }""" + + val objectMapper = ActivityPubConfig().objectMapper() + + objectMapper.readValue(json) + } + + @Test + fun nameがnullなDocumentのデイシリアライズができる() { + //language=JSON + val json = """{ + "type": "Document", + "mediaType": "image/webp", + "url": "https://s3misskey.usbharu.dev/misskey-minio/misskey-minio/data/81ec9ad1-2581-466e-b90c-d9d2350ab95c.webp", + "name": null + }""" + + val objectMapper = ActivityPubConfig().objectMapper() + + objectMapper.readValue(json) + } +} diff --git a/src/test/kotlin/dev/usbharu/hideout/activitypub/domain/model/PersonSerializeTest.kt b/src/test/kotlin/dev/usbharu/hideout/activitypub/domain/model/PersonSerializeTest.kt index 9b344337..15c7e506 100644 --- a/src/test/kotlin/dev/usbharu/hideout/activitypub/domain/model/PersonSerializeTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/activitypub/domain/model/PersonSerializeTest.kt @@ -72,4 +72,68 @@ class PersonSerializeTest { val readValue = objectMapper.readValue(personString) } + + @Test + fun MisskeyのnameがnullのPersonのデシリアライズができる() { + //language=JSON + val json = """{ + "@context": [ + "https://www.w3.org/ns/activitystreams", + "https://w3id.org/security/v1", + { + "manuallyApprovesFollowers": "as:manuallyApprovesFollowers", + "sensitive": "as:sensitive", + "Hashtag": "as:Hashtag", + "quoteUrl": "as:quoteUrl", + "toot": "http://joinmastodon.org/ns#", + "Emoji": "toot:Emoji", + "featured": "toot:featured", + "discoverable": "toot:discoverable", + "schema": "http://schema.org#", + "PropertyValue": "schema:PropertyValue", + "value": "schema:value", + "misskey": "https://misskey-hub.net/ns#", + "_misskey_content": "misskey:_misskey_content", + "_misskey_quote": "misskey:_misskey_quote", + "_misskey_reaction": "misskey:_misskey_reaction", + "_misskey_votes": "misskey:_misskey_votes", + "_misskey_summary": "misskey:_misskey_summary", + "isCat": "misskey:isCat", + "vcard": "http://www.w3.org/2006/vcard/ns#" + } + ], + "type": "Person", + "id": "https://misskey.usbharu.dev/users/9ghwhv9zgg", + "inbox": "https://misskey.usbharu.dev/users/9ghwhv9zgg/inbox", + "outbox": "https://misskey.usbharu.dev/users/9ghwhv9zgg/outbox", + "followers": "https://misskey.usbharu.dev/users/9ghwhv9zgg/followers", + "following": "https://misskey.usbharu.dev/users/9ghwhv9zgg/following", + "featured": "https://misskey.usbharu.dev/users/9ghwhv9zgg/collections/featured", + "sharedInbox": "https://misskey.usbharu.dev/inbox", + "endpoints": { + "sharedInbox": "https://misskey.usbharu.dev/inbox" + }, + "url": "https://misskey.usbharu.dev/@relay_test", + "preferredUsername": "relay_test", + "name": null, + "summary": null, + "_misskey_summary": null, + "icon": null, + "image": null, + "tag": [], + "manuallyApprovesFollowers": true, + "discoverable": true, + "publicKey": { + "id": "https://misskey.usbharu.dev/users/9ghwhv9zgg#main-key", + "type": "Key", + "owner": "https://misskey.usbharu.dev/users/9ghwhv9zgg", + "publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA2n5yekTaI4ex5VDWzQfE\nJpWMURAMWl8RcXHLPyLQVQ/PrHp7qatGXmKJUnAOBcq1cwk+VCqTEqx8vJCOZsr1\nMq+D3FMcFdwgtJ0nivPJPx2457b5kfQ4LTkWajcFhj2qixa/XFq6hHei3LDaE6hJ\nGQbdj9NTVlMd7VpiFQkoU09vAPUwGxRoP9Qbc/sh7jrKYFB3iRmY/+zOc+PFpnfn\nG8V1d2v+lnkb9f7t0Z8y2ckk6TVcLPRZktF15eGClVptlgts3hwhrcyrpBs2Dn0U\n35KgIhkhZGAjzk0uyplpfKcserXuGvsjJvelZ3BtMGsuR4kGLHrmiRQp23mIoA1I\n8tfVuV0zPOyO3ruLk2fOjoeZ4XvFHGRNKo66Qx055/8G8Ug5vU8lvIGXm9sflaA9\ntR3AKDNsyxEfjAfrfgJ7cwlKSlLZmkU51jtYEqJ48ZkiIa6fMC0m4QGXdaXmhFWC\no1sGoIErRFpRHewdGlLC9S8R/cMxjex+n8maF0yh79y7aVvU+TS6pRWg5wYjY8r3\nZqAVg/PGRVGAbjVdIdcsjH5ClwAFBW16S633D3m7HJypwwVCzVOvMZqPqcQ/2o8c\nUk+xa88xQG+OPqoAaQqyV9iqsmCMgYM/AcX/BC2h7L2mE/PWoXnoCxGPxr5uvyBf\nHQakDGg4pFZcpVNrDlYo260CAwEAAQ==\n-----END PUBLIC KEY-----\n" + }, + "isCat": false +}""" + + val objectMapper = ActivityPubConfig().objectMapper() + + objectMapper.readValue(json) + } } From ec848630ca5382d8f2146a12168b5dde61c7f369 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Thu, 14 Dec 2023 14:37:59 +0900 Subject: [PATCH 2/8] =?UTF-8?q?fix:=20toString=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../activitypub/domain/model/Delete.kt | 13 +++++- .../hideout/activitypub/domain/model/Emoji.kt | 12 +++++- .../activitypub/domain/model/Follow.kt | 10 ++++- .../hideout/activitypub/domain/model/Undo.kt | 13 +++++- .../hideout/core/domain/model/actor/Actor.kt | 42 +++++++++++-------- .../httpsignature/HttpSignatureUser.kt | 10 +++++ .../springframework/oauth2/UserDetailsImpl.kt | 9 ++++ .../interfaces/api/status/StatusesRequest.kt | 15 +++++-- .../dev/usbharu/hideout/util/LruCache.kt | 7 ++++ 9 files changed, 104 insertions(+), 27 deletions(-) diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Delete.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Delete.kt index 6f691492..f812b32a 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Delete.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Delete.kt @@ -50,6 +50,15 @@ open class Delete : Object, HasId, HasActor { return result } - override fun toString(): String = - "Delete(`object`=$apObject, published=$published, actor='$actor', id='$id') ${super.toString()}" + override fun toString(): String { + return "Delete(" + + "apObject=$apObject, " + + "published='$published', " + + "actor='$actor', " + + "id='$id'" + + ")" + + " ${super.toString()}" + } + + } diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Emoji.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Emoji.kt index 37ebb879..a856e9a3 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Emoji.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Emoji.kt @@ -30,5 +30,15 @@ open class Emoji( return result } - override fun toString(): String = "Emoji(updated=$updated, icon=$icon) ${super.toString()}" + override fun toString(): String { + return "Emoji(" + + "name='$name', " + + "id='$id', " + + "updated='$updated', " + + "icon=$icon" + + ")" + + " ${super.toString()}" + } + + } diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Follow.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Follow.kt index c7f292ba..536d38b2 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Follow.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Follow.kt @@ -32,5 +32,13 @@ open class Follow( return result } - override fun toString(): String = "Follow(`object`=$apObject, actor='$actor') ${super.toString()}" + override fun toString(): String { + return "Follow(" + + "apObject='$apObject', " + + "actor='$actor'" + + ")" + + " ${super.toString()}" + } + + } diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Undo.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Undo.kt index b1399777..6ec8e44e 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Undo.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Undo.kt @@ -38,6 +38,15 @@ open class Undo( return result } - override fun toString(): String = - "Undo(`object`=$apObject, published=$published, actor='$actor', id='$id') ${super.toString()}" + override fun toString(): String { + return "Undo(" + + "actor='$actor', " + + "id='$id', " + + "apObject=$apObject, " + + "published='$published'" + + ")" + + " ${super.toString()}" + } + + } diff --git a/src/main/kotlin/dev/usbharu/hideout/core/domain/model/actor/Actor.kt b/src/main/kotlin/dev/usbharu/hideout/core/domain/model/actor/Actor.kt index 3833e71a..31dc4c6a 100644 --- a/src/main/kotlin/dev/usbharu/hideout/core/domain/model/actor/Actor.kt +++ b/src/main/kotlin/dev/usbharu/hideout/core/domain/model/actor/Actor.kt @@ -181,25 +181,31 @@ data class Actor private constructor( fun decrementPostsCount(): Actor = this.copy(postsCount = this.postsCount - 1) fun withLastPostAt(lastPostDate: Instant): Actor = this.copy(lastPostDate = lastPostDate) - + override fun toString(): String { return "Actor(" + - "id=$id, " + - "name='$name', " + - "domain='$domain', " + - "screenName='$screenName', " + - "description='$description', " + - "inbox='$inbox', " + - "outbox='$outbox', " + - "url='$url', " + - "publicKey='$publicKey', " + - "privateKey=$privateKey, " + - "createdAt=$createdAt, " + - "keyId='$keyId', " + - "followers=$followers, " + - "following=$following, " + - "instance=$instance, " + - "locked=$locked" + - ")" + "id=$id, " + + "name='$name', " + + "domain='$domain', " + + "screenName='$screenName', " + + "description='$description', " + + "inbox='$inbox', " + + "outbox='$outbox', " + + "url='$url', " + + "publicKey='$publicKey', " + + "privateKey=$privateKey, " + + "createdAt=$createdAt, " + + "keyId='$keyId', " + + "followers=$followers, " + + "following=$following, " + + "instance=$instance, " + + "locked=$locked, " + + "followersCount=$followersCount, " + + "followingCount=$followingCount, " + + "postsCount=$postsCount, " + + "lastPostDate=$lastPostDate" + + ")" } + + } diff --git a/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/httpsignature/HttpSignatureUser.kt b/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/httpsignature/HttpSignatureUser.kt index 8beb4513..1b2a33a8 100644 --- a/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/httpsignature/HttpSignatureUser.kt +++ b/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/httpsignature/HttpSignatureUser.kt @@ -39,8 +39,18 @@ class HttpSignatureUser( return result } + override fun toString(): String { + return "HttpSignatureUser(" + + "domain='$domain', " + + "id=$id" + + ")" + + " ${super.toString()}" + } + companion object { @Serial private const val serialVersionUID: Long = -3330552099960982997L } + + } diff --git a/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/oauth2/UserDetailsImpl.kt b/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/oauth2/UserDetailsImpl.kt index 92b007da..dbd4e542 100644 --- a/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/oauth2/UserDetailsImpl.kt +++ b/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/oauth2/UserDetailsImpl.kt @@ -30,6 +30,15 @@ class UserDetailsImpl( @Serial private const val serialVersionUID: Long = -899168205656607781L } + + override fun toString(): String { + return "UserDetailsImpl(" + + "id=$id" + + ")" + + " ${super.toString()}" + } + + } @JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY) diff --git a/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/status/StatusesRequest.kt b/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/status/StatusesRequest.kt index 98803f6b..a8cb0ec9 100644 --- a/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/status/StatusesRequest.kt +++ b/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/status/StatusesRequest.kt @@ -65,11 +65,20 @@ class StatusesRequest { } override fun toString(): String { - return "StatusesRequest(status=$status, mediaIds=$media_ids, poll=$poll, inReplyToId=$in_reply_to_id, " + - "sensitive=$sensitive, spoilerText=$spoiler_text, visibility=$visibility, language=$language," + - " scheduledAt=$scheduled_at)" + return "StatusesRequest(" + + "status=$status, " + + "media_ids=$media_ids, " + + "poll=$poll, " + + "in_reply_to_id=$in_reply_to_id, " + + "sensitive=$sensitive, " + + "spoiler_text=$spoiler_text, " + + "visibility=$visibility, " + + "language=$language, " + + "scheduled_at=$scheduled_at" + + ")" } + @Suppress("EnumNaming", "EnumEntryNameCase") enum class Visibility { `public`, diff --git a/src/main/kotlin/dev/usbharu/hideout/util/LruCache.kt b/src/main/kotlin/dev/usbharu/hideout/util/LruCache.kt index 3f65175a..e62469a0 100644 --- a/src/main/kotlin/dev/usbharu/hideout/util/LruCache.kt +++ b/src/main/kotlin/dev/usbharu/hideout/util/LruCache.kt @@ -5,6 +5,13 @@ import java.io.Serial class LruCache(private val maxSize: Int) : LinkedHashMap(15, 0.75f, true) { override fun removeEldestEntry(eldest: MutableMap.MutableEntry?): Boolean = size > maxSize + override fun toString(): String { + return "LruCache(" + + "maxSize=$maxSize" + + ")" + + " ${super.toString()}" + } + companion object { @Serial From e8b6b6784cd7355bac06e5b3e41a9533fb493d85 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Thu, 14 Dec 2023 15:50:01 +0900 Subject: [PATCH 3/8] =?UTF-8?q?test:=20Equals=E3=81=AE=E3=83=86=E3=82=B9?= =?UTF-8?q?=E3=83=88=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usbharu/hideout/EqualsAndToStringTest.kt | 78 ++++++++++++++++--- 1 file changed, 67 insertions(+), 11 deletions(-) diff --git a/src/test/kotlin/dev/usbharu/hideout/EqualsAndToStringTest.kt b/src/test/kotlin/dev/usbharu/hideout/EqualsAndToStringTest.kt index c9156b3f..11360eb6 100644 --- a/src/test/kotlin/dev/usbharu/hideout/EqualsAndToStringTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/EqualsAndToStringTest.kt @@ -8,21 +8,77 @@ import nl.jqno.equalsverifier.Warning import nl.jqno.equalsverifier.internal.reflection.PackageScanner import org.junit.jupiter.api.DynamicTest import org.junit.jupiter.api.DynamicTest.dynamicTest -import org.junit.jupiter.api.Test import org.junit.jupiter.api.TestFactory +import org.springframework.context.annotation.Configuration +import org.springframework.stereotype.Component +import org.springframework.stereotype.Controller +import org.springframework.stereotype.Repository +import org.springframework.stereotype.Service +import org.springframework.web.bind.annotation.RestController import java.lang.reflect.Modifier -import kotlin.test.assertFails class EqualsAndToStringTest { - @Test - fun equalsTest() { - assertFails { - EqualsVerifier - .simple() - .suppress(Warning.INHERITED_DIRECTLY_FROM_OBJECT) - .forPackage("dev.usbharu.hideout", true) - .verify() - } + @TestFactory + fun equalsTest(): List { + + val classes = PackageScanner.getClassesIn("dev.usbharu.hideout", null, true) + + return classes + .asSequence() + .filter { + it.getAnnotation(Service::class.java) == null + } + .filter { + it.getAnnotation(Repository::class.java) == null + } + .filter { + it.getAnnotation(Component::class.java) == null + } + .filter { + it.getAnnotation(Controller::class.java) == null + } + .filter { + it.getAnnotation(RestController::class.java) == null + } + .filter { + it.getAnnotation(Configuration::class.java) == null + } + .filterNot { + it.packageName.startsWith("dev.usbharu.hideout.domain.mastodon.model.generated") + } + .filterNot { + Throwable::class.java.isAssignableFrom(it) + } + .filterNot { + Modifier.isAbstract(it.modifiers) + } + .filter { + try { + it.kotlin.objectInstance == null + } catch (_: Exception) { + true + } + + } + .filter { + it.superclass == Any::class.java || it.superclass?.packageName?.startsWith("dev.usbharu") ?: true + } + .map { + dynamicTest(it.name) { + if (it.isKotlinClass()) { + println(" at ${it.name}.toString(${it.simpleName}.kt:1)") + } + try { + EqualsVerifier.simple() + .suppress(Warning.INHERITED_DIRECTLY_FROM_OBJECT, Warning.TRANSIENT_FIELDS) + .forClass(it) + .verify() + } catch (e: AssertionError) { + e.printStackTrace() + } + } + } + .toList() } @TestFactory From 3eb310f3069f60582e797e7e5ee759daf0be6182 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Thu, 14 Dec 2023 15:50:19 +0900 Subject: [PATCH 4/8] =?UTF-8?q?fix:=20equals=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hideout/activitypub/domain/model/Emoji.kt | 39 +++++++----- .../common/APResourceResolveServiceImpl.kt | 15 +++++ .../service/id/SnowflakeIdGenerateService.kt | 23 +++++++ .../core/domain/model/instance/Nodeinfo.kt | 33 ++++++++++ .../core/domain/model/instance/Nodeinfo2_0.kt | 57 +++++++++++++++++ .../HttpSignatureVerifierComposite.kt | 20 ++++++ .../springframework/oauth2/UserDetailsImpl.kt | 16 +++++ .../hideout/core/service/media/SavedMedia.kt | 63 ++++++++++++++++++- .../service/resource/KtorResolveResponse.kt | 21 +++++++ .../dev/usbharu/hideout/util/TempFileUtil.kt | 15 +++++ 10 files changed, 284 insertions(+), 18 deletions(-) diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Emoji.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Emoji.kt index a856e9a3..02fd2308 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Emoji.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Emoji.kt @@ -14,21 +14,6 @@ open class Emoji( HasName, HasId { - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is Emoji) return false - if (!super.equals(other)) return false - - if (updated != other.updated) return false - return icon == other.icon - } - - override fun hashCode(): Int { - var result = super.hashCode() - result = 31 * result + updated.hashCode() - result = 31 * result + icon.hashCode() - return result - } override fun toString(): String { return "Emoji(" + @@ -40,5 +25,29 @@ open class Emoji( " ${super.toString()}" } + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + if (!super.equals(other)) return false + + other as Emoji + + if (name != other.name) return false + if (id != other.id) return false + if (updated != other.updated) return false + if (icon != other.icon) return false + + return true + } + + override fun hashCode(): Int { + var result = super.hashCode() + result = 31 * result + name.hashCode() + result = 31 * result + id.hashCode() + result = 31 * result + updated.hashCode() + result = 31 * result + icon.hashCode() + return result + } + } diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/service/common/APResourceResolveServiceImpl.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/service/common/APResourceResolveServiceImpl.kt index ad24ec57..b82d9df3 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/service/common/APResourceResolveServiceImpl.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/service/common/APResourceResolveServiceImpl.kt @@ -73,5 +73,20 @@ class APResourceResolveServiceImpl( override suspend fun statusMessage(): String { TODO("Not yet implemented") } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as APResolveResponse<*> + + return objects == other.objects + } + + override fun hashCode(): Int { + return objects.hashCode() + } + + } } diff --git a/src/main/kotlin/dev/usbharu/hideout/application/service/id/SnowflakeIdGenerateService.kt b/src/main/kotlin/dev/usbharu/hideout/application/service/id/SnowflakeIdGenerateService.kt index dc5ab4bc..c9174a22 100644 --- a/src/main/kotlin/dev/usbharu/hideout/application/service/id/SnowflakeIdGenerateService.kt +++ b/src/main/kotlin/dev/usbharu/hideout/application/service/id/SnowflakeIdGenerateService.kt @@ -43,4 +43,27 @@ open class SnowflakeIdGenerateService(private val baseTime: Long) : IdGenerateSe } private fun getTime(): Long = Instant.now().toEpochMilli() + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as SnowflakeIdGenerateService + + if (baseTime != other.baseTime) return false + if (lastTimeStamp != other.lastTimeStamp) return false + if (sequenceId != other.sequenceId) return false + if (mutex != other.mutex) return false + + return true + } + + override fun hashCode(): Int { + var result = baseTime.hashCode() + result = 31 * result + lastTimeStamp.hashCode() + result = 31 * result + sequenceId + result = 31 * result + mutex.hashCode() + return result + } + + } diff --git a/src/main/kotlin/dev/usbharu/hideout/core/domain/model/instance/Nodeinfo.kt b/src/main/kotlin/dev/usbharu/hideout/core/domain/model/instance/Nodeinfo.kt index f7fc3160..d22a3913 100644 --- a/src/main/kotlin/dev/usbharu/hideout/core/domain/model/instance/Nodeinfo.kt +++ b/src/main/kotlin/dev/usbharu/hideout/core/domain/model/instance/Nodeinfo.kt @@ -3,9 +3,42 @@ package dev.usbharu.hideout.core.domain.model.instance class Nodeinfo private constructor() { var links: List = emptyList() + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as Nodeinfo + + return links == other.links + } + + override fun hashCode(): Int { + return links.hashCode() + } + + } class Links private constructor() { var rel: String? = null var href: String? = null + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as Links + + if (rel != other.rel) return false + if (href != other.href) return false + + return true + } + + override fun hashCode(): Int { + var result = rel?.hashCode() ?: 0 + result = 31 * result + (href?.hashCode() ?: 0) + return result + } + + } diff --git a/src/main/kotlin/dev/usbharu/hideout/core/domain/model/instance/Nodeinfo2_0.kt b/src/main/kotlin/dev/usbharu/hideout/core/domain/model/instance/Nodeinfo2_0.kt index 97478228..403ab9d7 100644 --- a/src/main/kotlin/dev/usbharu/hideout/core/domain/model/instance/Nodeinfo2_0.kt +++ b/src/main/kotlin/dev/usbharu/hideout/core/domain/model/instance/Nodeinfo2_0.kt @@ -6,14 +6,71 @@ package dev.usbharu.hideout.core.domain.model.instance class Nodeinfo2_0 { var metadata: Metadata? = null var software: Software? = null + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as Nodeinfo2_0 + + if (metadata != other.metadata) return false + if (software != other.software) return false + + return true + } + + override fun hashCode(): Int { + var result = metadata?.hashCode() ?: 0 + result = 31 * result + (software?.hashCode() ?: 0) + return result + } + + } class Metadata { var nodeName: String? = null var nodeDescription: String? = null + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as Metadata + + if (nodeName != other.nodeName) return false + if (nodeDescription != other.nodeDescription) return false + + return true + } + + override fun hashCode(): Int { + var result = nodeName?.hashCode() ?: 0 + result = 31 * result + (nodeDescription?.hashCode() ?: 0) + return result + } + + } class Software { var name: String? = null var version: String? = null + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as Software + + if (name != other.name) return false + if (version != other.version) return false + + return true + } + + override fun hashCode(): Int { + var result = name?.hashCode() ?: 0 + result = 31 * result + (version?.hashCode() ?: 0) + return result + } + } diff --git a/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/httpsignature/HttpSignatureVerifierComposite.kt b/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/httpsignature/HttpSignatureVerifierComposite.kt index a1203ca1..a8089384 100644 --- a/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/httpsignature/HttpSignatureVerifierComposite.kt +++ b/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/httpsignature/HttpSignatureVerifierComposite.kt @@ -19,4 +19,24 @@ class HttpSignatureVerifierComposite( throw IllegalArgumentException("Unsupported algorithm. ${signature.algorithm}") } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as HttpSignatureVerifierComposite + + if (map != other.map) return false + if (httpSignatureHeaderParser != other.httpSignatureHeaderParser) return false + + return true + } + + override fun hashCode(): Int { + var result = map.hashCode() + result = 31 * result + httpSignatureHeaderParser.hashCode() + return result + } + + } diff --git a/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/oauth2/UserDetailsImpl.kt b/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/oauth2/UserDetailsImpl.kt index dbd4e542..c5639e65 100644 --- a/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/oauth2/UserDetailsImpl.kt +++ b/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/oauth2/UserDetailsImpl.kt @@ -38,6 +38,22 @@ class UserDetailsImpl( " ${super.toString()}" } + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + if (!super.equals(other)) return false + + other as UserDetailsImpl + + return id == other.id + } + + override fun hashCode(): Int { + var result = super.hashCode() + result = 31 * result + id.hashCode() + return result + } + } diff --git a/src/main/kotlin/dev/usbharu/hideout/core/service/media/SavedMedia.kt b/src/main/kotlin/dev/usbharu/hideout/core/service/media/SavedMedia.kt index 4f644da5..50a2caac 100644 --- a/src/main/kotlin/dev/usbharu/hideout/core/service/media/SavedMedia.kt +++ b/src/main/kotlin/dev/usbharu/hideout/core/service/media/SavedMedia.kt @@ -1,16 +1,73 @@ package dev.usbharu.hideout.core.service.media -sealed class SavedMedia(val success: Boolean) +sealed class SavedMedia(val success: Boolean) { + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as SavedMedia + + return success == other.success + } + + override fun hashCode(): Int { + return success.hashCode() + } +} class SuccessSavedMedia( val name: String, val url: String, val thumbnailUrl: String, ) : - SavedMedia(true) + SavedMedia(true) { + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + if (!super.equals(other)) return false + + other as SuccessSavedMedia + + if (name != other.name) return false + if (url != other.url) return false + if (thumbnailUrl != other.thumbnailUrl) return false + + return true + } + + override fun hashCode(): Int { + var result = super.hashCode() + result = 31 * result + name.hashCode() + result = 31 * result + url.hashCode() + result = 31 * result + thumbnailUrl.hashCode() + return result + } +} class FaildSavedMedia( val reason: String, val description: String, val trace: Throwable? = null -) : SavedMedia(false) +) : SavedMedia(false) { + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + if (!super.equals(other)) return false + + other as FaildSavedMedia + + if (reason != other.reason) return false + if (description != other.description) return false + if (trace != other.trace) return false + + return true + } + + override fun hashCode(): Int { + var result = super.hashCode() + result = 31 * result + reason.hashCode() + result = 31 * result + description.hashCode() + result = 31 * result + (trace?.hashCode() ?: 0) + return result + } +} diff --git a/src/main/kotlin/dev/usbharu/hideout/core/service/resource/KtorResolveResponse.kt b/src/main/kotlin/dev/usbharu/hideout/core/service/resource/KtorResolveResponse.kt index 3a5e2ad1..d4f20045 100644 --- a/src/main/kotlin/dev/usbharu/hideout/core/service/resource/KtorResolveResponse.kt +++ b/src/main/kotlin/dev/usbharu/hideout/core/service/resource/KtorResolveResponse.kt @@ -28,4 +28,25 @@ class KtorResolveResponse(val ktorHttpResponse: HttpResponse) : ResolveResponse override suspend fun header(): Map> = ktorHttpResponse.headers.toMap() override suspend fun status(): Int = ktorHttpResponse.status.value override suspend fun statusMessage(): String = ktorHttpResponse.status.description + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as KtorResolveResponse + + if (ktorHttpResponse != other.ktorHttpResponse) return false + if (_bodyAsText != other._bodyAsText) return false + if (!_bodyAsBytes.contentEquals(other._bodyAsBytes)) return false + + return true + } + + override fun hashCode(): Int { + var result = ktorHttpResponse.hashCode() + result = 31 * result + _bodyAsText.hashCode() + result = 31 * result + _bodyAsBytes.contentHashCode() + return result + } + + } diff --git a/src/main/kotlin/dev/usbharu/hideout/util/TempFileUtil.kt b/src/main/kotlin/dev/usbharu/hideout/util/TempFileUtil.kt index 186aa889..6a8fbdcd 100644 --- a/src/main/kotlin/dev/usbharu/hideout/util/TempFileUtil.kt +++ b/src/main/kotlin/dev/usbharu/hideout/util/TempFileUtil.kt @@ -9,4 +9,19 @@ class TempFile(val path: T) : AutoCloseable { override fun close() { path?.let { Files.deleteIfExists(it) } } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as TempFile<*> + + return path == other.path + } + + override fun hashCode(): Int { + return path?.hashCode() ?: 0 + } + + } From bccd16d9da96aa7a8c363599252343d1f4d843c7 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Thu, 14 Dec 2023 16:05:26 +0900 Subject: [PATCH 5/8] =?UTF-8?q?chore:=20=E3=82=AB=E3=83=90=E3=83=AC?= =?UTF-8?q?=E3=83=83=E3=82=B8=E8=A8=88=E6=B8=AC=E3=81=A7=E3=82=AD=E3=83=A3?= =?UTF-8?q?=E3=83=83=E3=82=B7=E3=83=A5=E3=82=92=E4=BD=BF=E3=82=8F=E3=81=AA?= =?UTF-8?q?=E3=81=84=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/pull-request-merge-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request-merge-check.yml b/.github/workflows/pull-request-merge-check.yml index 7d1a26f2..c66db522 100644 --- a/.github/workflows/pull-request-merge-check.yml +++ b/.github/workflows/pull-request-merge-check.yml @@ -236,7 +236,7 @@ jobs: - name: Run Kover uses: gradle/gradle-build-action@v2.8.1 with: - arguments: koverXmlReport -x integrationTest -x e2eTest + arguments: koverXmlReport -x integrationTest -x e2eTest --rerun-tasks - name: Add coverage report to PR if: always() From 8a064b9e33d323d7d3130d4e486dfcfefaca418e Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Thu, 14 Dec 2023 16:20:10 +0900 Subject: [PATCH 6/8] =?UTF-8?q?chore:=20=E3=82=AB=E3=83=90=E3=83=AC?= =?UTF-8?q?=E3=83=83=E3=82=B8=E3=83=AC=E3=83=9D=E3=83=BC=E3=83=88=E3=82=92?= =?UTF-8?q?=E4=BD=9C=E6=88=90=E3=81=99=E3=82=8BGitHub=20Action=E3=82=92?= =?UTF-8?q?=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/pull-request-merge-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request-merge-check.yml b/.github/workflows/pull-request-merge-check.yml index c66db522..8647e26e 100644 --- a/.github/workflows/pull-request-merge-check.yml +++ b/.github/workflows/pull-request-merge-check.yml @@ -241,7 +241,7 @@ jobs: - name: Add coverage report to PR if: always() id: kover - uses: mi-kas/kover-report@v1 + uses: madrapps/jacoco-report@v1.6.1 with: path: | ${{ github.workspace }}/build/reports/kover/report.xml From 11d82e7fbf1c50974a990be18b042c761e54a4e1 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Thu, 14 Dec 2023 16:24:50 +0900 Subject: [PATCH 7/8] =?UTF-8?q?chore:=20=E3=82=AB=E3=83=90=E3=83=AC?= =?UTF-8?q?=E3=83=83=E3=82=B8=E3=83=AC=E3=83=9D=E3=83=BC=E3=83=88=E3=82=92?= =?UTF-8?q?=E4=BD=9C=E6=88=90=E3=81=99=E3=82=8BGitHub=20Action=E3=82=92?= =?UTF-8?q?=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/pull-request-merge-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request-merge-check.yml b/.github/workflows/pull-request-merge-check.yml index 8647e26e..86dd05bf 100644 --- a/.github/workflows/pull-request-merge-check.yml +++ b/.github/workflows/pull-request-merge-check.yml @@ -243,7 +243,7 @@ jobs: id: kover uses: madrapps/jacoco-report@v1.6.1 with: - path: | + paths: | ${{ github.workspace }}/build/reports/kover/report.xml token: ${{ secrets.GITHUB_TOKEN }} title: Code Coverage From fdf3065953078d3dc9d729f6d032d7edb86b54be Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Thu, 14 Dec 2023 16:44:15 +0900 Subject: [PATCH 8/8] style: fix lint --- .../dev/usbharu/hideout/activitypub/domain/model/Delete.kt | 2 -- .../dev/usbharu/hideout/activitypub/domain/model/Emoji.kt | 3 --- .../dev/usbharu/hideout/activitypub/domain/model/Follow.kt | 2 -- .../dev/usbharu/hideout/activitypub/domain/model/Undo.kt | 2 -- .../service/common/APResourceResolveServiceImpl.kt | 2 -- .../application/service/id/SnowflakeIdGenerateService.kt | 2 -- .../dev/usbharu/hideout/core/domain/model/actor/Actor.kt | 4 +--- .../usbharu/hideout/core/domain/model/instance/Nodeinfo.kt | 4 ---- .../hideout/core/domain/model/instance/Nodeinfo2_0.kt | 5 ----- .../springframework/httpsignature/HttpSignatureUser.kt | 2 -- .../httpsignature/HttpSignatureVerifierComposite.kt | 2 -- .../infrastructure/springframework/oauth2/UserDetailsImpl.kt | 2 -- .../hideout/core/service/resource/KtorResolveResponse.kt | 2 -- .../mastodon/interfaces/api/status/StatusesRequest.kt | 1 - src/main/kotlin/dev/usbharu/hideout/util/LruCache.kt | 1 - src/main/kotlin/dev/usbharu/hideout/util/TempFileUtil.kt | 2 -- 16 files changed, 1 insertion(+), 37 deletions(-) diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Delete.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Delete.kt index f812b32a..61ffb348 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Delete.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Delete.kt @@ -59,6 +59,4 @@ open class Delete : Object, HasId, HasActor { ")" + " ${super.toString()}" } - - } diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Emoji.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Emoji.kt index 02fd2308..2b9a0bee 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Emoji.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Emoji.kt @@ -14,7 +14,6 @@ open class Emoji( HasName, HasId { - override fun toString(): String { return "Emoji(" + "name='$name', " + @@ -48,6 +47,4 @@ open class Emoji( result = 31 * result + icon.hashCode() return result } - - } diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Follow.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Follow.kt index 536d38b2..8a0382a9 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Follow.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Follow.kt @@ -39,6 +39,4 @@ open class Follow( ")" + " ${super.toString()}" } - - } diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Undo.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Undo.kt index 6ec8e44e..178373fd 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Undo.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Undo.kt @@ -47,6 +47,4 @@ open class Undo( ")" + " ${super.toString()}" } - - } diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/service/common/APResourceResolveServiceImpl.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/service/common/APResourceResolveServiceImpl.kt index b82d9df3..246b02d8 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/service/common/APResourceResolveServiceImpl.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/service/common/APResourceResolveServiceImpl.kt @@ -86,7 +86,5 @@ class APResourceResolveServiceImpl( override fun hashCode(): Int { return objects.hashCode() } - - } } diff --git a/src/main/kotlin/dev/usbharu/hideout/application/service/id/SnowflakeIdGenerateService.kt b/src/main/kotlin/dev/usbharu/hideout/application/service/id/SnowflakeIdGenerateService.kt index c9174a22..54288173 100644 --- a/src/main/kotlin/dev/usbharu/hideout/application/service/id/SnowflakeIdGenerateService.kt +++ b/src/main/kotlin/dev/usbharu/hideout/application/service/id/SnowflakeIdGenerateService.kt @@ -64,6 +64,4 @@ open class SnowflakeIdGenerateService(private val baseTime: Long) : IdGenerateSe result = 31 * result + mutex.hashCode() return result } - - } diff --git a/src/main/kotlin/dev/usbharu/hideout/core/domain/model/actor/Actor.kt b/src/main/kotlin/dev/usbharu/hideout/core/domain/model/actor/Actor.kt index 31dc4c6a..6689e542 100644 --- a/src/main/kotlin/dev/usbharu/hideout/core/domain/model/actor/Actor.kt +++ b/src/main/kotlin/dev/usbharu/hideout/core/domain/model/actor/Actor.kt @@ -181,7 +181,7 @@ data class Actor private constructor( fun decrementPostsCount(): Actor = this.copy(postsCount = this.postsCount - 1) fun withLastPostAt(lastPostDate: Instant): Actor = this.copy(lastPostDate = lastPostDate) - + override fun toString(): String { return "Actor(" + "id=$id, " + @@ -206,6 +206,4 @@ data class Actor private constructor( "lastPostDate=$lastPostDate" + ")" } - - } diff --git a/src/main/kotlin/dev/usbharu/hideout/core/domain/model/instance/Nodeinfo.kt b/src/main/kotlin/dev/usbharu/hideout/core/domain/model/instance/Nodeinfo.kt index d22a3913..e2e44267 100644 --- a/src/main/kotlin/dev/usbharu/hideout/core/domain/model/instance/Nodeinfo.kt +++ b/src/main/kotlin/dev/usbharu/hideout/core/domain/model/instance/Nodeinfo.kt @@ -15,8 +15,6 @@ class Nodeinfo private constructor() { override fun hashCode(): Int { return links.hashCode() } - - } class Links private constructor() { @@ -39,6 +37,4 @@ class Links private constructor() { result = 31 * result + (href?.hashCode() ?: 0) return result } - - } diff --git a/src/main/kotlin/dev/usbharu/hideout/core/domain/model/instance/Nodeinfo2_0.kt b/src/main/kotlin/dev/usbharu/hideout/core/domain/model/instance/Nodeinfo2_0.kt index 403ab9d7..f3f5f72e 100644 --- a/src/main/kotlin/dev/usbharu/hideout/core/domain/model/instance/Nodeinfo2_0.kt +++ b/src/main/kotlin/dev/usbharu/hideout/core/domain/model/instance/Nodeinfo2_0.kt @@ -23,8 +23,6 @@ class Nodeinfo2_0 { result = 31 * result + (software?.hashCode() ?: 0) return result } - - } class Metadata { @@ -47,8 +45,6 @@ class Metadata { result = 31 * result + (nodeDescription?.hashCode() ?: 0) return result } - - } class Software { @@ -72,5 +68,4 @@ class Software { result = 31 * result + (version?.hashCode() ?: 0) return result } - } diff --git a/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/httpsignature/HttpSignatureUser.kt b/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/httpsignature/HttpSignatureUser.kt index 1b2a33a8..2d546af0 100644 --- a/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/httpsignature/HttpSignatureUser.kt +++ b/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/httpsignature/HttpSignatureUser.kt @@ -51,6 +51,4 @@ class HttpSignatureUser( @Serial private const val serialVersionUID: Long = -3330552099960982997L } - - } diff --git a/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/httpsignature/HttpSignatureVerifierComposite.kt b/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/httpsignature/HttpSignatureVerifierComposite.kt index a8089384..4496e0b5 100644 --- a/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/httpsignature/HttpSignatureVerifierComposite.kt +++ b/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/httpsignature/HttpSignatureVerifierComposite.kt @@ -37,6 +37,4 @@ class HttpSignatureVerifierComposite( result = 31 * result + httpSignatureHeaderParser.hashCode() return result } - - } diff --git a/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/oauth2/UserDetailsImpl.kt b/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/oauth2/UserDetailsImpl.kt index c5639e65..cb06f2ce 100644 --- a/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/oauth2/UserDetailsImpl.kt +++ b/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/oauth2/UserDetailsImpl.kt @@ -53,8 +53,6 @@ class UserDetailsImpl( result = 31 * result + id.hashCode() return result } - - } @JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY) diff --git a/src/main/kotlin/dev/usbharu/hideout/core/service/resource/KtorResolveResponse.kt b/src/main/kotlin/dev/usbharu/hideout/core/service/resource/KtorResolveResponse.kt index d4f20045..66b8ba85 100644 --- a/src/main/kotlin/dev/usbharu/hideout/core/service/resource/KtorResolveResponse.kt +++ b/src/main/kotlin/dev/usbharu/hideout/core/service/resource/KtorResolveResponse.kt @@ -47,6 +47,4 @@ class KtorResolveResponse(val ktorHttpResponse: HttpResponse) : ResolveResponse result = 31 * result + _bodyAsBytes.contentHashCode() return result } - - } diff --git a/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/status/StatusesRequest.kt b/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/status/StatusesRequest.kt index a8cb0ec9..0a9fac65 100644 --- a/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/status/StatusesRequest.kt +++ b/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/status/StatusesRequest.kt @@ -78,7 +78,6 @@ class StatusesRequest { ")" } - @Suppress("EnumNaming", "EnumEntryNameCase") enum class Visibility { `public`, diff --git a/src/main/kotlin/dev/usbharu/hideout/util/LruCache.kt b/src/main/kotlin/dev/usbharu/hideout/util/LruCache.kt index e62469a0..77c891da 100644 --- a/src/main/kotlin/dev/usbharu/hideout/util/LruCache.kt +++ b/src/main/kotlin/dev/usbharu/hideout/util/LruCache.kt @@ -12,7 +12,6 @@ class LruCache(private val maxSize: Int) : LinkedHashMap(15, 0.75f, " ${super.toString()}" } - companion object { @Serial private const val serialVersionUID: Long = -6446947260925053191L diff --git a/src/main/kotlin/dev/usbharu/hideout/util/TempFileUtil.kt b/src/main/kotlin/dev/usbharu/hideout/util/TempFileUtil.kt index 6a8fbdcd..8a506767 100644 --- a/src/main/kotlin/dev/usbharu/hideout/util/TempFileUtil.kt +++ b/src/main/kotlin/dev/usbharu/hideout/util/TempFileUtil.kt @@ -22,6 +22,4 @@ class TempFile(val path: T) : AutoCloseable { override fun hashCode(): Int { return path?.hashCode() ?: 0 } - - }