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.Commit;
8   import jakarta.json.Json;
9   import jakarta.json.JsonArray;
10  import jakarta.json.JsonObject;
11  import java.io.IOException;
12  import org.hamcrest.MatcherAssert;
13  import org.hamcrest.Matchers;
14  import org.junit.jupiter.api.Test;
15  
16  /**
17   * Testcase for MkTags.
18   * @since 0.8
19   * @checkstyle MultipleStringLiterals (500 lines)
20   */
21  final class MkCommitsTest {
22  
23      @Test
24      void createsMkCommit() throws IOException {
25          final JsonObject author = Json.createObjectBuilder()
26              .add("name", "Scott").add("email", "Scott@gmail.com")
27              .add("date", "2008-07-09T16:13:30+12:00").build();
28          final JsonArray tree = Json.createArrayBuilder()
29              .add("xyzsha12").build();
30          final Commit commit = new MkGitHub().randomRepo()
31              .git().commits().create(
32                  Json.createObjectBuilder().add("message", "my commit message")
33                      .add("sha", "12ahscba")
34                      .add("tree", "abcsha12")
35                      .add("parents", tree)
36                      .add("author", author).build()
37              );
38          MatcherAssert.assertThat(
39              "Value is null",
40              commit,
41              Matchers.notNullValue()
42          );
43          MatcherAssert.assertThat(
44              "Values are not equal",
45              commit.sha(),
46              Matchers.equalTo("12ahscba")
47          );
48      }
49  }