1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 package com.jcabi.github;
31
32 import com.jcabi.aspects.Tv;
33 import com.jcabi.github.OAuthScope.Scope;
34 import java.util.EnumMap;
35 import java.util.Iterator;
36 import org.hamcrest.MatcherAssert;
37 import org.hamcrest.Matchers;
38 import org.junit.Test;
39
40
41
42
43
44
45
46
47 @OAuthScope({ Scope.REPO, Scope.USER })
48 @SuppressWarnings("PMD.AvoidDuplicateLiterals")
49 public final class RtSearchITCase {
50
51
52
53
54
55 @Test
56 public void canSearchForRepos() {
57 MatcherAssert.assertThat(
58 new GithubIT().connect()
59 .search().repos("repo", "stars", Search.Order.DESC),
60 Matchers.not(Matchers.emptyIterableOf(Repo.class))
61 );
62 }
63
64
65
66
67
68 @Test
69 public void canFetchMultiplePages() {
70 final Iterator<Repo> iter = new GithubIT().connect().search().repos(
71 "java", "", Search.Order.DESC
72 ).iterator();
73 int count = 0;
74 while (iter.hasNext() && count < Tv.HUNDRED) {
75 iter.next().coordinates();
76 count += 1;
77 }
78 MatcherAssert.assertThat(
79 count,
80 Matchers.greaterThanOrEqualTo(Tv.HUNDRED)
81 );
82 }
83
84
85
86
87
88 @Test
89 public void canSearchForIssues() {
90 final EnumMap<Search.Qualifier, String> qualifiers =
91 new EnumMap<>(Search.Qualifier.class);
92 qualifiers.put(Search.Qualifier.LABEL, "bug");
93 MatcherAssert.assertThat(
94 new GithubIT().connect().search().issues(
95 "qualifiers",
96 "updated",
97 Search.Order.DESC,
98 qualifiers
99 ),
100 Matchers.not(Matchers.emptyIterableOf(Issue.class))
101 );
102 }
103
104
105
106
107
108 @Test
109 public void canSearchForUsers() {
110 MatcherAssert.assertThat(
111 new GithubIT().connect()
112 .search().users("jcabi", "joined", Search.Order.DESC),
113 Matchers.not(Matchers.emptyIterableOf(User.class))
114 );
115 }
116
117
118
119
120
121
122 @Test
123 public void canSearchForContents() {
124 MatcherAssert.assertThat(
125 new GithubIT().connect().search().codes(
126 "addClass repo:jquery/jquery", "joined", Search.Order.DESC
127 ),
128 Matchers.not(Matchers.emptyIterableOf(Content.class))
129 );
130 }
131
132 }