Java Code Examples for jenkins.scm.api.SCMHeadObserver#none()

The following examples show how to use jenkins.scm.api.SCMHeadObserver#none() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BranchDiscoveryTraitTest.java    From github-branch-source-plugin with MIT License 6 votes vote down vote up
@Test
public void given__discoverAll__when__appliedToContext__then__noFilter() throws Exception {
    GitHubSCMSourceContext ctx = new GitHubSCMSourceContext(null, SCMHeadObserver.none());
    assumeThat(ctx.wantBranches(), is(false));
    assumeThat(ctx.wantPRs(), is(false));
    assumeThat(ctx.prefilters(), is(Collections.<SCMHeadPrefilter>emptyList()));
    assumeThat(ctx.filters(), is(Collections.<SCMHeadFilter>emptyList()));
    assumeThat(ctx.authorities(), not(hasItem(
            instanceOf(BranchDiscoveryTrait.BranchSCMHeadAuthority.class)
    )));
    BranchDiscoveryTrait instance = new BranchDiscoveryTrait(true, true);
    instance.decorateContext(ctx);
    assertThat(ctx.wantBranches(), is(true));
    assertThat(ctx.wantPRs(), is(false));
    assertThat(ctx.prefilters(), is(Collections.<SCMHeadPrefilter>emptyList()));
    assertThat(ctx.filters(), is(Collections.<SCMHeadFilter>emptyList()));
    assertThat(ctx.authorities(), hasItem(
            instanceOf(BranchDiscoveryTrait.BranchSCMHeadAuthority.class)
    ));
}
 
Example 2
Source File: OriginPullRequestDiscoveryTraitTest.java    From github-branch-source-plugin with MIT License 6 votes vote down vote up
@Test
public void given__programmaticConstructor__when__appliedToContext__then__strategiesCorrect() throws Exception {
    GitHubSCMSourceContext ctx = new GitHubSCMSourceContext(null, SCMHeadObserver.none());
    assumeThat(ctx.wantBranches(), is(false));
    assumeThat(ctx.wantPRs(), is(false));
    assumeThat(ctx.prefilters(), is(Collections.<SCMHeadPrefilter>emptyList()));
    assumeThat(ctx.filters(), is(Collections.<SCMHeadFilter>emptyList()));
    assumeThat(ctx.authorities(), not(hasItem(
            instanceOf(OriginPullRequestDiscoveryTrait.OriginChangeRequestSCMHeadAuthority.class)
    )));
    OriginPullRequestDiscoveryTrait instance =
            new OriginPullRequestDiscoveryTrait(EnumSet.allOf(ChangeRequestCheckoutStrategy.class));
    instance.decorateContext(ctx);
    assertThat(ctx.wantBranches(), is(false));
    assertThat(ctx.wantPRs(), is(true));
    assertThat(ctx.prefilters(), is(Collections.<SCMHeadPrefilter>emptyList()));
    assertThat(ctx.filters(), is(Collections.<SCMHeadFilter>emptyList()));
    assertThat(ctx.originPRStrategies(),
            Matchers.is(EnumSet.allOf(ChangeRequestCheckoutStrategy.class)));
    assertThat(ctx.authorities(), hasItem(
            instanceOf(OriginPullRequestDiscoveryTrait.OriginChangeRequestSCMHeadAuthority.class)
    ));
}
 
