View Javadoc
1   /**
2    * Copyright (c) 2013-2023, jcabi.com
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions
7    * are met: 1) Redistributions of source code must retain the above
8    * copyright notice, this list of conditions and the following
9    * disclaimer. 2) Redistributions in binary form must reproduce the above
10   * copyright notice, this list of conditions and the following
11   * disclaimer in the documentation and/or other materials provided
12   * with the distribution. 3) Neither the name of the jcabi.com nor
13   * the names of its contributors may be used to endorse or promote
14   * products derived from this software without specific prior written
15   * permission.
16   *
17   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
19   * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20   * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21   * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22   * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23   * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28   * OF THE POSSIBILITY OF SUCH DAMAGE.
29   */
30  package com.jcabi.github.mock;
31  
32  import com.jcabi.github.Coordinates;
33  import com.jcabi.github.Fork;
34  import com.jcabi.github.Repo;
35  import org.hamcrest.MatcherAssert;
36  import org.hamcrest.Matchers;
37  import org.junit.Ignore;
38  import org.junit.Test;
39  
40  /**
41   * Test case for {@link MkForks}.
42   *
43   * @author Carlos Miranda (miranda.cma@gmail.com)
44   * @version $Id: 00d595978eff0039848b79dcca4632e07965b37b $
45   */
46  public final class MkForksTest {
47  
48      /**
49       * RtForks should be able to create a new fork.
50       *
51       * @throws Exception if a problem occurs.
52       */
53      @Test
54      @Ignore
55      public void createsFork() throws Exception {
56          final MkForks forks = new MkForks(
57              new MkStorage.InFile(),
58              "Test", new Coordinates.Simple("tests", "forks")
59          );
60          MatcherAssert.assertThat(
61              forks.create("blah"),
62              Matchers.notNullValue()
63          );
64      }
65  
66      /**
67       * MkForks can list forks.
68       * @throws Exception If some problem inside
69       */
70      @Test
71      public void iteratesForks() throws Exception {
72          final Repo repo = new MkGithub().randomRepo();
73          final Fork fork = repo.forks().create("Organization");
74          final Iterable<Fork> iterate = repo.forks().iterate("Order");
75          MatcherAssert.assertThat(
76              iterate,
77              Matchers.<Fork>iterableWithSize(1)
78          );
79          MatcherAssert.assertThat(
80              iterate,
81              Matchers.hasItem(fork)
82          );
83      }
84  }