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.ApacheRequest;
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   * Testcase for RtTag.
21   * @since 0.8
22   * @checkstyle MultipleStringLiterals (500 lines)
23   */
24  @ExtendWith(RandomPort.class)
25  final class RtTagTest {
26  
27      /**
28       * The rule for skipping test if there's BindException.
29       * @checkstyle VisibilityModifierCheck (3 lines)
30       */
31      @Test
32      void fetchesContent() throws IOException {
33          final MkContainer container = new MkGrizzlyContainer().next(
34              new MkAnswer.Simple(
35                  HttpURLConnection.HTTP_OK,
36                  "{\"sha\":\"abdes00test\", \"tag\":\"v.0.1\"}"
37              )
38          ).start(RandomPort.port());
39          final Tag tag = new RtTag(
40              new ApacheRequest(container.home()),
41              new MkGitHub().randomRepo(),
42              "abdes00test"
43          );
44          try {
45              MatcherAssert.assertThat(
46                  "Values are not equal",
47                  tag.json().getString("tag"),
48                  Matchers.is("v.0.1")
49              );
50          } finally {
51              container.stop();
52          }
53      }
54  }