From 58174da165d5b4b8264b0b23b57a9fc288c19c28 Mon Sep 17 00:00:00 2001 From: Henrique Truta Date: Mon, 27 Apr 2020 11:48:33 +0200 Subject: [PATCH 1/2] Add NON_ABSENT to MergeParams --- .../github/v3/prs/MergeParameters.java | 2 ++ .../github/v3/prs/PullRequestTest.java | 20 +++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/spotify/github/v3/prs/MergeParameters.java b/src/main/java/com/spotify/github/v3/prs/MergeParameters.java index 4a58c0a7..71c62be5 100644 --- a/src/main/java/com/spotify/github/v3/prs/MergeParameters.java +++ b/src/main/java/com/spotify/github/v3/prs/MergeParameters.java @@ -20,6 +20,7 @@ package com.spotify.github.v3.prs; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.spotify.github.GithubStyle; @@ -35,6 +36,7 @@ @GithubStyle @JsonSerialize(as = ImmutableMergeParameters.class) @JsonDeserialize(as = ImmutableMergeParameters.class) +@JsonInclude(JsonInclude.Include.NON_ABSENT) public abstract class MergeParameters { /** * SHA that pull request head must match to allow merge. diff --git a/src/test/java/com/spotify/github/v3/prs/PullRequestTest.java b/src/test/java/com/spotify/github/v3/prs/PullRequestTest.java index 97530dd3..fa1b4bea 100644 --- a/src/test/java/com/spotify/github/v3/prs/PullRequestTest.java +++ b/src/test/java/com/spotify/github/v3/prs/PullRequestTest.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -62,4 +62,20 @@ public void testSerializationMergeParams() throws IOException { assertThat(params.sha(), is(fixtureParams.sha())); assertThat(params.mergeMethod(), is(MergeMethod.merge)); } + + @Test + public void testDeserializationMergeParams() throws IOException { + final MergeParameters params = ImmutableMergeParameters.builder() + .commitMessage("a message") + .sha("6dcb09b5b57875f334f61aebed695e2e4193db5e") + .build(); + final String json = Json.create().toJson(params); + + assertThat( + json, + is( + "{\"sha\":\"6dcb09b5b57875f334f61aebed695e2e4193db5e\",\"commit_message\":\"a message\",\"merge_method\":\"merge\"}")); + + System.out.println(json); + } } From c7c15963bf9f748cceac121e0762a626703735b7 Mon Sep 17 00:00:00 2001 From: Henrique Truta Date: Mon, 27 Apr 2020 11:49:42 +0200 Subject: [PATCH 2/2] update header --- .../java/com/spotify/github/v3/prs/PullRequestTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/spotify/github/v3/prs/PullRequestTest.java b/src/test/java/com/spotify/github/v3/prs/PullRequestTest.java index fa1b4bea..2f6c0464 100644 --- a/src/test/java/com/spotify/github/v3/prs/PullRequestTest.java +++ b/src/test/java/com/spotify/github/v3/prs/PullRequestTest.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -64,7 +64,7 @@ public void testSerializationMergeParams() throws IOException { } @Test - public void testDeserializationMergeParams() throws IOException { + public void testDeserializationMergeParamsOmitsFields() throws IOException { final MergeParameters params = ImmutableMergeParameters.builder() .commitMessage("a message") .sha("6dcb09b5b57875f334f61aebed695e2e4193db5e")