4141import javax .json .Json ;
4242import javax .json .JsonArrayBuilder ;
4343import javax .json .JsonObjectBuilder ;
44+ import javax .json .JsonValue ;
4445import org .hamcrest .MatcherAssert ;
4546import org .hamcrest .Matchers ;
4647import org .junit .Assert ;
@@ -62,6 +63,11 @@ public final class RtChecksTest {
6263 */
6364 private static final String CONCLUSION_KEY = "conclusion" ;
6465
66+ /**
67+ * Status key in json check.
68+ */
69+ private static final String STATUS_KEY = "status" ;
70+
6571 /**
6672 * The rule for skipping test if there's BindException.
6773 * @checkstyle VisibilityModifierCheck (3 lines)
@@ -183,6 +189,45 @@ public void retrievesUnfinishedChecksWithoutConclusion()
183189 }
184190 }
185191
192+ /**
193+ * Checks that library can handle unfinished checks.
194+ * @throws IOException If some I/O problem happens.
195+ */
196+ @ Test
197+ public void retrievesUnfinishedChecksWithNullableConclusion ()
198+ throws IOException {
199+ try (final MkContainer container = new MkGrizzlyContainer ()
200+ .next (
201+ new MkAnswer .Simple (
202+ HttpURLConnection .HTTP_OK ,
203+ RtChecksTest .jsonChecks (
204+ RtChecksTest .jsonCheck ()
205+ .add (
206+ RtChecksTest .CONCLUSION_KEY ,
207+ JsonValue .NULL
208+ ).add (
209+ RtChecksTest .STATUS_KEY ,
210+ Check .Status .QUEUED .value ()
211+ )
212+ )
213+ )
214+ ).start (this .resource .port ())
215+ ) {
216+ final Checks checks = new RtChecks (
217+ new JdkRequest (container .home ()),
218+ this .repo ().pulls ().get (0 )
219+ );
220+ final Collection <? extends Check > all = checks .all ();
221+ MatcherAssert .assertThat (all , Matchers .hasSize (1 ));
222+ for (final Check check : all ) {
223+ MatcherAssert .assertThat (
224+ check .successful (),
225+ Matchers .is (false )
226+ );
227+ }
228+ }
229+ }
230+
186231 /**
187232 * Checks that library can handle unfinished checks.
188233 * @throws IOException If some I/O problem happens.
@@ -223,7 +268,10 @@ public void retrievesUnfinishedChecksWithoutStatusAndConclusion()
223268 private static String jsonWithCheckRuns () {
224269 return RtChecksTest .jsonChecks (
225270 RtChecksTest .jsonCheck ()
226- .add ("status" , Check .Status .COMPLETED .value ())
271+ .add (
272+ RtChecksTest .STATUS_KEY ,
273+ Check .Status .COMPLETED .value ()
274+ )
227275 .add (
228276 RtChecksTest .CONCLUSION_KEY ,
229277 Check .Conclusion .SUCCESS .value ()
0 commit comments