Skip to content

Commit a180c28

Browse files
authored
Add CheckRunEvent to events model (#104)
1 parent 3f5a66e commit a180c28

File tree

3 files changed

+410
-0
lines changed

3 files changed

+410
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*-
2+
* -\-\-
3+
* github-api
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 com.fasterxml.jackson.databind.annotation.JsonDeserialize;
24+
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
25+
import com.spotify.github.GithubStyle;
26+
import com.spotify.github.UpdateTracking;
27+
import com.spotify.github.v3.checks.CheckRunResponse;
28+
import org.immutables.value.Value;
29+
30+
import javax.annotation.Nullable;
31+
32+
@Value.Immutable
33+
@GithubStyle
34+
@JsonSerialize(as = ImmutableCheckRunEvent.class)
35+
@JsonDeserialize(as = ImmutableCheckRunEvent.class)
36+
public interface CheckRunEvent extends BaseEvent, UpdateTracking {
37+
38+
@Nullable
39+
String action();
40+
41+
@Nullable
42+
CheckRunResponse checkRun();
43+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
31+
import java.io.IOException;
32+
33+
import org.junit.Test;
34+
35+
public class CheckRunEventTest {
36+
37+
@Test
38+
public void testDeserialization() throws IOException {
39+
// sample payload from https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads
40+
String fixture =
41+
Resources.toString(
42+
getResource(this.getClass(), "fixtures/check_run_event.json"), defaultCharset());
43+
final CheckRunEvent checkRunEvent = Json.create().fromJson(fixture, CheckRunEvent.class);
44+
assertThat(checkRunEvent.action(), is("created"));
45+
assertThat(checkRunEvent.checkRun().name(), is("Octocoders-linter"));
46+
assertThat(checkRunEvent.repository().name(), is("Hello-World"));
47+
}
48+
49+
}

0 commit comments

Comments
 (0)