Skip to content

Commit d358965

Browse files
Add StatusEvent properties (spotify#11)
* Add StatusEvent properties * Add license
1 parent 73c93c1 commit d358965

3 files changed

Lines changed: 53 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: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*-
2+
* -\-\-
3+
* github-client
4+
* --
5+
* Copyright (C) 2016 - 2020 Spotify AB
6+
* --
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* -/-/-
19+
*/
20+
21+
package com.spotify.github.v3.activity.events;
22+
23+
import static com.google.common.io.Resources.getResource;
24+
import static java.nio.charset.Charset.defaultCharset;
25+
import static org.hamcrest.MatcherAssert.assertThat;
26+
import static org.hamcrest.core.Is.is;
27+
28+
import com.google.common.io.Resources;
29+
import com.spotify.github.jackson.Json;
30+
import java.io.IOException;
31+
import org.junit.Test;
32+
33+
public class StatusEventTest {
34+
@Test
35+
public void testDeserialization() throws IOException {
36+
String fixture =
37+
Resources.toString(
38+
getResource(this.getClass(), "fixtures/status_event.json"), defaultCharset());
39+
final StatusEvent statusEvent = Json.create().fromJson(fixture, StatusEvent.class);
40+
assertThat(statusEvent.context(), is("default"));
41+
assertThat(statusEvent.sha(), is("9049f1265b7d61be4a8904a9a27120d2064dab3b"));
42+
assertThat(statusEvent.state(), is("success"));
43+
}
44+
}

0 commit comments

Comments
 (0)