Example 3
Source File: OriginPullRequestDiscoveryTraitTest.java    From github-branch-source-plugin with MIT License 6 votes vote down vote up
@Test
public void given__discoverMergeOnly__when__appliedToContext__then__strategiesCorrect() throws Exception {
    GitHubSCMSourceContext ctx = new GitHubSCMSourceContext(null, SCMHeadObserver.none());
    assumeThat(ctx.wantBranches(), is(false));
    assumeThat(ctx.wantPRs(), is(false));
    assumeThat(ctx.prefilters(), is(Collections.<SCMHeadPrefilter>emptyList()));
    assumeThat(ctx.filters(), is(Collections.<SCMHeadFilter>emptyList()));
    assumeThat(ctx.authorities(), not(hasItem(
            instanceOf(OriginPullRequestDiscoveryTrait.OriginChangeRequestSCMHeadAuthority.class)
    )));
    OriginPullRequestDiscoveryTrait instance = new OriginPullRequestDiscoveryTrait(
            EnumSet.of(ChangeRequestCheckoutStrategy.MERGE)
    );
    instance.decorateContext(ctx);
    assertThat(ctx.wantBranches(), is(false));
    assertThat(ctx.wantPRs(), is(true));
    assertThat(ctx.prefilters(), is(Collections.<SCMHeadPrefilter>emptyList()));
    assertThat(ctx.filters(), is(Collections.<SCMHeadFilter>emptyList()));
    assertThat(ctx.originPRStrategies(),
            Matchers.is(EnumSet.of(ChangeRequestCheckoutStrategy.MERGE)));
    assertThat(ctx.authorities(), hasItem(
            instanceOf(OriginPullRequestDiscoveryTrait.OriginChangeRequestSCMHeadAuthority.class)
    ));
}
 
Example 4
Source File: OriginPullRequestDiscoveryTraitTest.java    From github-branch-source-plugin with MIT License 6 votes vote down vote up
@Test
public void given__discoverHeadOnly__when__appliedToContext__then__strategiesCorrect() throws Exception {
    GitHubSCMSourceContext ctx = new GitHubSCMSourceContext(null, SCMHeadObserver.none());
    assumeThat(ctx.wantBranches(), is(false));
    assumeThat(ctx.wantPRs(), is(false));
    assumeThat(ctx.prefilters(), is(Collections.<SCMHeadPrefilter>emptyList()));
    assumeThat(ctx.filters(), is(Collections.<SCMHeadFilter>emptyList()));
    assumeThat(ctx.authorities(), not(hasItem(
            instanceOf(OriginPullRequestDiscoveryTrait.OriginChangeRequestSCMHeadAuthority.class)
    )));
    OriginPullRequestDiscoveryTrait instance = new OriginPullRequestDiscoveryTrait(
            EnumSet.of(ChangeRequestCheckoutStrategy.HEAD)
    );
    instance.decorateContext(ctx);
    assertThat(ctx.wantBranches(), is(false));
    assertThat(ctx.wantPRs(), is(true));
    assertThat(ctx.prefilters(), is(Collections.<SCMHeadPrefilter>emptyList()));
    assertThat(ctx.filters(), is(Collections.<SCMHeadFilter>emptyList()));
    assertThat(ctx.originPRStrategies(), Matchers.is(EnumSet.of(ChangeRequestCheckoutStrategy.HEAD)));
    assertThat(ctx.authorities(), hasItem(
            instanceOf(OriginPullRequestDiscoveryTrait.OriginChangeRequestSCMHeadAuthority.class)
    ));
}
 
Example 5
Source File: OriginPullRequestDiscoveryTraitTest.java    From github-branch-source-plugin with MIT License 6 votes vote down vote up
@Test
public void given__discoverHeadMerge__when__appliedToContext__then__strategiesCorrect() throws Exception {
    GitHubSCMSourceContext ctx = new GitHubSCMSourceContext(null, SCMHeadObserver.none());
    assumeThat(ctx.wantBranches(), is(false));
    assumeThat(ctx.wantPRs(), is(false));
    assumeThat(ctx.prefilters(), is(Collections.<SCMHeadPrefilter>emptyList()));
    assumeThat(ctx.filters(), is(Collections.<SCMHeadFilter>emptyList()));
    assumeThat(ctx.authorities(), not(hasItem(
            instanceOf(OriginPullRequestDiscoveryTrait.OriginChangeRequestSCMHeadAuthority.class)
    )));
    OriginPullRequestDiscoveryTrait instance = new OriginPullRequestDiscoveryTrait(
            EnumSet.allOf(ChangeRequestCheckoutStrategy.class)
    );
    instance.decorateContext(ctx);
    assertThat(ctx.wantBranches(), is(false));
    assertThat(ctx.wantPRs(), is(true));
    assertThat(ctx.prefilters(), is(Collections.<SCMHeadPrefilter>emptyList()));
    assertThat(ctx.filters(), is(Collections.<SCMHeadFilter>emptyList()));
    assertThat(ctx.originPRStrategies(), Matchers.is(EnumSet.allOf(ChangeRequestCheckoutStrategy.class)));
    assertThat(ctx.authorities(), hasItem(
            instanceOf(OriginPullRequestDiscoveryTrait.OriginChangeRequestSCMHeadAuthority.class)
    ));
}
 
