1
2
3
4
5 package com.jcabi.github.mock;
6
7 import com.jcabi.github.CommitsComparison;
8 import com.jcabi.github.Coordinates;
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 MkCommitsComparisonTest {
19
20
21
22
23
24 @Test
25 void getRepo() throws IOException {
26 final String user = "test_user";
27 MatcherAssert.assertThat(
28 "Value is null",
29 new MkCommitsComparison(
30 new MkStorage.InFile(), user,
31 new Coordinates.Simple(user, "test_repo")
32 ).repo(), Matchers.notNullValue()
33 );
34 }
35
36 @Test
37 void canGetJson() throws IOException {
38 MatcherAssert.assertThat(
39 "Value is null",
40 new MkCommitsComparison(
41 new MkStorage.InFile(), "test1", new Coordinates.Simple(
42 "test_user1", "test_repo1"
43 )
44 ).json().getString("status"),
45 Matchers.notNullValue()
46 );
47 MatcherAssert.assertThat(
48 "Value is null",
49 new MkCommitsComparison(
50 new MkStorage.InFile(), "test2", new Coordinates.Simple(
51 "test_user2", "test_repo2"
52 )
53 ).json().getInt("ahead_by"),
54 Matchers.notNullValue()
55 );
56 }
57
58 @Test
59 void canGetJsonWithCommits() throws IOException {
60 final CommitsComparison cmp = new MkCommitsComparison(
61 new MkStorage.InFile(), "test-9",
62 new Coordinates.Simple("test_user_A", "test_repo_B")
63 );
64 MatcherAssert.assertThat(
65 "Collection size is incorrect",
66 new CommitsComparison.Smart(cmp).commits(),
67 Matchers.iterableWithSize(0)
68 );
69 MatcherAssert.assertThat(
70 "Value is null",
71 cmp.json().getJsonArray("commits"),
72 Matchers.notNullValue()
73 );
74 }
75 }