1
2
3
4
5 package com.jcabi.github.mock;
6
7 import com.jcabi.github.Milestone;
8 import com.jcabi.github.Milestones;
9 import com.jcabi.github.Repo;
10 import com.jcabi.immutable.ArrayMap;
11 import java.io.IOException;
12 import org.hamcrest.MatcherAssert;
13 import org.hamcrest.Matchers;
14 import org.junit.jupiter.api.Test;
15
16
17
18
19
20
21 final class MkMilestonesTest {
22
23 @Test
24 void returnsRepo() throws IOException {
25 final Repo repo = new MkGitHub().randomRepo();
26 final Repo owner = repo.milestones().repo();
27 MatcherAssert.assertThat(
28 "Values are not equal", repo, Matchers.is(owner)
29 );
30 }
31
32 @Test
33 void createsMilestone() throws IOException {
34 final Milestones milestones = new MkGitHub().randomRepo()
35 .milestones();
36 final Milestone milestone = milestones.create("test milestone");
37 MatcherAssert.assertThat(
38 "Value is null", milestone, Matchers.notNullValue()
39 );
40 MatcherAssert.assertThat(
41 "Value is null",
42 milestones.create("another milestone"),
43 Matchers.notNullValue()
44 );
45 }
46
47
48
49
50 @Test
51 void getsMilestone() throws IOException {
52 final Milestones milestones = new MkGitHub().randomRepo()
53 .milestones();
54 final Milestone created = milestones.create("test");
55 MatcherAssert.assertThat(
56 "Value is null",
57 milestones.get(created.number()),
58 Matchers.notNullValue()
59 );
60 }
61
62
63
64
65 @Test
66 void removesMilestone() throws IOException {
67 final Milestones milestones = new MkGitHub().randomRepo()
68 .milestones();
69 final Milestone created = milestones.create("testTitle");
70 MatcherAssert.assertThat(
71 "Collection size is incorrect",
72 milestones.iterate(new ArrayMap<>()),
73 Matchers.iterableWithSize(1)
74 );
75 milestones.remove(created.number());
76 MatcherAssert.assertThat(
77 "Collection size is incorrect",
78 milestones.iterate(new ArrayMap<>()),
79 Matchers.iterableWithSize(0)
80 );
81 }
82
83
84
85
86
87 @Test
88 void iteratesMilestones() throws IOException {
89 final Milestones milestones = new MkGitHub().randomRepo()
90 .milestones();
91 milestones.create("testMilestone");
92 MatcherAssert.assertThat(
93 "Collection size is incorrect",
94 milestones.iterate(new ArrayMap<>()),
95 Matchers.iterableWithSize(1)
96 );
97 }
98 }