|
24 | 24 | import static java.nio.charset.Charset.defaultCharset;
|
25 | 25 | import static org.hamcrest.MatcherAssert.assertThat;
|
26 | 26 | import static org.hamcrest.core.Is.is;
|
| 27 | +import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 28 | +import static org.junit.jupiter.api.Assertions.assertNull; |
27 | 29 |
|
28 | 30 | import com.google.common.io.Resources;
|
29 | 31 | import com.spotify.github.jackson.Json;
|
@@ -85,6 +87,36 @@ public void testSerializationMergeParams() throws IOException {
|
85 | 87 | assertThat(params.mergeMethod(), is(MergeMethod.merge));
|
86 | 88 | }
|
87 | 89 |
|
| 90 | + @Test |
| 91 | + public void testSerializationAutoMergeDisabled() throws IOException { |
| 92 | + String fixture = |
| 93 | + Resources.toString(getResource(this.getClass(), "pull_request_automerge_disabled.json"), defaultCharset()); |
| 94 | + final PullRequest pr = Json.create().fromJson(fixture, PullRequest.class); |
| 95 | + |
| 96 | + assertThat(pr.id(), is(2439836648L)); |
| 97 | + assertThat(pr.head().sha(), is("881ef333d1ffc01869b666f13d3b37d7af92b9a2")); |
| 98 | + assertThat(pr.merged(), is(false)); |
| 99 | + assertThat(pr.mergeable().get(), is(true)); |
| 100 | + assertThat(pr.draft(), is(Optional.of(true))); |
| 101 | + assertNull(pr.autoMerge()); |
| 102 | + } |
| 103 | + |
| 104 | + @Test |
| 105 | + public void testSerializationAutoMergeEnabled() throws IOException { |
| 106 | + String fixture = |
| 107 | + Resources.toString(getResource(this.getClass(), "pull_request_automerge_enabled.json"), defaultCharset()); |
| 108 | + final PullRequest pr = Json.create().fromJson(fixture, PullRequest.class); |
| 109 | + |
| 110 | + assertThat(pr.id(), is(2439836648L)); |
| 111 | + assertThat(pr.head().sha(), is("881ef333d1ffc01869b666f13d3b37d7af92b9a2")); |
| 112 | + assertThat(pr.merged(), is(false)); |
| 113 | + assertThat(pr.mergeable().get(), is(true)); |
| 114 | + assertThat(pr.draft(), is(Optional.of(false))); |
| 115 | + assertNotNull(pr.autoMerge()); |
| 116 | + assertThat(pr.autoMerge().enabledBy().login(), is("octocat")); |
| 117 | + assertThat(pr.autoMerge().mergeMethod(), is("squash")); |
| 118 | + } |
| 119 | + |
88 | 120 | @Test
|
89 | 121 | public void testDeserializationMergeParamsOmitsFields() throws IOException {
|
90 | 122 | final MergeParameters params = ImmutableMergeParameters.builder()
|
|
0 commit comments