GHPullRequestSubscriber extends AbstractGHPullRequestSubsriber { @Override protected boolean isApplicable(Item item) { return item instanceof Job && withPRTrigger().apply((Job) item); }    }
@Test public void shouldNotBeApplicableWithoutTrigger() throws Exception { FreeStyleProject job = jenkins.createFreeStyleProject(); assertThat("only for jobs with trigger", new GHPullRequestSubscriber().isApplicable(job), is(false)); }
@Test public void shouldNotBeApplicableWithCronTrigger() throws Exception { when(trigger.getTriggerMode()).thenReturn(GitHubPRTriggerMode.CRON); FreeStyleProject job = jenkins.createFreeStyleProject(); job.addTrigger(trigger); assertThat("should ignore cron trigger", new GHPullRequestSubscriber().isApplicable(job), is(false)); }
@Test public void shouldBeApplicableWithHeavyHooksTrigger() throws Exception { when(trigger.getTriggerMode()).thenReturn(GitHubPRTriggerMode.HEAVY_HOOKS); FreeStyleProject job = jenkins.createFreeStyleProject(); job.addTrigger(trigger); assertThat("only for jobs with trigger with hook", new GHPullRequestSubscriber().isApplicable(job), is(true)); }
@Test public void shouldBeApplicableWithCronHooksTrigger() throws Exception { when(trigger.getTriggerMode()).thenReturn(GitHubPRTriggerMode.HEAVY_HOOKS_CRON); FreeStyleProject job = jenkins.createFreeStyleProject(); job.addTrigger(trigger); assertThat("only for jobs with trigger with hook", new GHPullRequestSubscriber().isApplicable(job), is(true)); }
@Test public void shouldBeApplicableWithLightHooksTrigger() throws Exception { when(trigger.getTriggerMode()).thenReturn(GitHubPRTriggerMode.LIGHT_HOOKS); FreeStyleProject job = jenkins.createFreeStyleProject(); job.addTrigger(trigger); assertThat("only for jobs with trigger with hook", new GHPullRequestSubscriber().isApplicable(job), is(true)); }