{"action":"created","comment":{"url":"https://api.github.com/repos/square/misk/pulls/comments/168909467","pull_request_review_id":97361905,"id":168909467,"diff_hunk":"@@ -0,0 +1,171 @@\n+package misk.moshi.wire\n+\n+import com.google.inject.util.Modules\n+import com.squareup.moshi.Moshi\n+import com.squareup.protos.test.parsing.Shipment\n+import com.squareup.protos.test.parsing.Warehouse\n+import misk.moshi.MoshiModule\n+import misk.testing.MiskTest\n+import misk.testing.MiskTestModule\n+import okio.ByteString\n+import org.assertj.core.api.Assertions.assertThat\n+import org.junit.jupiter.api.Test\n+import javax.inject.Inject\n+\n+@MiskTest(startService = false)\n+internal class WireMessageAdapterTest {\n+    @MiskTestModule\n+    val module = Modules.combine(MoshiModule())\n+\n+    @Inject\n+    lateinit var moshi: Moshi\n+\n+    @Test\n+    fun simpleTypes() {\n+        val warehouseAdapter = moshi.adapter(Warehouse::class.java)\n+\n+        val warehouse = Warehouse.Builder()\n+                .warehouse_id(1014L)\n+                .warehouse_token(\"AAAA\")\n+                .build()\n+\n+        assertThat(warehouseAdapter.toJson(warehouse))\n+                .isEqualTo(\"\"\"{\"warehouse_id\":1014,\"warehouse_token\":\"AAAA\"}\"\"\")\n+        assertThat(warehouseAdapter.fromJson(\"\"\"{\"warehouse_id\":1014,\"warehouse_token\":\"AAAA\"}\"\"\"))\n+                .isEqualTo(warehouse)\n+    }\n+\n+    @Test\n+    fun nestedTypes() {\n+        val shipmentAdapter = moshi.adapter(Shipment::class.java)\n+\n+        val shipment = Shipment.Builder()\n+                .shipment_id(100075)\n+                .shipment_token(\"P_AAAAA\")\n+                .status(Shipment.State.DELIVERING)\n+                .source(Warehouse.Builder()\n+                        .warehouse_id(9999L)\n+                        .warehouse_token(\"C_RANDY\")\n+                        .build())\n+                .destination(Warehouse.Builder()\n+                        .warehouse_id(7777L)\n+                        .warehouse_token(\"C_CATHY\")\n+                        .build())\n+                .deleted(true)\n+                .load_ratio(0.75)\n+                .notes(listOf(\"Note A\", \"Note B\", \"Note C\"))\n+                .build()\n+\n+        val jsonText = shipmentAdapter.indent(\" \").toJson(shipment)\n+        assertThat(jsonText).isEqualTo(\"\"\"","path":"misk/src/test/kotlin/misk/moshi/wire/WireMessageAdapterTest.kt","position":60,"original_position":60,"commit_id":"42603e1c8c1dec20af82e01c579f85e690a5bcf1","original_commit_id":"42603e1c8c1dec20af82e01c579f85e690a5bcf1","user":{"login":"swankjesse","id":133019,"avatar_url":"https://avatars3.githubusercontent.com/u/133019?v=4","gravatar_id":"","url":"https://api.github.com/users/swankjesse","html_url":"https://github.com/swankjesse","followers_url":"https://api.github.com/users/swankjesse/followers","following_url":"https://api.github.com/users/swankjesse/following{/other_user}","gists_url":"https://api.github.com/users/swankjesse/gists{/gist_id}","starred_url":"https://api.github.com/users/swankjesse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swankjesse/subscriptions","organizations_url":"https://api.github.com/users/swankjesse/orgs","repos_url":"https://api.github.com/users/swankjesse/repos","events_url":"https://api.github.com/users/swankjesse/events{/privacy}","received_events_url":"https://api.github.com/users/swankjesse/received_events","type":"User","site_admin":false},"body":"You can use trimPrefix() or whatever if you'd like. \r\n\r\nExample:\r\nhttps://github.com/square/kotlinpoet/blob/master/src/test/java/com/squareup/kotlinpoet/KotlinPoetTest.kt","created_at":"2018-02-17T02:34:13Z","updated_at":"2018-02-17T02:36:24Z","html_url":"https://github.com/square/misk/pull/102#discussion_r168909467","pull_request_url":"https://api.github.com/repos/square/misk/pulls/102","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/square/misk/pulls/comments/168909467"},"html":{"href":"https://github.com/square/misk/pull/102#discussion_r168909467"},"pull_request":{"href":"https://api.github.com/repos/square/misk/pulls/102"}}},"pull_request":{"url":"https://api.github.com/repos/square/misk/pulls/102","id":169757107,"html_url":"https://github.com/square/misk/pull/102","diff_url":"https://github.com/square/misk/pull/102.diff","patch_url":"https://github.com/square/misk/pull/102.patch","issue_url":"https://api.github.com/repos/square/misk/issues/102","number":102,"state":"open","locked":false,"title":"Explicit moshi support for wire","user":{"login":"mmihic","id":392793,"avatar_url":"https://avatars0.githubusercontent.com/u/392793?v=4","gravatar_id":"","url":"https://api.github.com/users/mmihic","html_url":"https://github.com/mmihic","followers_url":"https://api.github.com/users/mmihic/followers","following_url":"https://api.github.com/users/mmihic/following{/other_user}","gists_url":"https://api.github.com/users/mmihic/gists{/gist_id}","starred_url":"https://api.github.com/users/mmihic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmihic/subscriptions","organizations_url":"https://api.github.com/users/mmihic/orgs","repos_url":"https://api.github.com/users/mmihic/repos","events_url":"https://api.github.com/users/mmihic/events{/privacy}","received_events_url":"https://api.github.com/users/mmihic/received_events","type":"User","site_admin":false},"body":"Adds a JsonAdapter for wire Message types that does the right thing in\r\nbuilding those types (i.e. uses the Builder, creates empty lists for\r\nrepeated fields missing from the json). Also provides a ByteString\r\nJsonAdapter that emits the bytes as a base64 URL-safe string.","created_at":"2018-02-17T00:41:15Z","updated_at":"2018-02-17T02:36:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e9b5d12f92e2db2f0d77181fbbeaee85250bd050","assignee":null,"assignees":[],"requested_reviewers":[{"login":"ryanhall07","id":4166092,"avatar_url":"https://avatars2.githubusercontent.com/u/4166092?v=4","gravatar_id":"","url":"https://api.github.com/users/ryanhall07","html_url":"https://github.com/ryanhall07","followers_url":"https://api.github.com/users/ryanhall07/followers","following_url":"https://api.github.com/users/ryanhall07/following{/other_user}","gists_url":"https://api.github.com/users/ryanhall07/gists{/gist_id}","starred_url":"https://api.github.com/users/ryanhall07/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryanhall07/subscriptions","organizations_url":"https://api.github.com/users/ryanhall07/orgs","repos_url":"https://api.github.com/users/ryanhall07/repos","events_url":"https://api.github.com/users/ryanhall07/events{/privacy}","received_events_url":"https://api.github.com/users/ryanhall07/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/square/misk/pulls/102/commits","review_comments_url":"https://api.github.com/repos/square/misk/pulls/102/comments","review_comment_url":"https://api.github.com/repos/square/misk/pulls/comments{/number}","comments_url":"https://api.github.com/repos/square/misk/issues/102/comments","statuses_url":"https://api.github.com/repos/square/misk/statuses/42603e1c8c1dec20af82e01c579f85e690a5bcf1","head":{"label":"square:mmihic/moshi-wire","ref":"mmihic/moshi-wire","sha":"42603e1c8c1dec20af82e01c579f85e690a5bcf1","user":{"login":"square","id":82592,"avatar_url":"https://avatars0.githubusercontent.com/u/82592?v=4","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"repo":{"id":113107217,"name":"misk","full_name":"square/misk","owner":{"login":"square","id":82592,"avatar_url":"https://avatars0.githubusercontent.com/u/82592?v=4","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/square/misk","description":null,"fork":false,"url":"https://api.github.com/repos/square/misk","forks_url":"https://api.github.com/repos/square/misk/forks","keys_url":"https://api.github.com/repos/square/misk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/square/misk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/square/misk/teams","hooks_url":"https://api.github.com/repos/square/misk/hooks","issue_events_url":"https://api.github.com/repos/square/misk/issues/events{/number}","events_url":"https://api.github.com/repos/square/misk/events","assignees_url":"https://api.github.com/repos/square/misk/assignees{/user}","branches_url":"https://api.github.com/repos/square/misk/branches{/branch}","tags_url":"https://api.github.com/repos/square/misk/tags","blobs_url":"https://api.github.com/repos/square/misk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/square/misk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/square/misk/git/refs{/sha}","trees_url":"https://api.github.com/repos/square/misk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/square/misk/statuses/{sha}","languages_url":"https://api.github.com/repos/square/misk/languages","stargazers_url":"https://api.github.com/repos/square/misk/stargazers","contributors_url":"https://api.github.com/repos/square/misk/contributors","subscribers_url":"https://api.github.com/repos/square/misk/subscribers","subscription_url":"https://api.github.com/repos/square/misk/subscription","commits_url":"https://api.github.com/repos/square/misk/commits{/sha}","git_commits_url":"https://api.github.com/repos/square/misk/git/commits{/sha}","comments_url":"https://api.github.com/repos/square/misk/comments{/number}","issue_comment_url":"https://api.github.com/repos/square/misk/issues/comments{/number}","contents_url":"https://api.github.com/repos/square/misk/contents/{+path}","compare_url":"https://api.github.com/repos/square/misk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/square/misk/merges","archive_url":"https://api.github.com/repos/square/misk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/square/misk/downloads","issues_url":"https://api.github.com/repos/square/misk/issues{/number}","pulls_url":"https://api.github.com/repos/square/misk/pulls{/number}","milestones_url":"https://api.github.com/repos/square/misk/milestones{/number}","notifications_url":"https://api.github.com/repos/square/misk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/square/misk/labels{/name}","releases_url":"https://api.github.com/repos/square/misk/releases{/id}","deployments_url":"https://api.github.com/repos/square/misk/deployments","created_at":"2017-12-04T23:31:52Z","updated_at":"2018-02-12T02:49:43Z","pushed_at":"2018-02-17T02:10:23Z","git_url":"git://github.com/square/misk.git","ssh_url":"git@github.com:square/misk.git","clone_url":"https://github.com/square/misk.git","svn_url":"https://github.com/square/misk","homepage":null,"size":435,"stargazers_count":28,"watchers_count":28,"language":"Kotlin","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":28,"license":null,"forks":3,"open_issues":28,"watchers":28,"default_branch":"master"}},"base":{"label":"square:master","ref":"master","sha":"f137d8856971445076f698d72bbc030eb332f9a8","user":{"login":"square","id":82592,"avatar_url":"https://avatars0.githubusercontent.com/u/82592?v=4","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"repo":{"id":113107217,"name":"misk","full_name":"square/misk","owner":{"login":"square","id":82592,"avatar_url":"https://avatars0.githubusercontent.com/u/82592?v=4","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/square/misk","description":null,"fork":false,"url":"https://api.github.com/repos/square/misk","forks_url":"https://api.github.com/repos/square/misk/forks","keys_url":"https://api.github.com/repos/square/misk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/square/misk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/square/misk/teams","hooks_url":"https://api.github.com/repos/square/misk/hooks","issue_events_url":"https://api.github.com/repos/square/misk/issues/events{/number}","events_url":"https://api.github.com/repos/square/misk/events","assignees_url":"https://api.github.com/repos/square/misk/assignees{/user}","branches_url":"https://api.github.com/repos/square/misk/branches{/branch}","tags_url":"https://api.github.com/repos/square/misk/tags","blobs_url":"https://api.github.com/repos/square/misk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/square/misk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/square/misk/git/refs{/sha}","trees_url":"https://api.github.com/repos/square/misk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/square/misk/statuses/{sha}","languages_url":"https://api.github.com/repos/square/misk/languages","stargazers_url":"https://api.github.com/repos/square/misk/stargazers","contributors_url":"https://api.github.com/repos/square/misk/contributors","subscribers_url":"https://api.github.com/repos/square/misk/subscribers","subscription_url":"https://api.github.com/repos/square/misk/subscription","commits_url":"https://api.github.com/repos/square/misk/commits{/sha}","git_commits_url":"https://api.github.com/repos/square/misk/git/commits{/sha}","comments_url":"https://api.github.com/repos/square/misk/comments{/number}","issue_comment_url":"https://api.github.com/repos/square/misk/issues/comments{/number}","contents_url":"https://api.github.com/repos/square/misk/contents/{+path}","compare_url":"https://api.github.com/repos/square/misk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/square/misk/merges","archive_url":"https://api.github.com/repos/square/misk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/square/misk/downloads","issues_url":"https://api.github.com/repos/square/misk/issues{/number}","pulls_url":"https://api.github.com/repos/square/misk/pulls{/number}","milestones_url":"https://api.github.com/repos/square/misk/milestones{/number}","notifications_url":"https://api.github.com/repos/square/misk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/square/misk/labels{/name}","releases_url":"https://api.github.com/repos/square/misk/releases{/id}","deployments_url":"https://api.github.com/repos/square/misk/deployments","created_at":"2017-12-04T23:31:52Z","updated_at":"2018-02-12T02:49:43Z","pushed_at":"2018-02-17T02:10:23Z","git_url":"git://github.com/square/misk.git","ssh_url":"git@github.com:square/misk.git","clone_url":"https://github.com/square/misk.git","svn_url":"https://github.com/square/misk","homepage":null,"size":435,"stargazers_count":28,"watchers_count":28,"language":"Kotlin","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":28,"license":null,"forks":3,"open_issues":28,"watchers":28,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/square/misk/pulls/102"},"html":{"href":"https://github.com/square/misk/pull/102"},"issue":{"href":"https://api.github.com/repos/square/misk/issues/102"},"comments":{"href":"https://api.github.com/repos/square/misk/issues/102/comments"},"review_comments":{"href":"https://api.github.com/repos/square/misk/pulls/102/comments"},"review_comment":{"href":"https://api.github.com/repos/square/misk/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/square/misk/pulls/102/commits"},"statuses":{"href":"https://api.github.com/repos/square/misk/statuses/42603e1c8c1dec20af82e01c579f85e690a5bcf1"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"swankjesse"}}