View Javadoc
1   /*
2    * SPDX-FileCopyrightText: Copyright (c) 2013-2025 Yegor Bugayenko
3    * SPDX-License-Identifier: MIT
4    */
5   package com.jcabi.github;
6   
7   import java.io.IOException;
8   import org.hamcrest.MatcherAssert;
9   import org.hamcrest.Matchers;
10  import org.junit.jupiter.api.Assumptions;
11  import org.junit.jupiter.api.Test;
12  
13  /**
14   * Test case for {@link RtForks}.
15   * @since 0.1
16   */
17  @OAuthScope(OAuthScope.Scope.REPO)
18  final class RtForksITCase {
19  
20      /**
21       * RepoRule.
22       * @checkstyle VisibilityModifierCheck (3 lines)
23       */
24      public final transient RepoRule rule = new RepoRule();
25  
26      @Test
27      void retrievesForks() throws IOException {
28          final String organization = System.getProperty(
29              "failsafe.github.organization"
30          );
31          Assumptions.assumeTrue(
32              organization != null,
33              "Organization must be set for this test"
34          );
35          final Repo repo = this.rule.repo(RtForksITCase.repos());
36          try {
37              final Fork fork = repo.forks().create(organization);
38              MatcherAssert.assertThat(
39                  "Value is null",
40                  fork,
41                  Matchers.notNullValue()
42              );
43              final Iterable<Fork> forks = repo.forks().iterate("newest");
44              MatcherAssert.assertThat(
45                  "Value is null",
46                  forks,
47                  Matchers.notNullValue()
48              );
49              MatcherAssert.assertThat(
50                  "Collection is not empty",
51                  forks,
52                  Matchers.not(Matchers.emptyIterable())
53              );
54              MatcherAssert.assertThat(
55                  "Assertion failed",
56                  forks,
57                  Matchers.contains(fork)
58              );
59          } finally {
60              RtForksITCase.repos().remove(repo.coordinates());
61          }
62      }
63  
64      /**
65       * Returns github repos.
66       * @return GitHub repos.
67       */
68      private static Repos repos() {
69          return GitHubIT.connect().repos();
70      }
71  
72  }