From 2e1cee4e1af23a8fd9775878c49241f6ce646993 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Tue, 28 Nov 2023 11:58:30 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20POJO=E3=81=AE=E5=A4=89=E6=9B=B4?= =?UTF-8?q?=E3=82=92=E5=8F=8D=E6=98=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../activitypub/domain/model/Delete.kt | 9 ++---- .../activitypub/domain/model/Document.kt | 28 +++++++----------- .../hideout/activitypub/domain/model/Emoji.kt | 29 +++++++------------ .../hideout/activitypub/domain/model/Undo.kt | 5 ++-- .../model/objects/ObjectDeserializer.kt | 3 -- .../domain/model/objects/ObjectValue.kt | 21 +++++--------- .../exposedquery/NoteQueryServiceImpl.kt | 1 - .../activity/delete/APDeleteProcessor.kt | 7 ++++- .../activity/follow/APSendFollowService.kt | 1 - .../activity/like/ApReactionJobProcessor.kt | 1 - .../like/ApRemoveReactionJobProcessor.kt | 3 +- .../service/objects/user/APUserService.kt | 4 --- .../application/config/ActivityPubConfig.kt | 1 + .../domain/model/DeleteSerializeTest.kt | 4 +-- .../domain/model/NoteSerializeTest.kt | 5 +--- .../activitypub/domain/model/UndoTest.kt | 10 +++---- .../model/objects/ObjectSerializeTest.kt | 15 ++-------- .../api/actor/UserAPControllerImplTest.kt | 2 -- .../api/note/NoteApControllerImplTest.kt | 2 -- .../create/ApSendCreateServiceImplTest.kt | 1 - .../follow/APSendFollowServiceImplTest.kt | 1 - .../common/APRequestServiceImplTest.kt | 14 ++------- .../objects/note/APNoteServiceImplTest.kt | 11 ++----- .../hideout/ap/ContextSerializerTest.kt | 1 - 24 files changed, 56 insertions(+), 123 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 5b867818..10b919c5 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 @@ -4,18 +4,16 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize import dev.usbharu.hideout.activitypub.domain.model.objects.Object import dev.usbharu.hideout.activitypub.domain.model.objects.ObjectDeserializer -open class Delete : Object, HasId, HasActor, HasName { +open class Delete : Object, HasId, HasActor { @JsonDeserialize(using = ObjectDeserializer::class) @Suppress("VariableNaming") var `object`: Object? = null var published: String? = null override val actor: String override val id: String - override val name: String constructor( type: List = emptyList(), - name: String = "Delete", actor: String, id: String, `object`: Object, @@ -23,7 +21,6 @@ open class Delete : Object, HasId, HasActor, HasName { ) : super(add(type, "Delete")) { this.`object` = `object` this.published = published - this.name = name this.actor = actor this.id = id } @@ -39,7 +36,6 @@ open class Delete : Object, HasId, HasActor, HasName { if (published != other.published) return false if (actor != other.actor) return false if (id != other.id) return false - if (name != other.name) return false return true } @@ -50,10 +46,9 @@ open class Delete : Object, HasId, HasActor, HasName { result = 31 * result + (published?.hashCode() ?: 0) result = 31 * result + actor.hashCode() result = 31 * result + id.hashCode() - result = 31 * result + name.hashCode() return result } override fun toString(): String = - "Delete(`object`=$`object`, published=$published, actor='$actor', id='$id', name='$name') ${super.toString()}" + "Delete(`object`=$`object`, published=$published, actor='$actor', id='$id') ${super.toString()}" } diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Document.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Document.kt index 489029d0..480c6011 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Document.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Document.kt @@ -2,24 +2,18 @@ package dev.usbharu.hideout.activitypub.domain.model import dev.usbharu.hideout.activitypub.domain.model.objects.Object -open class Document : Object, HasName { +open class Document( + type: List = emptyList(), + override val name: String = "", + mediaType: String, + url: String +) : Object( + type = add(type, "Document") +), + HasName { - var mediaType: String? = null - var url: String? = null - override val name: String - - constructor( - type: List = emptyList(), - name: String, - mediaType: String, - url: String - ) : super( - type = add(type, "Document") - ) { - this.mediaType = mediaType - this.url = url - this.name = name - } + var mediaType: String? = mediaType + var url: String? = url override fun equals(other: Any?): Boolean { if (this === other) return true 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 c270be48..0a91be60 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 @@ -2,24 +2,17 @@ package dev.usbharu.hideout.activitypub.domain.model import dev.usbharu.hideout.activitypub.domain.model.objects.Object -open class Emoji : Object { - var updated: String? = null - var icon: Image? = null - - protected constructor() : super() - constructor( - type: List, - name: String?, - actor: String?, - id: String?, - updated: String?, - icon: Image? - ) : super( - type = add(type, "Emoji") - ) { - this.updated = updated - this.icon = icon - } +open class Emoji( + type: List, + override val name: String, + override val id: String, + var updated: String?, + var icon: Image? +) : Object( + type = add(type, "Emoji") +), + HasName, + HasId { override fun equals(other: Any?): Boolean { if (this === other) return true 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 f1a0d9d6..857416ef 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 @@ -3,7 +3,6 @@ package dev.usbharu.hideout.activitypub.domain.model import com.fasterxml.jackson.databind.annotation.JsonDeserialize import dev.usbharu.hideout.activitypub.domain.model.objects.Object import dev.usbharu.hideout.activitypub.domain.model.objects.ObjectDeserializer -import java.time.Instant open class Undo : Object, HasId, HasActor { @@ -19,10 +18,10 @@ open class Undo : Object, HasId, HasActor { actor: String, id: String, `object`: Object, - published: Instant + published: String ) : super(add(type, "Undo")) { this.`object` = `object` - this.published = published.toString() + this.published = published this.id = id this.actor = actor } diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/objects/ObjectDeserializer.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/objects/ObjectDeserializer.kt index acbf32e5..f28070e6 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/objects/ObjectDeserializer.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/objects/ObjectDeserializer.kt @@ -15,9 +15,6 @@ class ObjectDeserializer : JsonDeserializer() { if (treeNode.isValueNode) { return ObjectValue( emptyList(), - null, - null, - null, treeNode.asText() ) } else if (treeNode.isObject) { diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/objects/ObjectValue.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/objects/ObjectValue.kt index 2a9c8eef..62ed4344 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/objects/ObjectValue.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/objects/ObjectValue.kt @@ -3,30 +3,25 @@ package dev.usbharu.hideout.activitypub.domain.model.objects import com.fasterxml.jackson.annotation.JsonCreator @Suppress("VariableNaming") -open class ObjectValue : Object { - - lateinit var `object`: String - - @JsonCreator - constructor(type: List) : super( - type - ) { - this.`object` = `object` - } +open class ObjectValue @JsonCreator constructor(type: List, var `object`: String) : Object( + type +) { override fun equals(other: Any?): Boolean { if (this === other) return true - if (other !is ObjectValue) return false + if (javaClass != other?.javaClass) return false if (!super.equals(other)) return false + other as ObjectValue + return `object` == other.`object` } override fun hashCode(): Int { var result = super.hashCode() - result = 31 * result + (`object`?.hashCode() ?: 0) + result = 31 * result + `object`.hashCode() return result } - override fun toString(): String = "ObjectValue(`object`=$`object`) ${super.toString()}" + override fun toString(): String = "ObjectValue(`object`='$`object`') ${super.toString()}" } diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/infrastructure/exposedquery/NoteQueryServiceImpl.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/infrastructure/exposedquery/NoteQueryServiceImpl.kt index 3348f832..561b8de2 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/infrastructure/exposedquery/NoteQueryServiceImpl.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/infrastructure/exposedquery/NoteQueryServiceImpl.kt @@ -64,7 +64,6 @@ class NoteQueryServiceImpl(private val postRepository: PostRepository, private v this[Users.followers] ) return Note( - name = "Post", id = this[Posts.apId], attributedTo = this[Users.url], content = this[Posts.text], diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/delete/APDeleteProcessor.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/delete/APDeleteProcessor.kt index 060dc713..f6f136fa 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/delete/APDeleteProcessor.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/delete/APDeleteProcessor.kt @@ -2,6 +2,7 @@ package dev.usbharu.hideout.activitypub.service.activity.delete import dev.usbharu.hideout.activitypub.domain.exception.IllegalActivityPubObjectException import dev.usbharu.hideout.activitypub.domain.model.Delete +import dev.usbharu.hideout.activitypub.domain.model.HasId import dev.usbharu.hideout.activitypub.service.common.AbstractActivityPubProcessor import dev.usbharu.hideout.activitypub.service.common.ActivityPubProcessContext import dev.usbharu.hideout.activitypub.service.common.ActivityType @@ -17,7 +18,11 @@ class APDeleteProcessor( ) : AbstractActivityPubProcessor(transaction) { override suspend fun internalProcess(activity: ActivityPubProcessContext) { - val deleteId = activity.activity.`object`?.id ?: throw IllegalActivityPubObjectException("object.id is null") + val value = activity.activity.`object` + if (value !is HasId) { + throw IllegalActivityPubObjectException("object hasn't id") + } + val deleteId = value.id val post = try { postQueryService.findByApId(deleteId) diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/follow/APSendFollowService.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/follow/APSendFollowService.kt index e71e7c79..554fa571 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/follow/APSendFollowService.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/follow/APSendFollowService.kt @@ -15,7 +15,6 @@ class APSendFollowServiceImpl( ) : APSendFollowService { override suspend fun sendFollow(sendFollowDto: SendFollowDto) { val follow = Follow( - name = "Follow", `object` = sendFollowDto.followTargetUserId.url, actor = sendFollowDto.userId.url ) diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/like/ApReactionJobProcessor.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/like/ApReactionJobProcessor.kt index af3f2f09..3f73bb2e 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/like/ApReactionJobProcessor.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/like/ApReactionJobProcessor.kt @@ -21,7 +21,6 @@ class ApReactionJobProcessor( apRequestService.apPost( param.inbox, Like( - name = "Like", actor = param.actor, `object` = param.postUrl, id = "${applicationConfig.url}/liek/note/${param.id}", diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/like/ApRemoveReactionJobProcessor.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/like/ApRemoveReactionJobProcessor.kt index 307f0c16..6a873aca 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/like/ApRemoveReactionJobProcessor.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/service/activity/like/ApRemoveReactionJobProcessor.kt @@ -28,11 +28,10 @@ class ApRemoveReactionJobProcessor( apRequestService.apPost( param.inbox, Undo( - name = "Undo Reaction", actor = param.actor, `object` = like, id = "${applicationConfig.url}/undo/like/${param.id}", - published = Instant.now() + published = Instant.now().toString() ), signer ) diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/service/objects/user/APUserService.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/service/objects/user/APUserService.kt index d69eb9d6..31a2b505 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/service/objects/user/APUserService.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/service/objects/user/APUserService.kt @@ -57,13 +57,11 @@ class APUserServiceImpl( url = userUrl, icon = Image( type = emptyList(), - name = "$userUrl/icon.png", mediaType = "image/png", url = "$userUrl/icon.png" ), publicKey = Key( type = emptyList(), - name = "Public Key", id = userEntity.keyId, owner = userUrl, publicKeyPem = userEntity.publicKey @@ -127,13 +125,11 @@ class APUserServiceImpl( url = id, icon = Image( type = emptyList(), - name = "$id/icon.png", mediaType = "image/png", url = "$id/icon.png" ), publicKey = Key( type = emptyList(), - name = "Public Key", id = userEntity.keyId, owner = id, publicKeyPem = userEntity.publicKey diff --git a/src/main/kotlin/dev/usbharu/hideout/application/config/ActivityPubConfig.kt b/src/main/kotlin/dev/usbharu/hideout/application/config/ActivityPubConfig.kt index d6bdf301..d661a30a 100644 --- a/src/main/kotlin/dev/usbharu/hideout/application/config/ActivityPubConfig.kt +++ b/src/main/kotlin/dev/usbharu/hideout/application/config/ActivityPubConfig.kt @@ -25,6 +25,7 @@ class ActivityPubConfig { .enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY) .setSerializationInclusion(JsonInclude.Include.NON_EMPTY) .setDefaultSetterInfo(JsonSetter.Value.forContentNulls(Nulls.AS_EMPTY)) + .setDefaultSetterInfo(JsonSetter.Value.forValueNulls(Nulls.AS_EMPTY)) .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) .configure(JsonParser.Feature.ALLOW_COMMENTS, true) .configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true) diff --git a/src/test/kotlin/dev/usbharu/hideout/activitypub/domain/model/DeleteSerializeTest.kt b/src/test/kotlin/dev/usbharu/hideout/activitypub/domain/model/DeleteSerializeTest.kt index 4f190250..21de8c61 100644 --- a/src/test/kotlin/dev/usbharu/hideout/activitypub/domain/model/DeleteSerializeTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/activitypub/domain/model/DeleteSerializeTest.kt @@ -46,7 +46,6 @@ class DeleteSerializeTest { val readValue = objectMapper.readValue(json) val expected = Delete( - name = null, actor = "https://misskey.usbharu.dev/users/97ws8y3rj6", id = "https://misskey.usbharu.dev/4b5b6ed5-9269-45f3-8403-cba1e74b4b69", `object` = Tombstone( @@ -61,7 +60,6 @@ class DeleteSerializeTest { @Test fun シリアライズできる() { val delete = Delete( - name = null, actor = "https://misskey.usbharu.dev/users/97ws8y3rj6", id = "https://misskey.usbharu.dev/4b5b6ed5-9269-45f3-8403-cba1e74b4b69", `object` = Tombstone( @@ -75,7 +73,7 @@ class DeleteSerializeTest { val actual = objectMapper.writeValueAsString(delete) val expected = - """{"type":"Delete","actor":"https://misskey.usbharu.dev/users/97ws8y3rj6","id":"https://misskey.usbharu.dev/4b5b6ed5-9269-45f3-8403-cba1e74b4b69","object":{"type":"Tombstone","name":"Tombstone","id":"https://misskey.usbharu.dev/notes/9lkwqnwqk9"},"published":"2023-11-02T15:30:34.160Z"}""" + """{"type":"Delete","actor":"https://misskey.usbharu.dev/users/97ws8y3rj6","id":"https://misskey.usbharu.dev/4b5b6ed5-9269-45f3-8403-cba1e74b4b69","object":{"type":"Tombstone","id":"https://misskey.usbharu.dev/notes/9lkwqnwqk9"},"published":"2023-11-02T15:30:34.160Z"}""" assertEquals(expected, actual) } } diff --git a/src/test/kotlin/dev/usbharu/hideout/activitypub/domain/model/NoteSerializeTest.kt b/src/test/kotlin/dev/usbharu/hideout/activitypub/domain/model/NoteSerializeTest.kt index 1b05eef1..9e1397a9 100644 --- a/src/test/kotlin/dev/usbharu/hideout/activitypub/domain/model/NoteSerializeTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/activitypub/domain/model/NoteSerializeTest.kt @@ -10,7 +10,6 @@ class NoteSerializeTest { @Test fun Noteのシリアライズができる() { val note = Note( - name = "Note", id = "https://example.com", attributedTo = "https://example.com/actor", content = "Hello", @@ -22,7 +21,7 @@ class NoteSerializeTest { val writeValueAsString = objectMapper.writeValueAsString(note) assertEquals( - "{\"type\":\"Note\",\"name\":\"Note\",\"id\":\"https://example.com\",\"attributedTo\":\"https://example.com/actor\",\"content\":\"Hello\",\"published\":\"2023-05-20T10:28:17.308Z\",\"sensitive\":false}", + """{"type":"Note","id":"https://example.com","attributedTo":"https://example.com/actor","content":"Hello","published":"2023-05-20T10:28:17.308Z","sensitive":false}""", writeValueAsString ) } @@ -65,7 +64,6 @@ class NoteSerializeTest { val readValue = objectMapper.readValue(json) val note = Note( - name = "", id = "https://misskey.usbharu.dev/notes/9f2i9cm88e", type = listOf("Note"), attributedTo = "https://misskey.usbharu.dev/users/97ws8y3rj6", @@ -77,7 +75,6 @@ class NoteSerializeTest { inReplyTo = "https://calckey.jp/notes/9f2i7ymf1d", attachment = emptyList() ) - note.name = null assertEquals(note, readValue) } } diff --git a/src/test/kotlin/dev/usbharu/hideout/activitypub/domain/model/UndoTest.kt b/src/test/kotlin/dev/usbharu/hideout/activitypub/domain/model/UndoTest.kt index 97ba9bc4..ea279694 100644 --- a/src/test/kotlin/dev/usbharu/hideout/activitypub/domain/model/UndoTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/activitypub/domain/model/UndoTest.kt @@ -1,8 +1,8 @@ package dev.usbharu.hideout.activitypub.domain.model +import dev.usbharu.hideout.application.config.ActivityPubConfig import org.intellij.lang.annotations.Language import org.junit.jupiter.api.Test -import utils.JsonObjectMapper import java.time.Clock import java.time.Instant import java.time.ZoneId @@ -12,18 +12,16 @@ class UndoTest { fun Undoのシリアライズができる() { val undo = Undo( emptyList(), - "Undo Follow", "https://follower.example.com/", "https://follower.example.com/undo/1", Follow( emptyList(), - null, "https://follower.example.com/users/", actor = "https://follower.exaple.com/users/1" ), - Instant.now(Clock.tickMillis(ZoneId.systemDefault())) + Instant.now(Clock.tickMillis(ZoneId.systemDefault())).toString() ) - val writeValueAsString = JsonObjectMapper.objectMapper.writeValueAsString(undo) + val writeValueAsString = ActivityPubConfig().objectMapper().writeValueAsString(undo) println(writeValueAsString) } @@ -70,7 +68,7 @@ class UndoTest { """.trimIndent() - val undo = JsonObjectMapper.objectMapper.readValue(json, Undo::class.java) + val undo = ActivityPubConfig().objectMapper().readValue(json, Undo::class.java) println(undo) } } diff --git a/src/test/kotlin/dev/usbharu/hideout/activitypub/domain/model/objects/ObjectSerializeTest.kt b/src/test/kotlin/dev/usbharu/hideout/activitypub/domain/model/objects/ObjectSerializeTest.kt index 77f2579b..41bc114e 100644 --- a/src/test/kotlin/dev/usbharu/hideout/activitypub/domain/model/objects/ObjectSerializeTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/activitypub/domain/model/objects/ObjectSerializeTest.kt @@ -16,10 +16,7 @@ class ObjectSerializeTest { val readValue = objectMapper.readValue(json) val expected = Object( - listOf("Object"), - null, - null, - null + listOf("Object") ) assertEquals(expected, readValue) } @@ -34,10 +31,7 @@ class ObjectSerializeTest { val readValue = objectMapper.readValue(json) val expected = Object( - listOf("Hoge", "Object"), - null, - null, - null + listOf("Hoge", "Object") ) assertEquals(expected, readValue) @@ -53,10 +47,7 @@ class ObjectSerializeTest { val readValue = objectMapper.readValue(json) val expected = Object( - emptyList(), - null, - null, - null + emptyList() ) assertEquals(expected, readValue) diff --git a/src/test/kotlin/dev/usbharu/hideout/activitypub/interfaces/api/actor/UserAPControllerImplTest.kt b/src/test/kotlin/dev/usbharu/hideout/activitypub/interfaces/api/actor/UserAPControllerImplTest.kt index 9520eac2..42f44e27 100644 --- a/src/test/kotlin/dev/usbharu/hideout/activitypub/interfaces/api/actor/UserAPControllerImplTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/activitypub/interfaces/api/actor/UserAPControllerImplTest.kt @@ -49,12 +49,10 @@ class UserAPControllerImplTest { outbox = "https://example.com/users/hoge/outbox", url = "https://example.com/users/hoge", icon = Image( - name = "icon", mediaType = "image/jpeg", url = "https://example.com/users/hoge/icon.jpg" ), publicKey = Key( - name = "Public Key", id = "https://example.com/users/hoge#pubkey", owner = "https://example.com/users/hoge", publicKeyPem = "-----BEGIN PUBLIC KEY-----...-----END PUBLIC KEY-----", diff --git a/src/test/kotlin/dev/usbharu/hideout/activitypub/interfaces/api/note/NoteApControllerImplTest.kt b/src/test/kotlin/dev/usbharu/hideout/activitypub/interfaces/api/note/NoteApControllerImplTest.kt index c337e770..bfa7168e 100644 --- a/src/test/kotlin/dev/usbharu/hideout/activitypub/interfaces/api/note/NoteApControllerImplTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/activitypub/interfaces/api/note/NoteApControllerImplTest.kt @@ -53,7 +53,6 @@ class NoteApControllerImplTest { fun `postAP 匿名で取得できる`() = runTest { SecurityContextHolder.clearContext() val note = Note( - name = "Note", id = "https://example.com/users/hoge/posts/1234", attributedTo = "https://example.com/users/hoge", content = "Hello", @@ -90,7 +89,6 @@ class NoteApControllerImplTest { @Test fun `postAP 認証に成功している場合userIdがnullでない`() = runTest { val note = Note( - name = "Note", id = "https://example.com/users/hoge/posts/1234", attributedTo = "https://example.com/users/hoge", content = "Hello", diff --git a/src/test/kotlin/dev/usbharu/hideout/activitypub/service/activity/create/ApSendCreateServiceImplTest.kt b/src/test/kotlin/dev/usbharu/hideout/activitypub/service/activity/create/ApSendCreateServiceImplTest.kt index 47b5671e..01975882 100644 --- a/src/test/kotlin/dev/usbharu/hideout/activitypub/service/activity/create/ApSendCreateServiceImplTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/activitypub/service/activity/create/ApSendCreateServiceImplTest.kt @@ -52,7 +52,6 @@ class ApSendCreateServiceImplTest { val post = PostBuilder.of() val user = UserBuilder.localUserOf(id = post.userId) val note = Note( - name = "Post", id = post.apId, attributedTo = user.url, content = post.text, diff --git a/src/test/kotlin/dev/usbharu/hideout/activitypub/service/activity/follow/APSendFollowServiceImplTest.kt b/src/test/kotlin/dev/usbharu/hideout/activitypub/service/activity/follow/APSendFollowServiceImplTest.kt index 6ce3a084..93e1d76d 100644 --- a/src/test/kotlin/dev/usbharu/hideout/activitypub/service/activity/follow/APSendFollowServiceImplTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/activitypub/service/activity/follow/APSendFollowServiceImplTest.kt @@ -24,7 +24,6 @@ class APSendFollowServiceImplTest { apSendFollowServiceImpl.sendFollow(sendFollowDto) val value = Follow( - name = "Follow", `object` = sendFollowDto.followTargetUserId.url, actor = sendFollowDto.userId.url ) diff --git a/src/test/kotlin/dev/usbharu/hideout/activitypub/service/common/APRequestServiceImplTest.kt b/src/test/kotlin/dev/usbharu/hideout/activitypub/service/common/APRequestServiceImplTest.kt index ec36d233..2c609183 100644 --- a/src/test/kotlin/dev/usbharu/hideout/activitypub/service/common/APRequestServiceImplTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/activitypub/service/common/APRequestServiceImplTest.kt @@ -39,7 +39,7 @@ class APRequestServiceImplTest { assertDoesNotThrow { dateTimeFormatter.parse(it.headers["Date"]) } - respond("{}") + respond("""{"type":"Follow","object": "https://example.com","actor": "https://example.com"}""") }), objectMapper, mock(), @@ -47,7 +47,6 @@ class APRequestServiceImplTest { ) val responseClass = Follow( - name = "Follow", `object` = "https://example.com", actor = "https://example.com" ) @@ -65,7 +64,7 @@ class APRequestServiceImplTest { assertDoesNotThrow { dateTimeFormatter.parse(it.headers["Date"]) } - respond("{}") + respond("""{"type":"Follow","object": "https://example.com","actor": "https://example.com"}""") }), objectMapper, mock(), @@ -73,7 +72,6 @@ class APRequestServiceImplTest { ) val responseClass = Follow( - name = "Follow", `object` = "https://example.com", actor = "https://example.com" ) @@ -106,7 +104,7 @@ class APRequestServiceImplTest { assertDoesNotThrow { dateTimeFormatter.parse(it.headers["Date"]) } - respond("{}") + respond("""{"type":"Follow","object": "https://example.com","actor": "https://example.com"}""") }), objectMapper, httpSignatureSigner, @@ -114,7 +112,6 @@ class APRequestServiceImplTest { ) val responseClass = Follow( - name = "Follow", `object` = "https://example.com", actor = "https://example.com" ) @@ -166,7 +163,6 @@ class APRequestServiceImplTest { }), objectMapper, mock(), dateTimeFormatter) val body = Follow( - name = "Follow", `object` = "https://example.com", actor = "https://example.com" ) @@ -213,7 +209,6 @@ class APRequestServiceImplTest { }), objectMapper, mock(), dateTimeFormatter) val body = Follow( - name = "Follow", `object` = "https://example.com", actor = "https://example.com" ) @@ -244,7 +239,6 @@ class APRequestServiceImplTest { }), objectMapper, mock(), dateTimeFormatter) val body = Follow( - name = "Follow", `object` = "https://example.com", actor = "https://example.com" ) @@ -286,7 +280,6 @@ class APRequestServiceImplTest { }), objectMapper, httpSignatureSigner, dateTimeFormatter) val body = Follow( - name = "Follow", `object` = "https://example.com", actor = "https://example.com" ) @@ -337,7 +330,6 @@ class APRequestServiceImplTest { }), objectMapper, mock(), dateTimeFormatter) val body = Follow( - name = "Follow", `object` = "https://example.com", actor = "https://example.com" ) diff --git a/src/test/kotlin/dev/usbharu/hideout/activitypub/service/objects/note/APNoteServiceImplTest.kt b/src/test/kotlin/dev/usbharu/hideout/activitypub/service/objects/note/APNoteServiceImplTest.kt index 540f642c..5ed6597d 100644 --- a/src/test/kotlin/dev/usbharu/hideout/activitypub/service/objects/note/APNoteServiceImplTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/activitypub/service/objects/note/APNoteServiceImplTest.kt @@ -56,7 +56,6 @@ class APNoteServiceImplTest { onBlocking { findById(eq(post.userId)) } doReturn user } val expected = Note( - name = "Post", id = post.apId, attributedTo = user.url, content = post.text, @@ -98,7 +97,6 @@ class APNoteServiceImplTest { onBlocking { findById(eq(post.userId)) } doReturn user } val note = Note( - name = "Post", id = post.apId, attributedTo = user.url, content = post.text, @@ -124,13 +122,11 @@ class APNoteServiceImplTest { url = user.url, icon = Image( type = emptyList(), - name = user.url + "/icon.png", mediaType = "image/png", url = user.url + "/icon.png" ), publicKey = Key( type = emptyList(), - name = "Public Key", id = user.keyId, owner = user.url, publicKeyPem = user.publicKey @@ -177,7 +173,6 @@ class APNoteServiceImplTest { onBlocking { findById(eq(post.userId)) } doReturn user } val note = Note( - name = "Post", id = post.apId, attributedTo = user.url, content = post.text, @@ -246,11 +241,11 @@ class APNoteServiceImplTest { outbox = user.outbox, url = user.url, icon = Image( - name = user.url + "/icon.png", mediaType = "image/png", url = user.url + "/icon.png" + mediaType = "image/png", + url = user.url + "/icon.png" ), publicKey = Key( type = emptyList(), - name = "Public Key", id = user.keyId, owner = user.url, publicKeyPem = user.publicKey @@ -278,7 +273,6 @@ class APNoteServiceImplTest { ) val note = Note( - name = "Post", id = post.apId, attributedTo = user.url, content = post.text, @@ -311,7 +305,6 @@ class APNoteServiceImplTest { onBlocking { findById(eq(user.id)) } doReturn user } val note = Note( - name = "Post", id = post.apId, attributedTo = user.url, content = post.text, diff --git a/src/test/kotlin/dev/usbharu/hideout/ap/ContextSerializerTest.kt b/src/test/kotlin/dev/usbharu/hideout/ap/ContextSerializerTest.kt index db434005..d73e31d7 100644 --- a/src/test/kotlin/dev/usbharu/hideout/ap/ContextSerializerTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/ap/ContextSerializerTest.kt @@ -13,7 +13,6 @@ class ContextSerializerTest { name = "aaa", actor = "bbb", `object` = Follow( - name = "ccc", `object` = "ddd", actor = "aaa" )