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.GitHub;
8   import com.jcabi.github.Issue;
9   import com.jcabi.github.Repo;
10  import com.jcabi.github.Repos;
11  import com.jcabi.immutable.ArrayMap;
12  import java.io.IOException;
13  import org.hamcrest.MatcherAssert;
14  import org.hamcrest.Matchers;
15  import org.junit.jupiter.api.Test;
16  
17  /**
18   * Test case for {@link MkIssues}.
19   * @since 0.1
20   * @checkstyle MultipleStringLiterals (500 lines)
21   */
22  final class MkIssuesTest {
23  
24      @Test
25      void iteratesIssues() throws IOException {
26          final Repo repo = new MkGitHub().randomRepo();
27          repo.issues().create("hey, you", "body of issue");
28          repo.issues().create("hey", "body of 2nd issue");
29          repo.issues().create("hey again", "body of 3rd issue");
30          MatcherAssert.assertThat(
31              "Collection size is incorrect",
32              repo.issues().iterate(new ArrayMap<>()),
33              Matchers.iterableWithSize(3)
34          );
35      }
36  
37      @Test
38      void createsNewIssueWithCorrectAuthor() throws IOException {
39          final Repo repo = new MkGitHub().randomRepo();
40          final Issue.Smart issue = new Issue.Smart(
41              repo.issues().create("hello", "the body")
42          );
43          MatcherAssert.assertThat(
44              "Values are not equal",
45              issue.author().login(),
46              Matchers.equalTo(repo.github().users().self().login())
47          );
48      }
49  
50      @Test
51      void createsMultipleIssues() throws IOException {
52          final GitHub github = new MkGitHub("jeff");
53          final Repo repo = github.repos().create(
54              new Repos.RepoCreate("test-3", false)
55          );
56          for (int idx = 1; idx < 10; ++idx) {
57              repo.issues().create("title", "body");
58          }
59      }
60  }