View Javadoc
1   /*
2    * SPDX-FileCopyrightText: Copyright (c) 2013-2025 Yegor Bugayenko
3    * SPDX-License-Identifier: MIT
4    */
5   package com.jcabi.github.mock;
6   
7   import com.jcabi.github.Repo;
8   import com.jcabi.github.User;
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   * Test case for {@link MkAssignees}.
16   * @since 0.7
17   * @checkstyle MultipleStringLiteralsCheck (100 lines)
18   */
19  final class MkAssigneesTest {
20  
21      /**
22       * MkAssignees can iterate over assignees.
23       * @throws Exception Exception If some problem inside
24       */
25      @Test
26      void iteratesAssignees() throws Exception {
27          MatcherAssert.assertThat(
28              "Collection is not empty",
29              MkAssigneesTest.repo().assignees().iterate(),
30              Matchers.not(Matchers.emptyIterableOf(User.class))
31          );
32      }
33  
34      /**
35       * MkAssignees can check if a collaborator is an assignee for this repo.
36       * @throws Exception Exception If some problem inside
37       */
38      @Test
39      void checkCollaboratorIsAssigneeForRepo() throws Exception {
40          final Repo repo = MkAssigneesTest.repo();
41          repo.collaborators().add("Vladimir");
42          MatcherAssert.assertThat(
43              "Values are not equal",
44              repo.assignees().check("Vladimir"),
45              Matchers.is(true)
46          );
47      }
48  
49      /**
50       * MkAssignees can check if the owner is an assignee for this repo.
51       * @throws Exception Exception If some problem inside
52       */
53      @Test
54      void checkOwnerIsAssigneeForRepo() throws Exception {
55          MatcherAssert.assertThat(
56              "Values are not equal",
57              MkAssigneesTest.repo().assignees().check("Jonathan"),
58              Matchers.is(true)
59          );
60      }
61  
62      /**
63       * Create a repo to work with.
64       * @return Repo
65       */
66      private static Repo repo() throws IOException {
67          return new MkGitHub("Jonathan").randomRepo();
68      }
69  }