Example 6
Source File: ForkPullRequestDiscoveryTraitTest.java    From github-branch-source-plugin with MIT License 6 votes vote down vote up
@Test
public void given__nonDefaultTrust__when__appliedToContext__then__authoritiesCorrect() throws Exception {
    GitHubSCMSourceContext ctx = new GitHubSCMSourceContext(null, SCMHeadObserver.none());
    assumeThat(ctx.wantBranches(), is(false));
    assumeThat(ctx.wantPRs(), is(false));
    assumeThat(ctx.prefilters(), is(Collections.<SCMHeadPrefilter>emptyList()));
    assumeThat(ctx.filters(), is(Collections.<SCMHeadFilter>emptyList()));
    assumeThat(ctx.authorities(), not(hasItem(
            instanceOf(ForkPullRequestDiscoveryTrait.TrustContributors.class)
    )));
    ForkPullRequestDiscoveryTrait instance = new ForkPullRequestDiscoveryTrait(
            EnumSet.allOf(ChangeRequestCheckoutStrategy.class),
            new ForkPullRequestDiscoveryTrait.TrustEveryone()
    );
    instance.decorateContext(ctx);
    assertThat(ctx.wantBranches(), is(false));
    assertThat(ctx.wantPRs(), is(true));
    assertThat(ctx.prefilters(), is(Collections.<SCMHeadPrefilter>emptyList()));
    assertThat(ctx.filters(), is(Collections.<SCMHeadFilter>emptyList()));
    assertThat(ctx.forkPRStrategies(), Matchers.is(EnumSet.allOf(ChangeRequestCheckoutStrategy.class)));
    assertThat(ctx.authorities(), hasItem(
            instanceOf(ForkPullRequestDiscoveryTrait.TrustEveryone.class)
    ));
}
 
Example 7
Source File: ForkPullRequestDiscoveryTraitTest.java    From github-branch-source-plugin with MIT License 6 votes vote down vote up
@Test
public void given__discoverMergeOnly__when__appliedToContext__then__strategiesCorrect() throws Exception {
    GitHubSCMSourceContext ctx = new GitHubSCMSourceContext(null, SCMHeadObserver.none());
    assumeThat(ctx.wantBranches(), is(false));
    assumeThat(ctx.wantPRs(), is(false));
    assumeThat(ctx.prefilters(), is(Collections.<SCMHeadPrefilter>emptyList()));
    assumeThat(ctx.filters(), is(Collections.<SCMHeadFilter>emptyList()));
    assumeThat(ctx.authorities(), not(hasItem(
            instanceOf(ForkPullRequestDiscoveryTrait.TrustContributors.class)
    )));
    ForkPullRequestDiscoveryTrait instance = new ForkPullRequestDiscoveryTrait(
            EnumSet.of(ChangeRequestCheckoutStrategy.MERGE),
            new ForkPullRequestDiscoveryTrait.TrustContributors()
    );
    instance.decorateContext(ctx);
    assertThat(ctx.wantBranches(), is(false));
    assertThat(ctx.wantPRs(), is(true));
    assertThat(ctx.prefilters(), is(Collections.<SCMHeadPrefilter>emptyList()));
    assertThat(ctx.filters(), is(Collections.<SCMHeadFilter>emptyList()));
    assertThat(ctx.forkPRStrategies(), Matchers.is(EnumSet.of(ChangeRequestCheckoutStrategy.MERGE)));
    assertThat(ctx.authorities(), hasItem(
            instanceOf(ForkPullRequestDiscoveryTrait.TrustContributors.class)
    ));
}
 
