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.Tag;
8   import jakarta.json.Json;
9   import jakarta.json.JsonObject;
10  import java.io.IOException;
11  import org.hamcrest.MatcherAssert;
12  import org.hamcrest.Matchers;
13  import org.junit.jupiter.api.Test;
14  
15  /**
16   * Testcase for MkTag.
17   * @since 0.1
18   * @checkstyle MultipleStringLiterals (500 lines)
19   */
20  final class MkTagTest {
21  
22      /**
23       * MkTag should return its json.
24       * @throws Exception If something goes wrong.
25       */
26      @Test
27      void fetchesContent() throws Exception {
28          MatcherAssert.assertThat(
29              "Values are not equal",
30              MkTagTest.tag().json().getString("message"),
31              Matchers.is("\"test tag\"")
32          );
33      }
34  
35      /**
36       * Return a Tag for testing.
37       * @return Tag
38       */
39      private static Tag tag() throws IOException {
40          final JsonObject json = Json.createObjectBuilder()
41              .add("sha", "abcsha12").add("message", "test tag")
42              .add("name", "v.0.1").build();
43          return new MkGitHub().randomRepo().git().tags().create(json);
44      }
45  
46  }