GitHubPRNonMergeableEvent extends GitHubPREvent { @Override public GitHubPRCause check(@Nonnull GitHubPRDecisionContext prDecisionContext) throws IOException { TaskListener listener = prDecisionContext.getListener(); GHPullRequest remotePR = prDecisionContext.getRemotePR(); final PrintStream logger = listener.getLogger(); Boolean mergeable; try { mergeable = remotePR.getMergeable(); } catch (IOException e) { listener.error(DISPLAY_NAME + ": can't get mergeable status {}", e); LOGGER.warn("Can't get mergeable status: {}", e); mergeable = false; } mergeable = mergeable != null ? mergeable : false; if (!mergeable) { return prDecisionContext.newCause(DISPLAY_NAME, isSkip()); } return null; } @DataBoundConstructor  GitHubPRNonMergeableEvent(boolean skip); @Override GitHubPRCause check(@Nonnull GitHubPRDecisionContext prDecisionContext); boolean isSkip();  }
@Test public void remotePRThrowsExceptionForMergeable() throws IOException { GitHubPRNonMergeableEvent instance = new GitHubPRNonMergeableEvent(true); when(remotePr.getMergeable()).thenThrow(new IOException("test IO")); when(listener.getLogger()).thenReturn(logger); assertNotNull(instance.check(newGitHubPRDecisionContext() .withPrTrigger(trigger) .withRemotePR(remotePr) .withListener(listener) .withLocalPR(localPr) .build())); }