Example 8
Source File: ForkPullRequestDiscoveryTraitTest.java    From github-branch-source-plugin with MIT License 6 votes vote down vote up
@Test
public void given__discoverHeadOnly__when__appliedToContext__then__strategiesCorrect() throws Exception {
    GitHubSCMSourceContext ctx = new GitHubSCMSourceContext(null, SCMHeadObserver.none());
    assumeThat(ctx.wantBranches(), is(false));
    assumeThat(ctx.wantPRs(), is(false));
    assumeThat(ctx.prefilters(), is(Collections.<SCMHeadPrefilter>emptyList()));
    assumeThat(ctx.filters(), is(Collections.<SCMHeadFilter>emptyList()));
    assumeThat(ctx.authorities(), not(hasItem(
            instanceOf(ForkPullRequestDiscoveryTrait.TrustContributors.class)
    )));
    ForkPullRequestDiscoveryTrait instance = new ForkPullRequestDiscoveryTrait(
            EnumSet.of(ChangeRequestCheckoutStrategy.HEAD),
            new ForkPullRequestDiscoveryTrait.TrustContributors()
    );
    instance.decorateContext(ctx);
    assertThat(ctx.wantBranches(), is(false));
    assertThat(ctx.wantPRs(), is(true));
    assertThat(ctx.prefilters(), is(Collections.<SCMHeadPrefilter>emptyList()));
    assertThat(ctx.filters(), is(Collections.<SCMHeadFilter>emptyList()));
    assertThat(ctx.forkPRStrategies(), Matchers.is(EnumSet.of(ChangeRequestCheckoutStrategy.HEAD)));
    assertThat(ctx.authorities(), hasItem(
            instanceOf(ForkPullRequestDiscoveryTrait.TrustContributors.class)
    ));
}
 
Example 9
Source File: ForkPullRequestDiscoveryTraitTest.java    From github-branch-source-plugin with MIT License 6 votes vote down vote up
@Test
public void given__discoverHeadMerge__when__appliedToContext__then__strategiesCorrect() throws Exception {
    GitHubSCMSourceContext ctx = new GitHubSCMSourceContext(null, SCMHeadObserver.none());
    assumeThat(ctx.wantBranches(), is(false));
    assumeThat(ctx.wantPRs(), is(false));
    assumeThat(ctx.prefilters(), is(Collections.<SCMHeadPrefilter>emptyList()));
    assumeThat(ctx.filters(), is(Collections.<SCMHeadFilter>emptyList()));
    assumeThat(ctx.authorities(), not(hasItem(
            instanceOf(ForkPullRequestDiscoveryTrait.TrustContributors.class)
    )));
    ForkPullRequestDiscoveryTrait instance = new ForkPullRequestDiscoveryTrait(
            EnumSet.allOf(ChangeRequestCheckoutStrategy.class),
            new ForkPullRequestDiscoveryTrait.TrustContributors()
    );
    instance.decorateContext(ctx);
    assertThat(ctx.wantBranches(), is(false));
    assertThat(ctx.wantPRs(), is(true));
    assertThat(ctx.prefilters(), is(Collections.<SCMHeadPrefilter>emptyList()));
    assertThat(ctx.filters(), is(Collections.<SCMHeadFilter>emptyList()));
    assertThat(ctx.forkPRStrategies(), Matchers.is(EnumSet.allOf(ChangeRequestCheckoutStrategy.class)));
    assertThat(ctx.authorities(), hasItem(
            instanceOf(ForkPullRequestDiscoveryTrait.TrustContributors.class)
    ));
}
 
