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 com.jcabi.http.mock.MkAnswer;
9   import com.jcabi.http.mock.MkContainer;
10  import com.jcabi.http.mock.MkGrizzlyContainer;
11  import com.jcabi.http.request.JdkRequest;
12  import java.io.IOException;
13  import java.net.HttpURLConnection;
14  import org.hamcrest.MatcherAssert;
15  import org.hamcrest.Matchers;
16  import org.junit.jupiter.api.Test;
17  import org.junit.jupiter.api.extension.ExtendWith;
18  
19  /**
20   * Test case for RtCommit.
21   * @since 0.18.2
22   * @checkstyle MultipleStringLiterals (500 lines)
23   */
24  @ExtendWith(RandomPort.class)
25  final class RtCommitTest {
26  
27      /**
28       * The rule for skipping test if there's BindException.
29       * @checkstyle VisibilityModifierCheck (3 lines)
30       */
31      @Test
32      void readsMessage() throws IOException {
33          try (
34              MkContainer container = new MkGrizzlyContainer().next(
35                  new MkAnswer.Simple(
36                      HttpURLConnection.HTTP_OK,
37                      "{\"sha\":\"a0b1c3\", \"commit\":{\"message\":\"hello\"}}"
38                  )
39              ).start(RandomPort.port())) {
40              final Commit.Smart commit = new Commit.Smart(
41                  new RtCommit(
42                      new JdkRequest(container.home()),
43                      new MkGitHub().randomRepo(),
44                      "sha"
45                  )
46              );
47              MatcherAssert.assertThat(
48                  "Values are not equal",
49                  commit.message(),
50                  Matchers.equalTo("hello")
51              );
52          }
53      }
54  }