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 org.hamcrest.MatcherAssert;
8   import org.hamcrest.Matchers;
9   import org.junit.jupiter.api.Test;
10  
11  /**
12   * Test case for {@link RtCheck}.
13   *
14   * @since 1.5.0
15   */
16  final class RtCheckTest {
17  
18      @Test
19      void checksSuccessfulState() {
20          MatcherAssert.assertThat(
21              "Values are not equal",
22              new RtCheck(
23                  Check.Status.COMPLETED,
24                  Check.Conclusion.SUCCESS
25              ).successful(),
26              Matchers.is(true)
27          );
28      }
29  
30      @Test
31      void checksNotSuccessfulStateIfInProgress() {
32          MatcherAssert.assertThat(
33              "Values are not equal",
34              new RtCheck(
35                  Check.Status.IN_PROGRESS,
36                  Check.Conclusion.SUCCESS
37              ).successful(),
38              Matchers.is(false)
39          );
40      }
41  
42      @Test
43      void checksNotSuccessfulState() {
44          MatcherAssert.assertThat(
45              "Values are not equal",
46              new RtCheck(
47                  Check.Status.COMPLETED,
48                  Check.Conclusion.CANCELLED
49              ).successful(),
50              Matchers.is(false)
51          );
52      }
53  
54      @Test
55      void createsWithUnexistingStatus() {
56          try {
57              new RtCheck(
58                  "unexisting",
59                  "success"
60              ).successful();
61              MatcherAssert.assertThat(
62                  "IllegalArgumentException was expected",
63                  false,
64                  Matchers.is(true)
65              );
66          } catch (final IllegalArgumentException ex) {
67              MatcherAssert.assertThat(
68                  "Exception was thrown as expected",
69                  ex,
70                  Matchers.notNullValue()
71              );
72          }
73      }
74  
75      @Test
76      void createsWithUnexistingConclusion() {
77          try {
78              new RtCheck(
79                  "completed",
80                  "unexist"
81              ).successful();
82              MatcherAssert.assertThat(
83                  "IllegalArgumentException was expected",
84                  false,
85                  Matchers.is(true)
86              );
87          } catch (final IllegalArgumentException ex) {
88              MatcherAssert.assertThat(
89                  "Exception was thrown as expected",
90                  ex,
91                  Matchers.notNullValue()
92              );
93          }
94      }
95  }