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.Check;
8   import com.jcabi.github.Pull;
9   import java.io.IOException;
10  import org.hamcrest.MatcherAssert;
11  import org.hamcrest.Matchers;
12  import org.junit.jupiter.api.BeforeEach;
13  import org.junit.jupiter.api.Test;
14  
15  /**
16   * Test case for {@link MkCheck}.
17   * @since 1.6.1
18   */
19  final class MkCheckTest {
20  
21      /**
22       * Pull request.
23       */
24      private transient Pull pull;
25  
26      /**
27       * Set up.
28       * @throws IOException If some problem with I/O.
29       */
30      @BeforeEach
31      void setUp() throws IOException {
32          this.pull = new MkGitHub()
33              .randomRepo()
34              .pulls()
35              .create("Test PR", "abcdea8", "abcdea9");
36      }
37  
38      /**
39       * MkChecks can create successful check.
40       * @throws IOException If some problem with I/O.
41       */
42      @Test
43      void createsSuccessfulCheck() throws IOException {
44          MatcherAssert.assertThat(
45              "Values are not equal",
46              ((MkChecks) this.pull.checks())
47                  .create(Check.Status.COMPLETED, Check.Conclusion.SUCCESS)
48                  .successful(),
49              Matchers.is(true)
50          );
51      }
52  
53      /**
54       * MkChecks can create failed check.
55       * @throws IOException If some problem with I/O.
56       */
57      @Test
58      void createsFailedCheck() throws IOException {
59          MatcherAssert.assertThat(
60              "Values are not equal",
61              ((MkChecks) this.pull.checks())
62                  .create(
63                      Check.Status.COMPLETED,
64                      Check.Conclusion.FAILURE
65                  ).successful(),
66              Matchers.is(false)
67          );
68      }
69  }