Example 10
Source File: BranchDiscoveryTraitTest.java    From github-branch-source-plugin with MIT License 6 votes vote down vote up
@Test
public void given__onlyPRs__when__appliedToContext__then__filter() throws Exception {
    GitHubSCMSourceContext ctx = new GitHubSCMSourceContext(null, SCMHeadObserver.none());
    assumeThat(ctx.wantBranches(), is(false));
    assumeThat(ctx.wantPRs(), is(false));
    assumeThat(ctx.prefilters(), is(Collections.<SCMHeadPrefilter>emptyList()));
    assumeThat(ctx.filters(), is(Collections.<SCMHeadFilter>emptyList()));
    assumeThat(ctx.authorities(), not(hasItem(
            instanceOf(BranchDiscoveryTrait.BranchSCMHeadAuthority.class)
    )));
    BranchDiscoveryTrait instance = new BranchDiscoveryTrait(false, true);
    instance.decorateContext(ctx);
    assertThat(ctx.wantBranches(), is(true));
    assertThat(ctx.wantPRs(), is(true));
    assertThat(ctx.prefilters(), is(Collections.<SCMHeadPrefilter>emptyList()));
    assertThat(ctx.filters(), contains(instanceOf(BranchDiscoveryTrait.OnlyOriginPRBranchesSCMHeadFilter.class)));
    assertThat(ctx.authorities(), hasItem(
            instanceOf(BranchDiscoveryTrait.BranchSCMHeadAuthority.class)
    ));
}
 
Example 11
Source File: BranchDiscoveryTraitTest.java    From github-branch-source-plugin with MIT License 6 votes vote down vote up
@Test
public void given__excludingPRs__when__appliedToContext__then__filter() throws Exception {
    GitHubSCMSourceContext ctx = new GitHubSCMSourceContext(null, SCMHeadObserver.none());
    assumeThat(ctx.wantBranches(), is(false));
    assumeThat(ctx.wantPRs(), is(false));
    assumeThat(ctx.prefilters(), is(Collections.<SCMHeadPrefilter>emptyList()));
    assumeThat(ctx.filters(), is(Collections.<SCMHeadFilter>emptyList()));
    assumeThat(ctx.authorities(), not(hasItem(
            instanceOf(BranchDiscoveryTrait.BranchSCMHeadAuthority.class)
    )));
    BranchDiscoveryTrait instance = new BranchDiscoveryTrait(true, false);
    instance.decorateContext(ctx);
    assertThat(ctx.wantBranches(), is(true));
    assertThat(ctx.wantPRs(), is(true));
    assertThat(ctx.prefilters(), is(Collections.<SCMHeadPrefilter>emptyList()));
    assertThat(ctx.filters(),
            contains(instanceOf(BranchDiscoveryTrait.ExcludeOriginPRBranchesSCMHeadFilter.class)));
    assertThat(ctx.authorities(), hasItem(
            instanceOf(BranchDiscoveryTrait.BranchSCMHeadAuthority.class)
    ));
}
 
Example 12
Source File: PendingChecksFilterTests.java    From gerrit-code-review-plugin with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setupClass() throws Exception {
  context = new GerritSCMSourceContext(null, SCMHeadObserver.none());
  context.wantFilterForPendingChecks(true);
  context.withChecksQueryOperator(ChecksQueryOperator.ID);
  context.withChecksQueryString(checkerUuid);

  pendingChecksInfos = new ArrayList<PendingChecksInfo>();
  pendingChecksInfos.add(getPendingChecksInfo("test", 11111, 1, CheckState.NOT_STARTED));

  query = new HashMap<String, List<String>>();
  query.put("query", Arrays.asList(new String[] {"checker:test:checker"}));

  filter = new PendingChecksFilter();
}
 
