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 com.jcabi.github.mock.MkGitHub;
8   import jakarta.json.Json;
9   import java.io.IOException;
10  import org.hamcrest.MatcherAssert;
11  import org.hamcrest.Matchers;
12  import org.junit.jupiter.api.Test;
13  import org.mockito.Mockito;
14  
15  /**
16   * Tests for {@link Repo}.
17   * @since 0.1
18   */
19  final class RepoTest {
20  
21      @Test
22      void canFetchDescription() throws IOException {
23          final Repo repo = Mockito.mock(Repo.class);
24          Mockito.doReturn(
25              Json.createObjectBuilder()
26                  .add("description", "hello, world!")
27                  .build()
28          ).when(repo).json();
29          MatcherAssert.assertThat(
30              "String does not contain expected value",
31              new Repo.Smart(repo).description(),
32              Matchers.containsString("world!")
33          );
34      }
35  
36      @Test
37      void canFetchPrivateStatus() throws IOException {
38          final Repo repo = new MkGitHub().randomRepo();
39          repo.patch(
40              Json.createObjectBuilder()
41                  .add("private", true)
42                  .build()
43          );
44          MatcherAssert.assertThat(
45              "Values are not equal",
46              new Repo.Smart(repo).isPrivate(),
47              Matchers.is(true)
48          );
49      }
50  
51  }