1
2
3
4
5 package com.jcabi.github;
6
7 import com.jcabi.github.mock.MkGitHub;
8 import jakarta.json.Json;
9 import java.io.IOException;
10 import org.hamcrest.MatcherAssert;
11 import org.hamcrest.Matchers;
12 import org.junit.jupiter.api.Test;
13
14
15
16
17
18 final class RtStatusTest {
19
20
21
22
23 @Test
24 void fetchesId() throws IOException {
25 final int ident = 666;
26 MatcherAssert.assertThat(
27 "Values are not equal",
28 new RtStatus(
29 RtStatusTest.commit(),
30 Json.createObjectBuilder().add("id", ident).build()
31 ).identifier(),
32 Matchers.equalTo(ident)
33 );
34 }
35
36
37
38
39
40 @Test
41 void fetchesUrl() throws IOException {
42 final String url = "http://api.jcabi-github.invalid/whatever";
43 MatcherAssert.assertThat(
44 "Values are not equal",
45 new RtStatus(
46 RtStatusTest.commit(),
47 Json.createObjectBuilder().add("url", url).build()
48 ).url(),
49 Matchers.equalTo(url)
50 );
51 }
52
53
54
55
56
57 @Test
58 void fetchesCommit() throws IOException {
59 final Commit cmmt = RtStatusTest.commit();
60 MatcherAssert.assertThat(
61 "Values are not equal",
62 new RtStatus(cmmt, Json.createObjectBuilder().build()).commit(),
63 Matchers.equalTo(cmmt)
64 );
65 }
66
67
68
69
70
71
72 private static Commit commit() throws IOException {
73 return new MkGitHub().randomRepo().git().commits()
74 .get("d288364af5028c72e2a2c91c29343bae11fffcbe");
75 }
76 }