Skip to content

Commit 92c7059

Browse files
committed
Add StatusEvent properties
1 parent 73c93c1 commit 92c7059

3 files changed

Lines changed: 33 additions & 3 deletions

File tree

src/main/java/com/spotify/github/v3/activity/events/StatusEvent.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,27 @@
2020

2121
package com.spotify.github.v3.activity.events;
2222

23+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
24+
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
25+
import com.spotify.github.GithubStyle;
2326
import com.spotify.github.UpdateTracking;
2427
import com.spotify.github.v3.repos.Branch;
2528
import com.spotify.github.v3.repos.CommitItem;
2629
import java.net.URI;
2730
import java.util.List;
2831
import java.util.Optional;
2932
import javax.annotation.Nullable;
33+
import org.immutables.value.Value;
3034

3135
/**
3236
* Triggered when the status of a Git commit changes.
3337
*
3438
* <p>Events of this type are not visible in timelines. These events are only used to trigger hooks.
3539
*/
40+
@Value.Immutable
41+
@GithubStyle
42+
@JsonSerialize(as = ImmutableStatusEvent.class)
43+
@JsonDeserialize(as = ImmutableStatusEvent.class)
3644
public interface StatusEvent extends BaseEvent, UpdateTracking {
3745

3846
/** Status event id */

src/test/java/com/spotify/github/v3/activity/events/PullRequestEventTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,9 @@
3333

3434
public class PullRequestEventTest {
3535

36-
private String fixture;
37-
3836
@Test
3937
public void testDeserialization() throws IOException {
40-
fixture =
38+
String fixture =
4139
Resources.toString(
4240
getResource(this.getClass(), "fixtures/pull_request_event.json"), defaultCharset());
4341
final PullRequestEvent prEvent = Json.create().fromJson(fixture, PullRequestEvent.class);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.spotify.github.v3.activity.events;
2+
3+
import static com.google.common.io.Resources.getResource;
4+
import static java.nio.charset.Charset.defaultCharset;
5+
import static org.hamcrest.MatcherAssert.assertThat;
6+
import static org.hamcrest.core.Is.is;
7+
8+
import com.google.common.io.Resources;
9+
import com.spotify.github.jackson.Json;
10+
import java.io.IOException;
11+
import org.junit.Test;
12+
13+
public class StatusEventTest {
14+
@Test
15+
public void testDeserialization() throws IOException {
16+
String fixture =
17+
Resources.toString(
18+
getResource(this.getClass(), "fixtures/status_event.json"), defaultCharset());
19+
final StatusEvent statusEvent = Json.create().fromJson(fixture, StatusEvent.class);
20+
assertThat(statusEvent.context(), is("default"));
21+
assertThat(statusEvent.sha(), is("9049f1265b7d61be4a8904a9a27120d2064dab3b"));
22+
assertThat(statusEvent.state(), is("success"));
23+
}
24+
}

0 commit comments

Comments
 (0)