Example 13
Source File: GitHubNotificationTest.java    From github-branch-source-plugin with MIT License 5 votes vote down vote up
@Test
public void given__notificationsDisabled__when__appliedToContext__then__notificationsDisabled() throws Exception {
    GitHubSCMSourceContext ctx = new GitHubSCMSourceContext(null, SCMHeadObserver.none());
    assumeThat(ctx.notificationsDisabled(), is(false));
    ctx.withNotificationsDisabled(true);
    assertThat(ctx.notificationsDisabled(), is(true));
    ctx.withNotificationsDisabled(false);
    assertThat(ctx.notificationsDisabled(), is(false));
}
 
Example 14
Source File: GitHubNotificationTest.java    From github-branch-source-plugin with MIT License 5 votes vote down vote up
@Test
public void given__defaultNotificationStrategy__when__appliedToContext__then__duplicatesRemoved() throws Exception {
    GitHubSCMSourceContext ctx = new GitHubSCMSourceContext(null, SCMHeadObserver.none());
    assumeThat(ctx.notificationStrategies().size(), is(1));
    ctx.withNotificationStrategy(new DefaultGitHubNotificationStrategy());
    assertThat(ctx.notificationStrategies().size(), is(1));
}
 
Example 15
Source File: GitHubNotificationTest.java    From github-branch-source-plugin with MIT License 5 votes vote down vote up
@Test
public void given__emptyStrategiesList__when__appliedToContext__then__defaultApplied() throws Exception {
    GitHubSCMSourceContext ctx = new GitHubSCMSourceContext(null, SCMHeadObserver.none());
    assumeThat(ctx.notificationStrategies().size(), is(1));
    ctx.withNotificationStrategies(Collections.emptyList());
    assertThat(ctx.notificationStrategies().size(), is(1));
}
 
Example 16
Source File: GitHubNotificationTest.java    From github-branch-source-plugin with MIT License 5 votes vote down vote up
@Test
public void given__defaultStrategy__when__emptyStrategyList__then__strategyAdded() throws Exception {
    GitHubSCMSourceContext ctx = new GitHubSCMSourceContext(null, SCMHeadObserver.none());
    assumeThat(ctx.notificationStrategies().size(), is(1));
    ctx.withNotificationStrategies(Collections.emptyList());
    assertThat(ctx.notificationStrategies().size(), is(1));
    ctx.withNotificationStrategy(new DefaultGitHubNotificationStrategy());
    assertThat(ctx.notificationStrategies().size(), is(1));
}
 
Example 17
Source File: GitHubNotificationTest.java    From github-branch-source-plugin with MIT License 5 votes vote down vote up
@Test
public void given__defaultStrategyList__when__emptyStrategyList__then__strategyAdded() throws Exception {
    GitHubSCMSourceContext ctx = new GitHubSCMSourceContext(null, SCMHeadObserver.none());
    assumeThat(ctx.notificationStrategies().size(), is(1));
    ctx.withNotificationStrategies(Collections.emptyList());
    assertThat(ctx.notificationStrategies().size(), is(1));
    ctx.withNotificationStrategies(Collections.singletonList(new DefaultGitHubNotificationStrategy()));
    assertThat(ctx.notificationStrategies().size(), is(1));
}
 
Example 18
Source File: GitHubNotificationTest.java    From github-branch-source-plugin with MIT License 5 votes vote down vote up
@Test
public void given__customStrategy__when__emptyStrategyList__then__noDefaultStrategy() throws Exception {
    GitHubSCMSourceContext ctx = new GitHubSCMSourceContext(null, SCMHeadObserver.none());
    assumeThat(ctx.notificationStrategies().size(), is(1));
    ctx.withNotificationStrategy(new TestNotificationStrategy());
    List<AbstractGitHubNotificationStrategy> strategies = ctx.notificationStrategies();
    assertThat(strategies.size(), is(1));
    assertThat(strategies.get(0), Matchers.instanceOf(TestNotificationStrategy.class));
}