{"action":"created","comment":{"url":"https://api.github.com/repos/square/moshi/pulls/comments/28211242","id":28211242,"diff_hunk":"@@ -0,0 +1,73 @@\n+package com.squareup.moshi;\n+\n+import java.io.IOException;\n+import okio.Buffer;\n+import org.junit.Test;\n+\n+import static com.squareup.moshi.Util.NO_ANNOTATIONS;\n+import static org.assertj.core.api.Assertions.assertThat;\n+\n+public class EnumJsonAdapterTest {\n+  private final Moshi moshi = new Moshi.Builder().build();\n+\n+  enum Roshambo {\n+    ROCK,\n+    PAPER,\n+    SCISSORS\n+  }\n+\n+  @Test public void basics() throws Exception {\n+    JsonAdapter<Roshambo> adapter = moshi.adapter(Roshambo.class).lenient();\n+    assertThat(adapter.fromJson(\"\\\"ROCK\\\"\")).isEqualTo(Roshambo.ROCK);\n+    assertThat(adapter.toJson(Roshambo.PAPER)).isEqualTo(\"\\\"PAPER\\\"\");\n+  }\n+\n+  @Test public void invalidInput() throws Exception {\n+    JsonAdapter<Roshambo> adapter = moshi.adapter(Roshambo.class).lenient();\n+    assertThat(adapter.fromJson(\"\\\"Lizard\\\"\")).isNull();\n+    assertThat(adapter.fromJson(\"\\\"SPOCK\\\"\")).isNull();\n+  }\n+\n+  @Test public void nulls() throws Exception {\n+    JsonAdapter<Roshambo> adapter = moshi.adapter(Roshambo.class).lenient();\n+    assertThat(adapter.fromJson(\"null\")).isNull();\n+    assertThat(adapter.toJson(null)).isEqualTo(\"null\");\n+  }\n+\n+  static class Game {\n+    Roshambo player1;\n+    Roshambo player2;\n+  }\n+\n+  @Test public void enumInObject() throws Exception {","path":"moshi/src/test/java/com/squareup/moshi/EnumJsonAdapterTest.java","position":42,"original_position":42,"commit_id":"064dfbb5ec7c6ed8e60c91776ce0a4e90a29ff9e","original_commit_id":"064dfbb5ec7c6ed8e60c91776ce0a4e90a29ff9e","user":{"login":"swankjesse","id":133019,"avatar_url":"https://avatars.githubusercontent.com/u/133019?v=3","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":"I don't think this test is necessary; we already test composition in other tests.","created_at":"2015-04-13T02:09:47Z","updated_at":"2015-04-13T02:09:47Z","html_url":"https://github.com/square/moshi/pull/32#discussion_r28211242","pull_request_url":"https://api.github.com/repos/square/moshi/pulls/32","_links":{"self":{"href":"https://api.github.com/repos/square/moshi/pulls/comments/28211242"},"html":{"href":"https://github.com/square/moshi/pull/32#discussion_r28211242"},"pull_request":{"href":"https://api.github.com/repos/square/moshi/pulls/32"}}},"pull_request":{"url":"https://api.github.com/repos/square/moshi/pulls/32","id":33096272,"html_url":"https://github.com/square/moshi/pull/32","diff_url":"https://github.com/square/moshi/pull/32.diff","patch_url":"https://github.com/square/moshi/pull/32.patch","issue_url":"https://api.github.com/repos/square/moshi/issues/32","number":32,"state":"open","locked":false,"title":"EnumJsonAdapter","user":{"login":"dandc87","id":1239288,"avatar_url":"https://avatars.githubusercontent.com/u/1239288?v=3","gravatar_id":"","url":"https://api.github.com/users/dandc87","html_url":"https://github.com/dandc87","followers_url":"https://api.github.com/users/dandc87/followers","following_url":"https://api.github.com/users/dandc87/following{/other_user}","gists_url":"https://api.github.com/users/dandc87/gists{/gist_id}","starred_url":"https://api.github.com/users/dandc87/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dandc87/subscriptions","organizations_url":"https://api.github.com/users/dandc87/orgs","repos_url":"https://api.github.com/users/dandc87/repos","events_url":"https://api.github.com/users/dandc87/events{/privacy}","received_events_url":"https://api.github.com/users/dandc87/received_events","type":"User","site_admin":false},"body":"Enums from Strings","created_at":"2015-04-11T02:36:25Z","updated_at":"2015-04-13T02:09:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bd7c625957f8ddd83d18c06f3e83e54ab454c49d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/square/moshi/pulls/32/commits","review_comments_url":"https://api.github.com/repos/square/moshi/pulls/32/comments","review_comment_url":"https://api.github.com/repos/square/moshi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/square/moshi/issues/32/comments","statuses_url":"https://api.github.com/repos/square/moshi/statuses/064dfbb5ec7c6ed8e60c91776ce0a4e90a29ff9e","head":{"label":"dandc87:ak_enum_support","ref":"ak_enum_support","sha":"064dfbb5ec7c6ed8e60c91776ce0a4e90a29ff9e","user":{"login":"dandc87","id":1239288,"avatar_url":"https://avatars.githubusercontent.com/u/1239288?v=3","gravatar_id":"","url":"https://api.github.com/users/dandc87","html_url":"https://github.com/dandc87","followers_url":"https://api.github.com/users/dandc87/followers","following_url":"https://api.github.com/users/dandc87/following{/other_user}","gists_url":"https://api.github.com/users/dandc87/gists{/gist_id}","starred_url":"https://api.github.com/users/dandc87/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dandc87/subscriptions","organizations_url":"https://api.github.com/users/dandc87/orgs","repos_url":"https://api.github.com/users/dandc87/repos","events_url":"https://api.github.com/users/dandc87/events{/privacy}","received_events_url":"https://api.github.com/users/dandc87/received_events","type":"User","site_admin":false},"repo":{"id":33711064,"name":"moshi","full_name":"dandc87/moshi","owner":{"login":"dandc87","id":1239288,"avatar_url":"https://avatars.githubusercontent.com/u/1239288?v=3","gravatar_id":"","url":"https://api.github.com/users/dandc87","html_url":"https://github.com/dandc87","followers_url":"https://api.github.com/users/dandc87/followers","following_url":"https://api.github.com/users/dandc87/following{/other_user}","gists_url":"https://api.github.com/users/dandc87/gists{/gist_id}","starred_url":"https://api.github.com/users/dandc87/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dandc87/subscriptions","organizations_url":"https://api.github.com/users/dandc87/orgs","repos_url":"https://api.github.com/users/dandc87/repos","events_url":"https://api.github.com/users/dandc87/events{/privacy}","received_events_url":"https://api.github.com/users/dandc87/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dandc87/moshi","description":"A modern JSON library for Android and Java.","fork":true,"url":"https://api.github.com/repos/dandc87/moshi","forks_url":"https://api.github.com/repos/dandc87/moshi/forks","keys_url":"https://api.github.com/repos/dandc87/moshi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dandc87/moshi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dandc87/moshi/teams","hooks_url":"https://api.github.com/repos/dandc87/moshi/hooks","issue_events_url":"https://api.github.com/repos/dandc87/moshi/issues/events{/number}","events_url":"https://api.github.com/repos/dandc87/moshi/events","assignees_url":"https://api.github.com/repos/dandc87/moshi/assignees{/user}","branches_url":"https://api.github.com/repos/dandc87/moshi/branches{/branch}","tags_url":"https://api.github.com/repos/dandc87/moshi/tags","blobs_url":"https://api.github.com/repos/dandc87/moshi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dandc87/moshi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dandc87/moshi/git/refs{/sha}","trees_url":"https://api.github.com/repos/dandc87/moshi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dandc87/moshi/statuses/{sha}","languages_url":"https://api.github.com/repos/dandc87/moshi/languages","stargazers_url":"https://api.github.com/repos/dandc87/moshi/stargazers","contributors_url":"https://api.github.com/repos/dandc87/moshi/contributors","subscribers_url":"https://api.github.com/repos/dandc87/moshi/subscribers","subscription_url":"https://api.github.com/repos/dandc87/moshi/subscription","commits_url":"https://api.github.com/repos/dandc87/moshi/commits{/sha}","git_commits_url":"https://api.github.com/repos/dandc87/moshi/git/commits{/sha}","comments_url":"https://api.github.com/repos/dandc87/moshi/comments{/number}","issue_comment_url":"https://api.github.com/repos/dandc87/moshi/issues/comments{/number}","contents_url":"https://api.github.com/repos/dandc87/moshi/contents/{+path}","compare_url":"https://api.github.com/repos/dandc87/moshi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dandc87/moshi/merges","archive_url":"https://api.github.com/repos/dandc87/moshi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dandc87/moshi/downloads","issues_url":"https://api.github.com/repos/dandc87/moshi/issues{/number}","pulls_url":"https://api.github.com/repos/dandc87/moshi/pulls{/number}","milestones_url":"https://api.github.com/repos/dandc87/moshi/milestones{/number}","notifications_url":"https://api.github.com/repos/dandc87/moshi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dandc87/moshi/labels{/name}","releases_url":"https://api.github.com/repos/dandc87/moshi/releases{/id}","created_at":"2015-04-10T05:53:10Z","updated_at":"2015-04-12T20:08:32Z","pushed_at":"2015-04-12T20:10:23Z","git_url":"git://github.com/dandc87/moshi.git","ssh_url":"git@github.com:dandc87/moshi.git","clone_url":"https://github.com/dandc87/moshi.git","svn_url":"https://github.com/dandc87/moshi","homepage":"","size":635,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"square:master","ref":"master","sha":"eece10d46e0ace79ef6b3d937ef5eee3166915ec","user":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","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":22789601,"name":"moshi","full_name":"square/moshi","owner":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","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/moshi","description":"A modern JSON library for Android and Java.","fork":false,"url":"https://api.github.com/repos/square/moshi","forks_url":"https://api.github.com/repos/square/moshi/forks","keys_url":"https://api.github.com/repos/square/moshi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/square/moshi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/square/moshi/teams","hooks_url":"https://api.github.com/repos/square/moshi/hooks","issue_events_url":"https://api.github.com/repos/square/moshi/issues/events{/number}","events_url":"https://api.github.com/repos/square/moshi/events","assignees_url":"https://api.github.com/repos/square/moshi/assignees{/user}","branches_url":"https://api.github.com/repos/square/moshi/branches{/branch}","tags_url":"https://api.github.com/repos/square/moshi/tags","blobs_url":"https://api.github.com/repos/square/moshi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/square/moshi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/square/moshi/git/refs{/sha}","trees_url":"https://api.github.com/repos/square/moshi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/square/moshi/statuses/{sha}","languages_url":"https://api.github.com/repos/square/moshi/languages","stargazers_url":"https://api.github.com/repos/square/moshi/stargazers","contributors_url":"https://api.github.com/repos/square/moshi/contributors","subscribers_url":"https://api.github.com/repos/square/moshi/subscribers","subscription_url":"https://api.github.com/repos/square/moshi/subscription","commits_url":"https://api.github.com/repos/square/moshi/commits{/sha}","git_commits_url":"https://api.github.com/repos/square/moshi/git/commits{/sha}","comments_url":"https://api.github.com/repos/square/moshi/comments{/number}","issue_comment_url":"https://api.github.com/repos/square/moshi/issues/comments{/number}","contents_url":"https://api.github.com/repos/square/moshi/contents/{+path}","compare_url":"https://api.github.com/repos/square/moshi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/square/moshi/merges","archive_url":"https://api.github.com/repos/square/moshi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/square/moshi/downloads","issues_url":"https://api.github.com/repos/square/moshi/issues{/number}","pulls_url":"https://api.github.com/repos/square/moshi/pulls{/number}","milestones_url":"https://api.github.com/repos/square/moshi/milestones{/number}","notifications_url":"https://api.github.com/repos/square/moshi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/square/moshi/labels{/name}","releases_url":"https://api.github.com/repos/square/moshi/releases{/id}","created_at":"2014-08-09T15:58:42Z","updated_at":"2015-04-13T02:08:41Z","pushed_at":"2015-04-12T20:10:23Z","git_url":"git://github.com/square/moshi.git","ssh_url":"git@github.com:square/moshi.git","clone_url":"https://github.com/square/moshi.git","svn_url":"https://github.com/square/moshi","homepage":"","size":635,"stargazers_count":331,"watchers_count":331,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":9,"forks":10,"open_issues":9,"watchers":331,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/square/moshi/pulls/32"},"html":{"href":"https://github.com/square/moshi/pull/32"},"issue":{"href":"https://api.github.com/repos/square/moshi/issues/32"},"comments":{"href":"https://api.github.com/repos/square/moshi/issues/32/comments"},"review_comments":{"href":"https://api.github.com/repos/square/moshi/pulls/32/comments"},"review_comment":{"href":"https://api.github.com/repos/square/moshi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/square/moshi/pulls/32/commits"},"statuses":{"href":"https://api.github.com/repos/square/moshi/statuses/064dfbb5ec7c6ed8e60c91776ce0a4e90a29ff9e"}}}}