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.Comments;
8   import java.io.IOException;
9   import java.util.Date;
10  import org.hamcrest.MatcherAssert;
11  import org.hamcrest.Matchers;
12  import org.junit.jupiter.api.Test;
13  
14  /**
15   * Test case for {@link MkComments}.
16   * @since 0.7
17   */
18  final class MkCommentsTest {
19  
20      /**
21       * MkComments can iterate comments.
22       * @throws Exception If some problem inside
23       */
24      @Test
25      void iteratesComments() throws Exception {
26          final Comments comments = MkCommentsTest.comments();
27          comments.post("hello, dude!");
28          comments.post("hello again");
29          MatcherAssert.assertThat(
30              "Collection size is incorrect",
31              comments.iterate(new Date(0L)),
32              Matchers.iterableWithSize(2)
33          );
34      }
35  
36      /**
37       * Create a comments to work with.
38       * @return Comments just created
39       */
40      private static Comments comments() throws IOException {
41          return new MkGitHub().randomRepo()
42              .issues().create("hey", "how are you?")
43              .comments();
44      }
45  }