diff --git a/impl/misskey/src/test/kotlin/dev/usbharu/multim/misskey/v12/api/ApTest.kt b/impl/misskey/src/test/kotlin/dev/usbharu/multim/misskey/v12/api/ApTest.kt index b193333..551ff8d 100644 --- a/impl/misskey/src/test/kotlin/dev/usbharu/multim/misskey/v12/api/ApTest.kt +++ b/impl/misskey/src/test/kotlin/dev/usbharu/multim/misskey/v12/api/ApTest.kt @@ -10,6 +10,7 @@ import dev.usbharu.multim.TestUtil.failOnError import dev.usbharu.multim.misskey.v12.common.api.MisskeyApiClient import dev.usbharu.multim.misskey.v12.model.ApShowRequest import dev.usbharu.multim.misskey.v12.model.ApShowResponse +import dev.usbharu.multim.misskey.v12.model.NotesNotesRequest import dev.usbharu.multim.model.SingleTokenAuth import io.github.artsok.RepeatedIfExceptionsTest import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -17,8 +18,7 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.runBlocking import kotlinx.coroutines.test.runTest import kotlinx.serialization.decodeFromString -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Assertions.assertInstanceOf +import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.Test @@ -84,7 +84,13 @@ class ApTestE2E { // @Test fun show_showUserRequest_respondTypeUser() = runBlocking { val show = - Ap(misskeyApiClient).show(ApShowRequest("https://mstdn-dev.usbharu.dev/@testAdmin")) + Ap(misskeyApiClient).show( + ApShowRequest( + System.getProperty("multim_misskey_instance") + "@" + I( + misskeyApiClient + ).i().failOnError().username + ) + ) .failOnError() delay(1000) assertInstanceOf(ApShowResponse.TypeUser::class.java, show) @@ -94,7 +100,12 @@ class ApTestE2E { // @Test fun show_showNoteRequest_respondTypeNote() = runBlocking { val show = - Ap(misskeyApiClient).show(ApShowRequest("https://mstdn-dev.usbharu.dev/@testAdmin/109739544444885718")) + Ap(misskeyApiClient).show( + ApShowRequest( + Notes(misskeyApiClient).notes(NotesNotesRequest()).failOnError().first().uri + ?: fail() + ) + ) .failOnError() delay(1000) assertInstanceOf(ApShowResponse.TypeNote::class.java, show) diff --git a/impl/misskey/src/test/kotlin/dev/usbharu/multim/misskey/v12/api/NotesTest.kt b/impl/misskey/src/test/kotlin/dev/usbharu/multim/misskey/v12/api/NotesTest.kt index 7262f7e..6f48ead 100644 --- a/impl/misskey/src/test/kotlin/dev/usbharu/multim/misskey/v12/api/NotesTest.kt +++ b/impl/misskey/src/test/kotlin/dev/usbharu/multim/misskey/v12/api/NotesTest.kt @@ -23,6 +23,7 @@ import kotlinx.coroutines.test.runTest import kotlinx.datetime.Instant import kotlinx.serialization.encodeToString import org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows import java.util.* @@ -215,7 +216,9 @@ class NotesTestE2E { @Test fun show() = runTest { - val show = notes.show(NotesShowRequest("9bk3hn1qd0")).failOnError() + val show = + notes.show(NotesShowRequest(notes.notes(NotesNotesRequest()).failOnError().first().id)) + .failOnError() println(show) } @@ -286,19 +289,27 @@ class NotesTestE2E { @Test fun children() = runTest { - val children = notes.children(NotesChildrenRequest("9ad7btwst8")).failOnError() + val create = + notes.create(NotesCreateRequest(text = "このノートはMultiMのテストで作成され、子ノート取得のテストで使用されます。${this@NotesTestE2E::class} children")) + val id = create.failOnError().createdNote.id + val children = notes.children(NotesChildrenRequest(id)).failOnError() println(children) } @Test fun conversation() = runTest { - val conversation = notes.conversation(NotesConversationRequest("9bk3hn1qd0")).failOnError() + val create = + notes.create(NotesCreateRequest(text = "このノートはMultiMのテストで作成され、関連ノート取得のテストで使用されます。 ${this@NotesTestE2E::class} conversation")) + .failOnError() + val conversation = + notes.conversation(NotesConversationRequest(create.createdNote.id)).failOnError() println(conversation) } @Test fun state() = runTest { - val state = notes.state(NotesStateRequest("9bk3hn1qd0")).failOnError() + val create = notes.create(NotesCreateRequest(text="このノートはMultiMのテストで作成され、ノートの状態を取得するテストで使用されます。 ${this@NotesTestE2E::class} state")).failOnError() + val state = notes.state(NotesStateRequest(create.createdNote.id)).failOnError() println(state) } @@ -334,13 +345,14 @@ class NotesTestE2E { @Test fun mentions() = runTest { - val mentions = notes.mentions(NotesMentionsRequest()) + val mentions = notes.mentions(NotesMentionsRequest()).failOnError() println(mentions) } @Test fun reactions() = runTest { - val reactions = notes.reactions(NotesReactionsRequest("9ack8wxw3c")) + val create = notes.create(NotesCreateRequest(text = "このノートはMultiMのテストで作成され、リアクション取得のテストで使用されます。 ${this@NotesTestE2E::class} reactions")).failOnError() + val reactions = notes.reactions(NotesReactionsRequest(create.createdNote.id)) println(reactions) } @@ -430,7 +442,7 @@ class NotesTestE2E { @Test fun timeline() = runTest { - val timeline = notes.timeline(NotesTimelineRequest()) + val timeline = notes.timeline(NotesTimelineRequest()).failOnError() println(timeline) } @@ -455,14 +467,20 @@ class NotesTestE2E { } @Test + @Disabled("リスト操作系のAPIが未実装なため無効化") + // TODO: リスト操作系のAPI追加後、リストを取得してテストするように fun userListTimeline() = runTest { + val userListTimeline = notes.userListTimeline(NotesUserListTimelineRequest("9ady10e6z5")) println(userListTimeline) } @Test + @Disabled("自分以外ということが確定しているノートを取得できない為無効化") + // TODO: 自分以外のノートを取得できるようになってからテストを追加 fun watchingCreate() = runTest { + val noteId = "9bk3hn1qd0" val state = notes.state(NotesStateRequest(noteId)).failOnError() if (state.isWatching) { @@ -473,6 +491,7 @@ class NotesTestE2E { } @Test + @Disabled("自分以外ということが確定しているノートを取得できない為無効化") fun watchingDelete() = runTest { val noteId = "9bk3hn1qd0" val state = notes.state(NotesStateRequest(noteId)).failOnError()