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.Gist;
8   import java.io.IOException;
9   import java.util.Collections;
10  import org.hamcrest.MatcherAssert;
11  import org.hamcrest.Matchers;
12  import org.junit.jupiter.api.Test;
13  
14  /**
15   * Test case for {@link MkGist}.
16   * @since 0.1
17   */
18  final class MkGistTest {
19      /**
20       * MkGist can read empty file.
21       * @throws IOException If some problem inside
22       */
23      @Test
24      void readEmptyGistFile() throws IOException {
25          // @checkstyle MultipleStringLiterals (1 lines)
26          final String filename = "file.txt";
27          final Gist gist = new MkGitHub().gists().create(
28              Collections.singletonMap(filename, ""), false
29          );
30          MatcherAssert.assertThat(
31              "Values are not equal",
32              gist.read(filename),
33              Matchers.is(Matchers.emptyString())
34          );
35      }
36  
37      /**
38       * MkGist can fork itself.
39       * @throws IOException If some problem inside
40       */
41      @Test
42      void fork() throws IOException {
43          final String filename = "file.txt";
44          final Gist gist = new MkGitHub().gists().create(
45              Collections.singletonMap(filename, ""), false
46          );
47          gist.write(filename, "Hello, github!");
48          final Gist fork = gist.fork();
49          MatcherAssert.assertThat(
50              "Values are not equal",
51              fork.read(filename),
52              Matchers.equalTo(gist.read(filename))
53          );
54      }
55  }