1
2
3
4
5 package com.jcabi.github;
6
7 import java.util.EnumMap;
8 import java.util.Iterator;
9 import org.hamcrest.MatcherAssert;
10 import org.hamcrest.Matchers;
11 import org.junit.jupiter.api.Test;
12
13
14
15
16
17
18 @OAuthScope({ OAuthScope.Scope.REPO, OAuthScope.Scope.USER })
19 @SuppressWarnings("PMD.AvoidDuplicateLiterals")
20 final class RtSearchITCase {
21
22 @Test
23 void canSearchForRepos() {
24 MatcherAssert.assertThat(
25 "Collection is not empty",
26 GitHubIT.connect()
27 .search().repos("repo", "stars", Search.Order.DESC),
28 Matchers.not(Matchers.emptyIterableOf(Repo.class))
29 );
30 }
31
32
33
34
35 @Test
36 void canFetchMultiplePages() {
37 final Iterator<Repo> iter = GitHubIT.connect().search().repos(
38 "java", "", Search.Order.DESC
39 ).iterator();
40 int count = 0;
41 while (iter.hasNext() && count < 100) {
42 iter.next().coordinates();
43 count += 1;
44 }
45 MatcherAssert.assertThat(
46 "Value is not greater than expected",
47 count,
48 Matchers.greaterThanOrEqualTo(100)
49 );
50 }
51
52 @Test
53 void canSearchForIssues() {
54 final EnumMap<Search.Qualifier, String> qualifiers =
55 new EnumMap<>(Search.Qualifier.class);
56 qualifiers.put(Search.Qualifier.LABEL, "bug");
57 MatcherAssert.assertThat(
58 "Collection is not empty",
59 GitHubIT.connect().search().issues(
60 "qualifiers",
61 "updated",
62 Search.Order.DESC,
63 qualifiers
64 ),
65 Matchers.not(Matchers.emptyIterableOf(Issue.class))
66 );
67 }
68
69 @Test
70 void canSearchForUsers() {
71 MatcherAssert.assertThat(
72 "Collection is not empty",
73 GitHubIT.connect()
74 .search().users("jcabi", "joined", Search.Order.DESC),
75 Matchers.not(Matchers.emptyIterableOf(User.class))
76 );
77 }
78
79
80
81
82
83 @Test
84 void canSearchForContents() {
85 MatcherAssert.assertThat(
86 "Collection is not empty",
87 GitHubIT.connect().search().codes(
88 "addClass repo:jquery/jquery", "joined", Search.Order.DESC
89 ),
90 Matchers.not(Matchers.emptyIterableOf(Content.class))
91 );
92 }
93
94 }