GitHubBranchDeletedEvent extends GitHubBranchEvent { @Override public GitHubBranchCause check(@Nonnull GitHubBranchDecisionContext context) throws IOException { TaskListener listener = context.getListener(); GitHubBranch localBranch = context.getLocalBranch(); GHBranch remoteBranch = context.getRemoteBranch(); GitHubBranchCause cause = null; if (nonNull(localBranch) && isNull(remoteBranch)) { final PrintStream logger = listener.getLogger(); logger.println(DISPLAY_NAME + ": state has changed (branch was deleted)"); LOG.debug("{}: state has changed (branch was deleted)", DISPLAY_NAME); localBranch.setCommitSha(null); cause = context.newCause(DISPLAY_NAME, false); } return cause; } @DataBoundConstructor  GitHubBranchDeletedEvent(); @Override GitHubBranchCause check(@Nonnull GitHubBranchDecisionContext context);  }
@Test public void branchCreated() throws IOException { commonExpectations(); assertThat( event.check(newGitHubBranchDecisionContext() .withLocalBranch(null) .withLocalRepo(localRepo) .withBranchTrigger(trigger) .withRemoteBranch(remoteBranch) .withListener(listener) .build()), nullValue() ); }
@Test public void branchNotChangedExisted() throws IOException { commonExpectations(); assertThat( event.check(newGitHubBranchDecisionContext() .withLocalBranch(localBranch) .withBranchTrigger(trigger) .withLocalRepo(localRepo) .withRemoteBranch(remoteBranch) .withListener(listener) .build()), nullValue() ); }
@Test public void branchNotChangedNotExisted() throws IOException { commonExpectations(); assertThat( event.check(newGitHubBranchDecisionContext() .withLocalBranch(null) .withBranchTrigger(trigger) .withLocalRepo(localRepo) .withRemoteBranch(null) .withListener(listener) .build()), nullValue() ); }
@Test public void branchDeleted() throws IOException { commonExpectations(); assertThat( event.check(newGitHubBranchDecisionContext() .withLocalBranch(localBranch) .withBranchTrigger(trigger) .withLocalRepo(localRepo) .withListener(listener) .build()), notNullValue() ); }