diff --git a/src/main/java/com/spotify/github/v3/activity/events/StatusEvent.java b/src/main/java/com/spotify/github/v3/activity/events/StatusEvent.java index 599f5963..a43123d1 100644 --- a/src/main/java/com/spotify/github/v3/activity/events/StatusEvent.java +++ b/src/main/java/com/spotify/github/v3/activity/events/StatusEvent.java @@ -20,6 +20,9 @@ package com.spotify.github.v3.activity.events; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.spotify.github.GithubStyle; import com.spotify.github.UpdateTracking; import com.spotify.github.v3.repos.Branch; import com.spotify.github.v3.repos.CommitItem; @@ -27,12 +30,17 @@ import java.util.List; import java.util.Optional; import javax.annotation.Nullable; +import org.immutables.value.Value; /** * Triggered when the status of a Git commit changes. * *

Events of this type are not visible in timelines. These events are only used to trigger hooks. */ +@Value.Immutable +@GithubStyle +@JsonSerialize(as = ImmutableStatusEvent.class) +@JsonDeserialize(as = ImmutableStatusEvent.class) public interface StatusEvent extends BaseEvent, UpdateTracking { /** Status event id */ diff --git a/src/test/java/com/spotify/github/v3/activity/events/PullRequestEventTest.java b/src/test/java/com/spotify/github/v3/activity/events/PullRequestEventTest.java index 1669f18b..b558428d 100644 --- a/src/test/java/com/spotify/github/v3/activity/events/PullRequestEventTest.java +++ b/src/test/java/com/spotify/github/v3/activity/events/PullRequestEventTest.java @@ -33,11 +33,9 @@ public class PullRequestEventTest { - private String fixture; - @Test public void testDeserialization() throws IOException { - fixture = + String fixture = Resources.toString( getResource(this.getClass(), "fixtures/pull_request_event.json"), defaultCharset()); final PullRequestEvent prEvent = Json.create().fromJson(fixture, PullRequestEvent.class); diff --git a/src/test/java/com/spotify/github/v3/activity/events/StatusEventTest.java b/src/test/java/com/spotify/github/v3/activity/events/StatusEventTest.java new file mode 100644 index 00000000..0a686533 --- /dev/null +++ b/src/test/java/com/spotify/github/v3/activity/events/StatusEventTest.java @@ -0,0 +1,44 @@ +/*- + * -\-\- + * github-client + * -- + * Copyright (C) 2016 - 2020 Spotify AB + * -- + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * -/-/- + */ + +package com.spotify.github.v3.activity.events; + +import static com.google.common.io.Resources.getResource; +import static java.nio.charset.Charset.defaultCharset; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; + +import com.google.common.io.Resources; +import com.spotify.github.jackson.Json; +import java.io.IOException; +import org.junit.Test; + +public class StatusEventTest { + @Test + public void testDeserialization() throws IOException { + String fixture = + Resources.toString( + getResource(this.getClass(), "fixtures/status_event.json"), defaultCharset()); + final StatusEvent statusEvent = Json.create().fromJson(fixture, StatusEvent.class); + assertThat(statusEvent.context(), is("default")); + assertThat(statusEvent.sha(), is("9049f1265b7d61be4a8904a9a27120d2064dab3b")); + assertThat(statusEvent.state(), is("success")); + } +} \ No newline at end of file