From aa788f972077dc5d1d913562a7cd4c1d04359f76 Mon Sep 17 00:00:00 2001 From: Wv5twkFEKh54vo4tta9yu7dHa3 <61561059+Wv5twkFEKh54vo4tta9yu7dHa3@users.noreply.github.com> Date: Wed, 4 Mar 2020 18:04:55 +0100 Subject: [PATCH] Implement most of the API (#23) Add Kotlin representations (data classes) of the Types of the Mastodon API. Create helper function to make API from the interface. Test the deserialization. --- .travis.yml | 2 +- app/build.gradle | 24 ++- app/src/main/AndroidManifest.xml | 2 +- .../java/com/h/pixeldroid/MainActivity.kt | 10 ++ .../java/com/h/pixeldroid/api/PixelfedAPI.kt | 42 +++++ .../java/com/h/pixeldroid/objects/Account.kt | 35 ++++ .../com/h/pixeldroid/objects/Application.kt | 9 + .../com/h/pixeldroid/objects/Attachment.kt | 19 ++ .../java/com/h/pixeldroid/objects/Card.kt | 23 +++ .../java/com/h/pixeldroid/objects/Emoji.kt | 11 ++ .../java/com/h/pixeldroid/objects/Field.kt | 5 + .../java/com/h/pixeldroid/objects/History.kt | 8 + .../java/com/h/pixeldroid/objects/Mention.kt | 4 + .../java/com/h/pixeldroid/objects/Poll.kt | 5 + .../java/com/h/pixeldroid/objects/Source.kt | 5 + .../java/com/h/pixeldroid/objects/Status.kt | 48 +++++ .../main/java/com/h/pixeldroid/objects/Tag.kt | 9 + .../res/drawable/ic_launcher_background.xml | 170 ------------------ .../test/java/com/h/pixeldroid/APIUnitTest.kt | 135 ++++++++++++++ 19 files changed, 387 insertions(+), 179 deletions(-) create mode 100644 app/src/main/java/com/h/pixeldroid/api/PixelfedAPI.kt create mode 100644 app/src/main/java/com/h/pixeldroid/objects/Account.kt create mode 100644 app/src/main/java/com/h/pixeldroid/objects/Application.kt create mode 100644 app/src/main/java/com/h/pixeldroid/objects/Attachment.kt create mode 100644 app/src/main/java/com/h/pixeldroid/objects/Card.kt create mode 100644 app/src/main/java/com/h/pixeldroid/objects/Emoji.kt create mode 100644 app/src/main/java/com/h/pixeldroid/objects/Field.kt create mode 100644 app/src/main/java/com/h/pixeldroid/objects/History.kt create mode 100644 app/src/main/java/com/h/pixeldroid/objects/Mention.kt create mode 100644 app/src/main/java/com/h/pixeldroid/objects/Poll.kt create mode 100644 app/src/main/java/com/h/pixeldroid/objects/Source.kt create mode 100644 app/src/main/java/com/h/pixeldroid/objects/Status.kt create mode 100644 app/src/main/java/com/h/pixeldroid/objects/Tag.kt delete mode 100644 app/src/main/res/drawable/ic_launcher_background.xml create mode 100644 app/src/test/java/com/h/pixeldroid/APIUnitTest.kt diff --git a/.travis.yml b/.travis.yml index c23f3dcf..0f4df905 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,5 +25,5 @@ script: after_script: # Report test coverage to Code Climate - export JACOCO_SOURCE_PATH=app/src/main/java/ - - ./cc-test-reporter format-coverage ./app/build/reports/coverage/debug/report.xml --input-type jacoco + - ./cc-test-reporter format-coverage ./app/build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml --input-type jacoco - ./cc-test-reporter upload-coverage diff --git a/app/build.gradle b/app/build.gradle index d52bd54f..55ca3e78 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,7 +6,10 @@ apply plugin: 'jacoco' android { compileSdkVersion 29 buildToolsVersion "29.0.3" - +compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } defaultConfig { applicationId "com.h.pixeldroid" minSdkVersion 23 @@ -35,6 +38,15 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.core:core-ktx:1.2.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + implementation "com.squareup.okhttp3:okhttp:4.4.0" + implementation 'com.squareup.retrofit2:retrofit:2.7.1' + implementation 'com.squareup.retrofit2:converter-gson:2.7.1' + implementation 'com.squareup.retrofit2:adapter-rxjava2:2.7.1' + implementation 'io.reactivex.rxjava2:rxjava:2.2.16' + implementation 'io.reactivex.rxjava2:rxandroid:2.1.1' + + testImplementation "com.github.tomakehurst:wiremock-jre8:2.26.2" + testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0" testImplementation 'junit:junit:4.13' androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' @@ -54,13 +66,11 @@ task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'crea } def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*'] - def debugTree = fileTree(dir: "$project.buildDir/intermediates/classes/debug", excludes: fileFilter) def kotlinDebugTree = fileTree(dir: "$project.buildDir/tmp/kotlin-classes/debug", excludes: fileFilter) - def javaMainSrc = "$project.projectDir/src/main/java" - def kotlinMainSrc = "$project.projectDir/src/main/kotlin" - sourceDirectories = files([javaMainSrc, kotlinMainSrc]) - classDirectories = files([debugTree, kotlinDebugTree]) + def mainSrc = "$project.projectDir/src/main/java" + sourceDirectories = files([mainSrc]) + classDirectories = files([kotlinDebugTree]) executionData = fileTree(dir: project.buildDir, includes: [ - 'jacoco/testDebugUnitTest.exec', 'outputs/code-coverage/connected/*coverage.ec' + 'jacoco/testDebugUnitTest.exec', 'outputs/code-coverage/debugAndroidTest/connected/*coverage.ec' ]) } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 95641a5b..2d63dcda 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,7 +1,7 @@ - + > + + companion object { + fun create(baseUrl: String): PixelfedAPI { + return Retrofit.Builder() + .baseUrl(baseUrl) + .addConverterFactory(GsonConverterFactory.create()) + .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) + .build().create(PixelfedAPI::class.java) + } + } +} + diff --git a/app/src/main/java/com/h/pixeldroid/objects/Account.kt b/app/src/main/java/com/h/pixeldroid/objects/Account.kt new file mode 100644 index 00000000..738b1041 --- /dev/null +++ b/app/src/main/java/com/h/pixeldroid/objects/Account.kt @@ -0,0 +1,35 @@ +package com.h.pixeldroid.objects + + +/* +Represents a user and their associated profile. +https://docs.joinmastodon.org/entities/account/ + */ + +data class Account( + //Base attributes + val id: String, + val username: String, + val acct: String, + val url: String, //HTTPS URL + //Display attributes + val display_name: String, + val note: String, //HTML + val avatar: String, //URL + val avatar_static: String, //URL + val header: String, //URL + val header_static: String, //URL + val locked: Boolean, + val emojis: List, + val discoverable: Boolean, + //Statistical attributes + val created_at: String, //ISO 8601 Datetime (maybe can use a date type) + val statuses_count: Int, + val followers_count: Int, + val following_count: Int, + //Optional attributes + val moved: Account? = null, + val fields: List? = emptyList(), + val bot: Boolean = false, + val source: Source? = null +) \ No newline at end of file diff --git a/app/src/main/java/com/h/pixeldroid/objects/Application.kt b/app/src/main/java/com/h/pixeldroid/objects/Application.kt new file mode 100644 index 00000000..d58448b9 --- /dev/null +++ b/app/src/main/java/com/h/pixeldroid/objects/Application.kt @@ -0,0 +1,9 @@ +package com.h.pixeldroid.objects + +data class Application ( + //Required attributes + val name: String, + //Optional attributes + val website: String? = null, + val vapid_key: String? = null +) \ No newline at end of file diff --git a/app/src/main/java/com/h/pixeldroid/objects/Attachment.kt b/app/src/main/java/com/h/pixeldroid/objects/Attachment.kt new file mode 100644 index 00000000..e6dbb744 --- /dev/null +++ b/app/src/main/java/com/h/pixeldroid/objects/Attachment.kt @@ -0,0 +1,19 @@ +package com.h.pixeldroid.objects + +data class Attachment( + //Required attributes + val id: String, + val type: AttachmentType, + val url: String, //URL + val preview_url: String, //URL + //Optional attributes + val remote_url: String? = null, //URL + val text_url: String? = null, //URL + //TODO meta + val description: String? = null, + val blurhash: String? = null +) { + enum class AttachmentType { + unknown, image, gifv, video, audio + } +} diff --git a/app/src/main/java/com/h/pixeldroid/objects/Card.kt b/app/src/main/java/com/h/pixeldroid/objects/Card.kt new file mode 100644 index 00000000..25ba0cf0 --- /dev/null +++ b/app/src/main/java/com/h/pixeldroid/objects/Card.kt @@ -0,0 +1,23 @@ +package com.h.pixeldroid.objects + +data class Card( + //Required attributes + val url: String, //URL + val title: String, + val description: String, + val type: CardType, + //Optional attributes + val author_name: String? = null, + val author_url: String? = null, //URL + val provider_name: String? = null, + val provider_url: String? = null, //URL + val html: String? = null, //HTML + val width: Int? = null, + val height: Int? = null, + val image: String? = null, //URL + val embed_url: String? = null //URL +) { + enum class CardType { + link, photo, video, rich + } +} diff --git a/app/src/main/java/com/h/pixeldroid/objects/Emoji.kt b/app/src/main/java/com/h/pixeldroid/objects/Emoji.kt new file mode 100644 index 00000000..4c7dd769 --- /dev/null +++ b/app/src/main/java/com/h/pixeldroid/objects/Emoji.kt @@ -0,0 +1,11 @@ +package com.h.pixeldroid.objects + +data class Emoji( + //Required attributes + val shortcode: String, + val url: String, //URL + val static_url: String, //URL + val visible_in_picker: Boolean, + //Optional attributes + val category: String? = null +) \ No newline at end of file diff --git a/app/src/main/java/com/h/pixeldroid/objects/Field.kt b/app/src/main/java/com/h/pixeldroid/objects/Field.kt new file mode 100644 index 00000000..331719f2 --- /dev/null +++ b/app/src/main/java/com/h/pixeldroid/objects/Field.kt @@ -0,0 +1,5 @@ +package com.h.pixeldroid.objects + +class Field { + +} diff --git a/app/src/main/java/com/h/pixeldroid/objects/History.kt b/app/src/main/java/com/h/pixeldroid/objects/History.kt new file mode 100644 index 00000000..811ca67a --- /dev/null +++ b/app/src/main/java/com/h/pixeldroid/objects/History.kt @@ -0,0 +1,8 @@ +package com.h.pixeldroid.objects + +data class History( + //Required attributes + val day: String, + val uses: String, + val accounts: String +) diff --git a/app/src/main/java/com/h/pixeldroid/objects/Mention.kt b/app/src/main/java/com/h/pixeldroid/objects/Mention.kt new file mode 100644 index 00000000..c45021e7 --- /dev/null +++ b/app/src/main/java/com/h/pixeldroid/objects/Mention.kt @@ -0,0 +1,4 @@ +package com.h.pixeldroid.objects + +class Mention { +} \ No newline at end of file diff --git a/app/src/main/java/com/h/pixeldroid/objects/Poll.kt b/app/src/main/java/com/h/pixeldroid/objects/Poll.kt new file mode 100644 index 00000000..1dea36db --- /dev/null +++ b/app/src/main/java/com/h/pixeldroid/objects/Poll.kt @@ -0,0 +1,5 @@ +package com.h.pixeldroid.objects + +class Poll { + +} diff --git a/app/src/main/java/com/h/pixeldroid/objects/Source.kt b/app/src/main/java/com/h/pixeldroid/objects/Source.kt new file mode 100644 index 00000000..cdbd0532 --- /dev/null +++ b/app/src/main/java/com/h/pixeldroid/objects/Source.kt @@ -0,0 +1,5 @@ +package com.h.pixeldroid.objects + +class Source { + +} diff --git a/app/src/main/java/com/h/pixeldroid/objects/Status.kt b/app/src/main/java/com/h/pixeldroid/objects/Status.kt new file mode 100644 index 00000000..c6064cba --- /dev/null +++ b/app/src/main/java/com/h/pixeldroid/objects/Status.kt @@ -0,0 +1,48 @@ +package com.h.pixeldroid.objects + + +/* +Represents a status posted by an account. +https://docs.joinmastodon.org/entities/status/ + */ +data class Status( + //Base attributes + val id: String, + val uri: String, + val created_at: String, //ISO 8601 Datetime (maybe can use a date type) + val account: Account, + val content: String, //HTML + val visibility: Visibility, + val sensitive: Boolean, + val spoiler_text: String, + val media_attachments: List, + val application: Application, + //Rendering attributes + val mentions: List, + val tags: List, + val emojis: List, + //Informational attributes + val reblogs_count: Int, + val favourites_count: Int, + val replies_count: Int, + //Nullable attributes + val url: String?, //URL + val in_reply_to_id: String?, + val in_reply_to_account: String?, + val reblog: Status?, + val poll: Poll?, + val card: Card?, + val language: String?, //ISO 639 Part 1 two-letter language code + val text: String?, + //Authorized user attributes + val favourited: Boolean, + val reblogged: Boolean, + val muted: Boolean, + val bookmarked: Boolean, + val pinned: Boolean + ) +{ + enum class Visibility { + public, unlisted, private, direct + } +} \ No newline at end of file diff --git a/app/src/main/java/com/h/pixeldroid/objects/Tag.kt b/app/src/main/java/com/h/pixeldroid/objects/Tag.kt new file mode 100644 index 00000000..c15dcc7e --- /dev/null +++ b/app/src/main/java/com/h/pixeldroid/objects/Tag.kt @@ -0,0 +1,9 @@ +package com.h.pixeldroid.objects + +data class Tag( + //Base attributes + val name: String, + val url: String, + //Optional attributes + val history: List? = emptyList() +) \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml deleted file mode 100644 index 07d5da9c..00000000 --- a/app/src/main/res/drawable/ic_launcher_background.xml +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/test/java/com/h/pixeldroid/APIUnitTest.kt b/app/src/test/java/com/h/pixeldroid/APIUnitTest.kt new file mode 100644 index 00000000..a96b60df --- /dev/null +++ b/app/src/test/java/com/h/pixeldroid/APIUnitTest.kt @@ -0,0 +1,135 @@ +package com.h.pixeldroid + +import com.github.tomakehurst.wiremock.client.WireMock.* +import com.github.tomakehurst.wiremock.junit.WireMockRule +import com.h.pixeldroid.api.PixelfedAPI +import com.h.pixeldroid.objects.* +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNotNull +import org.junit.Rule +import org.junit.Test +import retrofit2.Call + + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class APIUnitTest { + @get:Rule + public var wireMockRule = WireMockRule(8089) + /*@Test + fun mocked_api_publicTimeline_test(){ + /* Given */ + val mock: PixelfedAPI = mock { + on { + timelinePublic(null, null, null, null, null) + } doReturn object: Call>{ + override fun enqueue(callback: Callback>) { + callback.onResponse(this, + Response.success( + listOf(Status( + "", "", "", + Account("", "", "", "", "", "", "", "", "", "", false, emptyList(), true, "", 5, 6, 7), + "", Status.Visibility.PUBLIC, false, "", emptyList(), Application("name"), emptyList(), emptyList(), emptyList(), 6, 7, 8, null, null, null, null, null, null, null, null, false, false, false, false,false) + )) + ) + } + + override fun isExecuted(): Boolean { + throw Error("not implemented") + } + + override fun clone(): Call> { + throw Error("not implemented") + } + + override fun isCanceled(): Boolean { + throw Error("not implemented") + } + + override fun cancel() { + throw Error("not implemented") + } + + override fun execute(): Response> { + throw Error("not implemented") + } + + override fun request(): Request { + throw Error("not implemented") + } + + } + + } + } + val classUnderTest = ClassUnderTest(mock) + + /* When */ + classUnderTest.doAction() + + /* Then */ + verify(mock).doSomething(any()) + }*/ + @Test + fun api_correctly_translated_data_class() { + stubFor( + get(urlEqualTo("/api/v1/timelines/public")) + .willReturn( + aResponse() + .withStatus(200) + .withHeader("Content-Type", "application/json") + .withBody( + """[{"id":"140364967936397312","uri":"https:\/\/pixelfed.de\/p\/Miike\/140364967936397312","url":"https:\/\/pixelfed.de\/p\/Miike\/140364967936397312","in_reply_to_id":null,"in_reply_to_account_id":null,"reblog":null,"content":"Day 8 #rotavicentina<\/a> #hiking<\/a> #nature<\/a>","created_at":"2020-03-03T08:00:16.000000Z","emojis":[],"replies_count":0,"reblogs_count":0,"favourites_count":0,"reblogged":null,"favourited":null,"muted":null,"sensitive":false,"spoiler_text":"","visibility":"public","mentions":[],"tags":[{"name":"hiking","url":"https:\/\/pixelfed.de\/discover\/tags\/hiking"},{"name":"nature","url":"https:\/\/pixelfed.de\/discover\/tags\/nature"},{"name":"rotavicentina","url":"https:\/\/pixelfed.de\/discover\/tags\/rotavicentina"}],"card":null,"poll":null,"application":{"name":"web","website":null},"language":null,"pinned":null,"account":{"id":"115114166443970560","username":"Miike","acct":"Miike","display_name":"Miike Duart","locked":false,"created_at":"2019-12-24T15:42:35.000000Z","followers_count":14,"following_count":0,"statuses_count":71,"note":"","url":"https:\/\/pixelfed.de\/Miike","avatar":"https:\/\/pixelfed.de\/storage\/avatars\/011\/511\/416\/644\/397\/056\/0\/ZhaopLJWTWJ3hsVCS5pS_avatar.png?v=d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35","avatar_static":"https:\/\/pixelfed.de\/storage\/avatars\/011\/511\/416\/644\/397\/056\/0\/ZhaopLJWTWJ3hsVCS5pS_avatar.png?v=d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35","header":"","header_static":"","emojis":[],"moved":null,"fields":null,"bot":false,"software":"pixelfed","is_admin":false},"media_attachments":[{"id":"15888","type":"image","url":"https:\/\/pixelfed.de\/storage\/m\/113a3e2124a33b1f5511e531953f5ee48456e0c7\/34dd6d9fb1762dac8c7ddeeaf789d2d8fa083c9f\/JtjO0eAbELpgO1UZqF5ydrKbCKRVyJUM1WAaqIeB.jpeg","remote_url":null,"preview_url":"https:\/\/pixelfed.de\/storage\/m\/113a3e2124a33b1f5511e531953f5ee48456e0c7\/34dd6d9fb1762dac8c7ddeeaf789d2d8fa083c9f\/JtjO0eAbELpgO1UZqF5ydrKbCKRVyJUM1WAaqIeB_thumb.jpeg","text_url":null,"meta":null,"description":null}]},{"id":"140349785193451520","uri":"https:\/\/pixelfed.de\/p\/stephan\/140349785193451520","url":"https:\/\/pixelfed.de\/p\/stephan\/140349785193451520","in_reply_to_id":null,"in_reply_to_account_id":null,"reblog":null,"content":"","created_at":"2020-03-03T06:59:56.000000Z","emojis":[],"replies_count":0,"reblogs_count":0,"favourites_count":2,"reblogged":null,"favourited":null,"muted":null,"sensitive":false,"spoiler_text":"","visibility":"public","mentions":[],"tags":[],"card":null,"poll":null,"application":{"name":"web","website":null},"language":null,"pinned":null,"account":{"id":"908","username":"stephan","acct":"stephan","display_name":"Stephan","locked":false,"created_at":"2019-03-17T07:46:33.000000Z","followers_count":136,"following_count":25,"statuses_count":136,"note":"Musician, software developer & hobby photographer.","url":"https:\/\/pixelfed.de\/stephan","avatar":"https:\/\/pixelfed.de\/storage\/avatars\/000\/000\/000\/908\/5nQzzsB1mkwKaUqQ9GNN_avatar.png?v=d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35","avatar_static":"https:\/\/pixelfed.de\/storage\/avatars\/000\/000\/000\/908\/5nQzzsB1mkwKaUqQ9GNN_avatar.png?v=d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35","header":"","header_static":"","emojis":[],"moved":null,"fields":null,"bot":false,"software":"pixelfed","is_admin":false},"media_attachments":[{"id":"15887","type":"image","url":"https:\/\/pixelfed.de\/storage\/m\/113a3e2124a33b1f5511e531953f5ee48456e0c7\/a1349f5183c2bac7d52880e8f5188df0f3b2d62a\/mvT3nYV6Wdu42Xh56Ny4VYaWU0OzbnC3wjxiqnKS.jpeg","remote_url":null,"preview_url":"https:\/\/pixelfed.de\/storage\/m\/113a3e2124a33b1f5511e531953f5ee48456e0c7\/a1349f5183c2bac7d52880e8f5188df0f3b2d62a\/mvT3nYV6Wdu42Xh56Ny4VYaWU0OzbnC3wjxiqnKS_thumb.jpeg","text_url":null,"meta":null,"description":null}]},{"id":"140276879742603264","uri":"https:\/\/pixelfed.de\/p\/fegrimaldi\/140276879742603264","url":"https:\/\/pixelfed.de\/p\/fegrimaldi\/140276879742603264","in_reply_to_id":null,"in_reply_to_account_id":null,"reblog":null,"content":"february 2 is the day to give flowers to Iemanj\u00e1. #salvador<\/a> #bahia<\/a> #brazil<\/a> #iemanja<\/a>","created_at":"2020-03-03T02:10:14.000000Z","emojis":[],"replies_count":0,"reblogs_count":0,"favourites_count":1,"reblogged":null,"favourited":null,"muted":null,"sensitive":false,"spoiler_text":"","visibility":"public","mentions":[],"tags":[{"name":"salvador","url":"https:\/\/pixelfed.de\/discover\/tags\/salvador"},{"name":"bahia","url":"https:\/\/pixelfed.de\/discover\/tags\/bahia"},{"name":"brazil","url":"https:\/\/pixelfed.de\/discover\/tags\/brazil"},{"name":"iemanja","url":"https:\/\/pixelfed.de\/discover\/tags\/iemanja"}],"card":null,"poll":null,"application":{"name":"web","website":null},"language":null,"pinned":null,"account":{"id":"137257212828585984","username":"fegrimaldi","acct":"fegrimaldi","display_name":"Fernanda Grimaldi","locked":false,"created_at":"2020-02-23T18:11:09.000000Z","followers_count":2,"following_count":7,"statuses_count":2,"note":"a little piece of Bahia in the fediverse.","url":"https:\/\/pixelfed.de\/fegrimaldi","avatar":"https:\/\/pixelfed.de\/storage\/avatars\/013\/725\/721\/282\/858\/598\/4\/oUPBit0TJso1xNhJfFqg_avatar.jpeg?v=d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35","avatar_static":"https:\/\/pixelfed.de\/storage\/avatars\/013\/725\/721\/282\/858\/598\/4\/oUPBit0TJso1xNhJfFqg_avatar.jpeg?v=d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35","header":"","header_static":"","emojis":[],"moved":null,"fields":null,"bot":false,"software":"pixelfed","is_admin":false},"media_attachments":[{"id":"15886","type":"image","url":"https:\/\/pixelfed.de\/storage\/m\/113a3e2124a33b1f5511e531953f5ee48456e0c7\/feb878b4bd60b85ac840670c6b9c809fd76b628b\/lYMrx0WF8LDqn0vTRgNJaRs7stMKtAXrgzpMrWEr.jpeg","remote_url":null,"preview_url":"https:\/\/pixelfed.de\/storage\/m\/113a3e2124a33b1f5511e531953f5ee48456e0c7\/feb878b4bd60b85ac840670c6b9c809fd76b628b\/lYMrx0WF8LDqn0vTRgNJaRs7stMKtAXrgzpMrWEr_thumb.jpeg","text_url":null,"meta":null,"description":null}]}]""" ) + )) + val call: Call> = PixelfedAPI.create("http://localhost:8089") + .timelinePublic(null, null, null, null, null) + val statuses = call.execute().body() + val f = statuses!![0] + val referenceFirstStatus = Status(id="140364967936397312", uri="https://pixelfed.de/p/Miike/140364967936397312", + created_at="2020-03-03T08:00:16.000000Z", + account=Account(id="115114166443970560", username="Miike", acct="Miike", + url="https://pixelfed.de/Miike", display_name="Miike Duart", note="", + avatar="https://pixelfed.de/storage/avatars/011/511/416/644/397/056/0/ZhaopLJWTWJ3hsVCS5pS_avatar.png?v=d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35", + avatar_static="https://pixelfed.de/storage/avatars/011/511/416/644/397/056/0/ZhaopLJWTWJ3hsVCS5pS_avatar.png?v=d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35", + header="", header_static="", locked=false, emojis= emptyList(), discoverable=false, + created_at="2019-12-24T15:42:35.000000Z", statuses_count=71, followers_count=14, + following_count=0, moved=null, fields=null, bot=false, source=null), + content="""Day 8 #rotavicentina #hiking #nature""", + visibility=Status.Visibility.public, sensitive=false, spoiler_text="", + media_attachments= listOf(Attachment(id="15888", type= Attachment.AttachmentType.image, url="https://pixelfed.de/storage/m/113a3e2124a33b1f5511e531953f5ee48456e0c7/34dd6d9fb1762dac8c7ddeeaf789d2d8fa083c9f/JtjO0eAbELpgO1UZqF5ydrKbCKRVyJUM1WAaqIeB.jpeg", + preview_url="https://pixelfed.de/storage/m/113a3e2124a33b1f5511e531953f5ee48456e0c7/34dd6d9fb1762dac8c7ddeeaf789d2d8fa083c9f/JtjO0eAbELpgO1UZqF5ydrKbCKRVyJUM1WAaqIeB_thumb.jpeg", + remote_url=null, text_url=null, description=null, blurhash=null)), + application= Application(name="web", website=null, vapid_key=null), mentions=emptyList(), + tags= listOf(Tag(name="hiking", url="https://pixelfed.de/discover/tags/hiking", history=null), Tag(name="nature", url="https://pixelfed.de/discover/tags/nature", history=null), Tag(name="rotavicentina", url="https://pixelfed.de/discover/tags/rotavicentina", history=null)), + emojis= emptyList(), reblogs_count=0, favourites_count=0, replies_count=0, url="https://pixelfed.de/p/Miike/140364967936397312", + in_reply_to_id=null, in_reply_to_account=null, reblog=null, poll=null, card=null, language=null, text=null, favourited=false, reblogged=false, muted=false, bookmarked=false, pinned=false) + assertEquals(referenceFirstStatus, f) + //same as before, but otherwise coverage is not detected for the data classes + assert( + ((f.id=="140364967936397312" + && f.uri=="https://pixelfed.de/p/Miike/140364967936397312" + && f.created_at=="2020-03-03T08:00:16.000000Z" + && f.account.id=="115114166443970560"&& f.account.username=="Miike"&& f.account.acct=="Miike" && + f.account.url=="https://pixelfed.de/Miike"&& f.account.display_name=="Miike Duart"&& f.account.note==""&& + f.account.avatar=="https://pixelfed.de/storage/avatars/011/511/416/644/397/056/0/ZhaopLJWTWJ3hsVCS5pS_avatar.png?v=d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35"&& + f.account.avatar_static=="https://pixelfed.de/storage/avatars/011/511/416/644/397/056/0/ZhaopLJWTWJ3hsVCS5pS_avatar.png?v=d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35"&& + f.account.header==""&& f.account.header_static=="") && !f.account.locked && f.account.emojis== emptyList() && !f.account.discoverable && f.account.created_at=="2019-12-24T15:42:35.000000Z" && f.account.statuses_count==71 && f.account.followers_count==14 && f.account.following_count==0 && f.account.moved==null && f.account.fields==null && !f.account.bot && f.account.source==null && f.content == """Day 8 #rotavicentina #hiking #nature""" && f.visibility==Status.Visibility.public) && !f.sensitive && f.spoiler_text=="" + ) + val attchmnt = f.media_attachments[0] + assert(attchmnt.id == "15888" && attchmnt.type == Attachment.AttachmentType.image && attchmnt.url=="https://pixelfed.de/storage/m/113a3e2124a33b1f5511e531953f5ee48456e0c7/34dd6d9fb1762dac8c7ddeeaf789d2d8fa083c9f/JtjO0eAbELpgO1UZqF5ydrKbCKRVyJUM1WAaqIeB.jpeg" && + attchmnt.preview_url =="https://pixelfed.de/storage/m/113a3e2124a33b1f5511e531953f5ee48456e0c7/34dd6d9fb1762dac8c7ddeeaf789d2d8fa083c9f/JtjO0eAbELpgO1UZqF5ydrKbCKRVyJUM1WAaqIeB_thumb.jpeg" && + attchmnt.remote_url ==null && attchmnt.text_url==null && attchmnt.description==null && attchmnt.blurhash==null ) + assert( f.application.name=="web" && f.application.website==null && f.application.vapid_key==null && f.mentions==emptyList()) + + val firstTag =f.tags[0] + val secondTag= f.tags[1] + val thirdTag = f.tags[2] + + assert(firstTag.name=="hiking" && firstTag.url=="https://pixelfed.de/discover/tags/hiking" && firstTag.history==null && + f.emojis== emptyList() && f.reblogs_count==0 && f.favourites_count==0&& f.replies_count==0 && f.url=="https://pixelfed.de/p/Miike/140364967936397312") + assert(f.in_reply_to_id==null && f.in_reply_to_account==null && f.reblog==null && f.poll==null && f.card==null && f.language==null && f.text==null && !f.favourited && !f.reblogged && !f.muted && !f.bookmarked && !f.pinned) + } +} \ No newline at end of file