1
2
3
4
5 package com.jcabi.github;
6
7 import java.io.IOException;
8 import org.apache.commons.lang3.RandomStringUtils;
9 import org.hamcrest.MatcherAssert;
10 import org.hamcrest.Matchers;
11 import org.junit.jupiter.api.AfterAll;
12 import org.junit.jupiter.api.BeforeAll;
13 import org.junit.jupiter.api.Test;
14
15
16
17
18
19 @OAuthScope(OAuthScope.Scope.READ_ORG)
20 final class RtAssigneesITCase {
21
22
23
24 private static Repos repos;
25
26
27
28
29 private static Repo repo;
30
31
32
33
34 @BeforeAll
35 static void setUp() throws IOException {
36 final GitHub github = GitHubIT.connect();
37 RtAssigneesITCase.repos = github.repos();
38 RtAssigneesITCase.repo = new RepoRule().repo(RtAssigneesITCase.repos);
39 }
40
41
42
43
44 @AfterAll
45 static void tearDown() throws IOException {
46 if (RtAssigneesITCase.repos != null && RtAssigneesITCase.repo != null) {
47 RtAssigneesITCase.repos.remove(RtAssigneesITCase.repo.coordinates());
48 }
49 }
50
51 @Test
52 void iteratesAssignees() throws IOException {
53 final Iterable<User> users = new Smarts<>(
54 new Bulk<>(
55 RtAssigneesITCase.repo.assignees().iterate()
56 )
57 );
58 for (final User user : users) {
59 MatcherAssert.assertThat(
60 "Value is null",
61 user.login(),
62 Matchers.notNullValue()
63 );
64 }
65 }
66
67 @Test
68 void checkUserIsAssigneeForRepo() throws IOException {
69 MatcherAssert.assertThat(
70 "Values are not equal",
71 RtAssigneesITCase.repo.assignees().check(RtAssigneesITCase.repo.coordinates().user()),
72 Matchers.is(true)
73 );
74 }
75
76 @Test
77 void checkUserIsNotAssigneeForRepo() throws IOException {
78 MatcherAssert.assertThat(
79 "Values are not equal",
80 RtAssigneesITCase.repo.assignees()
81 .check(RandomStringUtils.secure().nextAlphanumeric(10)),
82 Matchers.is(false)
83 );
84 }
85 }