jenkins.plugins.git.MergeWithGitSCMExtension Java Examples

The following examples show how to use jenkins.plugins.git.MergeWithGitSCMExtension. 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: GitHubSCMSource.java    From github-branch-source-plugin with MIT License 4 votes vote down vote up
private Object readResolve() throws ObjectStreamException {
    return new MergeWithGitSCMExtension("remotes/origin/"+baseName, baseHash);
}
 
Example #2
Source File: GitHubSCMBuilderTest.java    From github-branch-source-plugin with MIT License 4 votes vote down vote up
@Test
public void given__cloud_pullMerge_rev_anon__when__build__then__scmBuilt() throws Exception {
    createGitHubSCMSourceForTest(false, null);
    PullRequestSCMHead head = new PullRequestSCMHead("PR-1", "qa", "qa-repo", "qa-branch", 1,
            new BranchSCMHead("test-branch"), new SCMHeadOrigin.Fork("qa/qa-repo"),
            ChangeRequestCheckoutStrategy.MERGE);
    PullRequestSCMRevision revision = new PullRequestSCMRevision(
            head,
            "deadbeefcafebabedeadbeefcafebabedeadbeef",
            "cafebabedeadbeefcafebabedeadbeefcafebabe"
    );
    source.setCredentialsId(null);
    GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, revision);
    assertThat(instance.credentialsId(), is(nullValue()));
    assertThat(instance.head(), is(head));
    assertThat(instance.revision(), is(revision));
    assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1"));
    assertThat("expecting guess value until withGitHubRemote called",
            instance.remote(), is("https://github.com/tester/test-repo.git"));
    assertThat(instance.browser(), instanceOf(GithubWeb.class));
    assertThat(instance.browser().getRepoUrl(), is("https://github.com/qa/qa-repo"));

    instance.withGitHubRemote();
    assertThat(instance.remote(), is("https://github.com/tester/test-repo.git"));

    GitSCM actual = instance.build();
    assertThat(actual.getBrowser(), instanceOf(GithubWeb.class));
    assertThat(actual.getBrowser().getRepoUrl(), is("https://github.com/qa/qa-repo"));
    assertThat(actual.getGitTool(), nullValue());
    assertThat(actual.getUserRemoteConfigs(), hasSize(1));
    UserRemoteConfig config = actual.getUserRemoteConfigs().get(0);
    assertThat(config.getName(), is("origin"));
    assertThat(config.getRefspec(), is("+refs/pull/1/head:refs/remotes/origin/PR-1 "
            + "+refs/heads/test-branch:refs/remotes/origin/test-branch"));
    assertThat(config.getUrl(), is("https://github.com/tester/test-repo.git"));
    assertThat(config.getCredentialsId(), is(nullValue()));
    RemoteConfig origin = actual.getRepositoryByName("origin");
    assertThat(origin, notNullValue());
    assertThat(origin.getURIs(), hasSize(1));
    assertThat(origin.getURIs().get(0).toString(), is("https://github.com/tester/test-repo.git"));
    assertThat(origin.getFetchRefSpecs(), hasSize(2));
    assertThat(origin.getFetchRefSpecs().get(0).getSource(), is("refs/pull/1/head"));
    assertThat(origin.getFetchRefSpecs().get(0).getDestination(), is("refs/remotes/origin/PR-1"));
    assertThat(origin.getFetchRefSpecs().get(0).isForceUpdate(), is(true));
    assertThat(origin.getFetchRefSpecs().get(0).isWildcard(), is(false));
    assertThat(origin.getFetchRefSpecs().get(1).getSource(), is("refs/heads/test-branch"));
    assertThat(origin.getFetchRefSpecs().get(1).getDestination(), is("refs/remotes/origin/test-branch"));
    assertThat(origin.getFetchRefSpecs().get(1).isForceUpdate(), is(true));
    assertThat(origin.getFetchRefSpecs().get(1).isWildcard(), is(false));
    assertThat(actual.getExtensions(), containsInAnyOrder(
            instanceOf(GitSCMSourceDefaults.class),
            instanceOf(BuildChooserSetting.class),
            instanceOf(MergeWithGitSCMExtension.class)
    ));
    BuildChooserSetting chooser = getExtension(actual, BuildChooserSetting.class);
    assertThat(chooser, notNullValue());
    assertThat(chooser.getBuildChooser(), instanceOf(AbstractGitSCMSource.SpecificRevisionBuildChooser.class));
    AbstractGitSCMSource.SpecificRevisionBuildChooser revChooser =
            (AbstractGitSCMSource.SpecificRevisionBuildChooser) chooser.getBuildChooser();
    Collection<Revision> revisions = revChooser
            .getCandidateRevisions(false, "test-branch", Mockito.mock(GitClient.class), new LogTaskListener(
                    Logger.getAnonymousLogger(), Level.FINEST), null, null);
    assertThat(revisions, hasSize(1));
    assertThat(revisions.iterator().next().getSha1String(), is("cafebabedeadbeefcafebabedeadbeefcafebabe"));
    MergeWithGitSCMExtension merge = getExtension(actual, MergeWithGitSCMExtension.class);
    assertThat(merge, notNullValue());
    assertThat(merge.getBaseName(), is("remotes/origin/test-branch"));
    assertThat(merge.getBaseHash(), is("deadbeefcafebabedeadbeefcafebabedeadbeef"));
}
 
Example #3
Source File: GitHubSCMBuilderTest.java    From github-branch-source-plugin with MIT License 4 votes vote down vote up
@Test
public void given__cloud_pullMerge_rev_userpass__when__build__then__scmBuilt() throws Exception {
    createGitHubSCMSourceForTest(false, null);
    PullRequestSCMHead head = new PullRequestSCMHead("PR-1", "qa", "qa-repo", "qa-branch", 1,
            new BranchSCMHead("test-branch"), new SCMHeadOrigin.Fork("qa/qa-repo"),
            ChangeRequestCheckoutStrategy.MERGE);
    PullRequestSCMRevision revision = new PullRequestSCMRevision(
            head,
            "deadbeefcafebabedeadbeefcafebabedeadbeef",
            "cafebabedeadbeefcafebabedeadbeefcafebabe"
    );
    source.setCredentialsId("user-pass");
    GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, revision);
    assertThat(instance.credentialsId(), is("user-pass"));
    assertThat(instance.head(), is(head));
    assertThat(instance.revision(), is(revision));
    assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1"));
    assertThat("expecting guess value until withGitHubRemote called",
            instance.remote(), is("https://github.com/tester/test-repo.git"));
    assertThat(instance.browser(), instanceOf(GithubWeb.class));
    assertThat(instance.browser().getRepoUrl(), is("https://github.com/qa/qa-repo"));

    instance.withGitHubRemote();
    assertThat(instance.remote(), is("https://github.com/tester/test-repo.git"));

    GitSCM actual = instance.build();
    assertThat(actual.getBrowser(), instanceOf(GithubWeb.class));
    assertThat(actual.getBrowser().getRepoUrl(), is("https://github.com/qa/qa-repo"));
    assertThat(actual.getGitTool(), nullValue());
    assertThat(actual.getUserRemoteConfigs(), hasSize(1));
    UserRemoteConfig config = actual.getUserRemoteConfigs().get(0);
    assertThat(config.getName(), is("origin"));
    assertThat(config.getRefspec(), is("+refs/pull/1/head:refs/remotes/origin/PR-1 "
            + "+refs/heads/test-branch:refs/remotes/origin/test-branch"));
    assertThat(config.getUrl(), is("https://github.com/tester/test-repo.git"));
    assertThat(config.getCredentialsId(), is("user-pass"));
    RemoteConfig origin = actual.getRepositoryByName("origin");
    assertThat(origin, notNullValue());
    assertThat(origin.getURIs(), hasSize(1));
    assertThat(origin.getURIs().get(0).toString(), is("https://github.com/tester/test-repo.git"));
    assertThat(origin.getFetchRefSpecs(), hasSize(2));
    assertThat(origin.getFetchRefSpecs().get(0).getSource(), is("refs/pull/1/head"));
    assertThat(origin.getFetchRefSpecs().get(0).getDestination(), is("refs/remotes/origin/PR-1"));
    assertThat(origin.getFetchRefSpecs().get(0).isForceUpdate(), is(true));
    assertThat(origin.getFetchRefSpecs().get(0).isWildcard(), is(false));
    assertThat(origin.getFetchRefSpecs().get(1).getSource(), is("refs/heads/test-branch"));
    assertThat(origin.getFetchRefSpecs().get(1).getDestination(), is("refs/remotes/origin/test-branch"));
    assertThat(origin.getFetchRefSpecs().get(1).isForceUpdate(), is(true));
    assertThat(origin.getFetchRefSpecs().get(1).isWildcard(), is(false));
    assertThat(actual.getExtensions(), containsInAnyOrder(
            instanceOf(GitSCMSourceDefaults.class),
            instanceOf(BuildChooserSetting.class),
            instanceOf(MergeWithGitSCMExtension.class)
    ));
    BuildChooserSetting chooser = getExtension(actual, BuildChooserSetting.class);
    assertThat(chooser, notNullValue());
    assertThat(chooser.getBuildChooser(), instanceOf(AbstractGitSCMSource.SpecificRevisionBuildChooser.class));
    AbstractGitSCMSource.SpecificRevisionBuildChooser revChooser =
            (AbstractGitSCMSource.SpecificRevisionBuildChooser) chooser.getBuildChooser();
    Collection<Revision> revisions = revChooser
            .getCandidateRevisions(false, "test-branch", Mockito.mock(GitClient.class), new LogTaskListener(
                    Logger.getAnonymousLogger(), Level.FINEST), null, null);
    assertThat(revisions, hasSize(1));
    assertThat(revisions.iterator().next().getSha1String(), is("cafebabedeadbeefcafebabedeadbeefcafebabe"));
    MergeWithGitSCMExtension merge = getExtension(actual, MergeWithGitSCMExtension.class);
    assertThat(merge, notNullValue());
    assertThat(merge.getBaseName(), is("remotes/origin/test-branch"));
    assertThat(merge.getBaseHash(), is("deadbeefcafebabedeadbeefcafebabedeadbeef"));
}
 
Example #4
Source File: GitHubSCMBuilderTest.java    From github-branch-source-plugin with MIT License 4 votes vote down vote up
@Test
public void given__cloud_pullMerge_rev_userkey__when__build__then__scmBuilt() throws Exception {
    createGitHubSCMSourceForTest(false, null);
    PullRequestSCMHead head = new PullRequestSCMHead("PR-1", "qa", "qa-repo", "qa-branch", 1,
            new BranchSCMHead("test-branch"), new SCMHeadOrigin.Fork("qa/qa-repo"),
            ChangeRequestCheckoutStrategy.MERGE);
    PullRequestSCMRevision revision = new PullRequestSCMRevision(
            head,
            "deadbeefcafebabedeadbeefcafebabedeadbeef",
            "cafebabedeadbeefcafebabedeadbeefcafebabe"
    );
    source.setCredentialsId("user-key");
    GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, revision);
    assertThat(instance.credentialsId(), is("user-key"));
    assertThat(instance.head(), is(head));
    assertThat(instance.revision(), is(revision));
    assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1"));
    assertThat("expecting guess value until withGitHubRemote called",
            instance.remote(), is("https://github.com/tester/test-repo.git"));
    assertThat(instance.browser(), instanceOf(GithubWeb.class));
    assertThat(instance.browser().getRepoUrl(), is("https://github.com/qa/qa-repo"));

    instance.withGitHubRemote();
    assertThat(instance.remote(), is("[email protected]:tester/test-repo.git"));

    GitSCM actual = instance.build();
    assertThat(actual.getBrowser(), instanceOf(GithubWeb.class));
    assertThat(actual.getBrowser().getRepoUrl(), is("https://github.com/qa/qa-repo"));
    assertThat(actual.getGitTool(), nullValue());
    assertThat(actual.getUserRemoteConfigs(), hasSize(1));
    UserRemoteConfig config = actual.getUserRemoteConfigs().get(0);
    assertThat(config.getName(), is("origin"));
    assertThat(config.getRefspec(), is("+refs/pull/1/head:refs/remotes/origin/PR-1 "
            + "+refs/heads/test-branch:refs/remotes/origin/test-branch"));
    assertThat(config.getUrl(), is("[email protected]:tester/test-repo.git"));
    assertThat(config.getCredentialsId(), is("user-key"));
    RemoteConfig origin = actual.getRepositoryByName("origin");
    assertThat(origin, notNullValue());
    assertThat(origin.getURIs(), hasSize(1));
    assertThat(origin.getURIs().get(0).toString(), is("[email protected]:tester/test-repo.git"));
    assertThat(origin.getFetchRefSpecs(), hasSize(2));
    assertThat(origin.getFetchRefSpecs().get(0).getSource(), is("refs/pull/1/head"));
    assertThat(origin.getFetchRefSpecs().get(0).getDestination(), is("refs/remotes/origin/PR-1"));
    assertThat(origin.getFetchRefSpecs().get(0).isForceUpdate(), is(true));
    assertThat(origin.getFetchRefSpecs().get(0).isWildcard(), is(false));
    assertThat(origin.getFetchRefSpecs().get(1).getSource(), is("refs/heads/test-branch"));
    assertThat(origin.getFetchRefSpecs().get(1).getDestination(), is("refs/remotes/origin/test-branch"));
    assertThat(origin.getFetchRefSpecs().get(1).isForceUpdate(), is(true));
    assertThat(origin.getFetchRefSpecs().get(1).isWildcard(), is(false));
    assertThat(actual.getExtensions(), containsInAnyOrder(
            instanceOf(GitSCMSourceDefaults.class),
            instanceOf(BuildChooserSetting.class),
            instanceOf(MergeWithGitSCMExtension.class)
    ));
    BuildChooserSetting chooser = getExtension(actual, BuildChooserSetting.class);
    assertThat(chooser, notNullValue());
    assertThat(chooser.getBuildChooser(), instanceOf(AbstractGitSCMSource.SpecificRevisionBuildChooser.class));
    AbstractGitSCMSource.SpecificRevisionBuildChooser revChooser =
            (AbstractGitSCMSource.SpecificRevisionBuildChooser) chooser.getBuildChooser();
    Collection<Revision> revisions = revChooser
            .getCandidateRevisions(false, "test-branch", Mockito.mock(GitClient.class), new LogTaskListener(
                    Logger.getAnonymousLogger(), Level.FINEST), null, null);
    assertThat(revisions, hasSize(1));
    assertThat(revisions.iterator().next().getSha1String(), is("cafebabedeadbeefcafebabedeadbeefcafebabe"));
    MergeWithGitSCMExtension merge = getExtension(actual, MergeWithGitSCMExtension.class);
    assertThat(merge, notNullValue());
    assertThat(merge.getBaseName(), is("remotes/origin/test-branch"));
    assertThat(merge.getBaseHash(), is("deadbeefcafebabedeadbeefcafebabedeadbeef"));
}
 
Example #5
Source File: GitHubSCMBuilderTest.java    From github-branch-source-plugin with MIT License 4 votes vote down vote up
@Test
public void given__cloud_pullMerge_norev_anon__when__build__then__scmBuilt() throws Exception {
    createGitHubSCMSourceForTest(false, null);
    PullRequestSCMHead head = new PullRequestSCMHead("PR-1", "qa", "qa-repo", "qa-branch", 1,
            new BranchSCMHead("test-branch"), new SCMHeadOrigin.Fork("qa/qa-repo"),
            ChangeRequestCheckoutStrategy.MERGE);
    source.setCredentialsId(null);
    GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, null);
    assertThat(instance.credentialsId(), is(nullValue()));
    assertThat(instance.head(), is(head));
    assertThat(instance.revision(), is(nullValue()));
    assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1"));
    assertThat("expecting guess value until withGitHubRemote called",
            instance.remote(), is("https://github.com/tester/test-repo.git"));
    assertThat(instance.browser(), instanceOf(GithubWeb.class));
    assertThat(instance.browser().getRepoUrl(), is("https://github.com/qa/qa-repo"));

    instance.withGitHubRemote();
    assertThat(instance.remote(), is("https://github.com/tester/test-repo.git"));

    GitSCM actual = instance.build();
    assertThat(actual.getBrowser(), instanceOf(GithubWeb.class));
    assertThat(actual.getBrowser().getRepoUrl(), is("https://github.com/qa/qa-repo"));
    assertThat(actual.getGitTool(), nullValue());
    assertThat(actual.getUserRemoteConfigs(), hasSize(1));
    UserRemoteConfig config = actual.getUserRemoteConfigs().get(0);
    assertThat(config.getName(), is("origin"));
    assertThat(config.getRefspec(), is("+refs/pull/1/head:refs/remotes/origin/PR-1 "
            + "+refs/heads/test-branch:refs/remotes/origin/test-branch"));
    assertThat(config.getUrl(), is("https://github.com/tester/test-repo.git"));
    assertThat(config.getCredentialsId(), is(nullValue()));
    RemoteConfig origin = actual.getRepositoryByName("origin");
    assertThat(origin, notNullValue());
    assertThat(origin.getURIs(), hasSize(1));
    assertThat(origin.getURIs().get(0).toString(), is("https://github.com/tester/test-repo.git"));
    assertThat(origin.getFetchRefSpecs(), hasSize(2));
    assertThat(origin.getFetchRefSpecs().get(0).getSource(), is("refs/pull/1/head"));
    assertThat(origin.getFetchRefSpecs().get(0).getDestination(), is("refs/remotes/origin/PR-1"));
    assertThat(origin.getFetchRefSpecs().get(0).isForceUpdate(), is(true));
    assertThat(origin.getFetchRefSpecs().get(0).isWildcard(), is(false));
    assertThat(origin.getFetchRefSpecs().get(1).getSource(), is("refs/heads/test-branch"));
    assertThat(origin.getFetchRefSpecs().get(1).getDestination(), is("refs/remotes/origin/test-branch"));
    assertThat(origin.getFetchRefSpecs().get(1).isForceUpdate(), is(true));
    assertThat(origin.getFetchRefSpecs().get(1).isWildcard(), is(false));
    assertThat(actual.getExtensions(), containsInAnyOrder(
            instanceOf(GitSCMSourceDefaults.class),
            instanceOf(MergeWithGitSCMExtension.class)
    ));
    MergeWithGitSCMExtension merge = getExtension(actual, MergeWithGitSCMExtension.class);
    assertThat(merge.getBaseName(), is("remotes/origin/test-branch"));
    assertThat(merge.getBaseHash(), is(nullValue()));
}
 
Example #6
Source File: GitHubSCMBuilderTest.java    From github-branch-source-plugin with MIT License 4 votes vote down vote up
@Test
public void given__cloud_pullMerge_norev_userpass__when__build__then__scmBuilt() throws Exception {
    createGitHubSCMSourceForTest(false, null);
    PullRequestSCMHead head = new PullRequestSCMHead("PR-1", "qa", "qa-repo", "qa-branch", 1,
            new BranchSCMHead("test-branch"), new SCMHeadOrigin.Fork("qa/qa-repo"),
            ChangeRequestCheckoutStrategy.MERGE);
    source.setCredentialsId("user-pass");
    GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, null);
    assertThat(instance.credentialsId(), is("user-pass"));
    assertThat(instance.head(), is(head));
    assertThat(instance.revision(), is(nullValue()));
    assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1"));
    assertThat("expecting guess value until withGitHubRemote called",
            instance.remote(), is("https://github.com/tester/test-repo.git"));
    assertThat(instance.browser(), instanceOf(GithubWeb.class));
    assertThat(instance.browser().getRepoUrl(), is("https://github.com/qa/qa-repo"));

    instance.withGitHubRemote();
    assertThat(instance.remote(), is("https://github.com/tester/test-repo.git"));

    GitSCM actual = instance.build();
    assertThat(actual.getBrowser(), instanceOf(GithubWeb.class));
    assertThat(actual.getBrowser().getRepoUrl(), is("https://github.com/qa/qa-repo"));
    assertThat(actual.getGitTool(), nullValue());
    assertThat(actual.getUserRemoteConfigs(), hasSize(1));
    UserRemoteConfig config = actual.getUserRemoteConfigs().get(0);
    assertThat(config.getName(), is("origin"));
    assertThat(config.getRefspec(), is("+refs/pull/1/head:refs/remotes/origin/PR-1 "
            + "+refs/heads/test-branch:refs/remotes/origin/test-branch"));
    assertThat(config.getUrl(), is("https://github.com/tester/test-repo.git"));
    assertThat(config.getCredentialsId(), is("user-pass"));
    RemoteConfig origin = actual.getRepositoryByName("origin");
    assertThat(origin, notNullValue());
    assertThat(origin.getURIs(), hasSize(1));
    assertThat(origin.getURIs().get(0).toString(), is("https://github.com/tester/test-repo.git"));
    assertThat(origin.getFetchRefSpecs(), hasSize(2));
    assertThat(origin.getFetchRefSpecs().get(0).getSource(), is("refs/pull/1/head"));
    assertThat(origin.getFetchRefSpecs().get(0).getDestination(), is("refs/remotes/origin/PR-1"));
    assertThat(origin.getFetchRefSpecs().get(0).isForceUpdate(), is(true));
    assertThat(origin.getFetchRefSpecs().get(0).isWildcard(), is(false));
    assertThat(origin.getFetchRefSpecs().get(1).getSource(), is("refs/heads/test-branch"));
    assertThat(origin.getFetchRefSpecs().get(1).getDestination(), is("refs/remotes/origin/test-branch"));
    assertThat(origin.getFetchRefSpecs().get(1).isForceUpdate(), is(true));
    assertThat(origin.getFetchRefSpecs().get(1).isWildcard(), is(false));
    assertThat(actual.getExtensions(), containsInAnyOrder(
            instanceOf(GitSCMSourceDefaults.class),
            instanceOf(MergeWithGitSCMExtension.class)
    ));
    MergeWithGitSCMExtension merge = getExtension(actual, MergeWithGitSCMExtension.class);
    assertThat(merge.getBaseName(), is("remotes/origin/test-branch"));
    assertThat(merge.getBaseHash(), is(nullValue()));
}
 
Example #7
Source File: GitHubSCMBuilderTest.java    From github-branch-source-plugin with MIT License 4 votes vote down vote up
@Test
public void given__cloud_pullMerge_norev_userkey__when__build__then__scmBuilt() throws Exception {
    createGitHubSCMSourceForTest(false, null);
    PullRequestSCMHead head = new PullRequestSCMHead("PR-1", "qa", "qa-repo", "qa-branch", 1,
            new BranchSCMHead("test-branch"), new SCMHeadOrigin.Fork("qa/qa-repo"),
            ChangeRequestCheckoutStrategy.MERGE);
    source.setCredentialsId("user-key");
    GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, null);
    assertThat(instance.credentialsId(), is("user-key"));
    assertThat(instance.head(), is(head));
    assertThat(instance.revision(), is(nullValue()));
    assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1"));
    assertThat("expecting guess value until withGitHubRemote called",
            instance.remote(), is("https://github.com/tester/test-repo.git"));
    assertThat(instance.browser(), instanceOf(GithubWeb.class));
    assertThat(instance.browser().getRepoUrl(), is("https://github.com/qa/qa-repo"));

    instance.withGitHubRemote();
    assertThat(instance.remote(), is("[email protected]:tester/test-repo.git"));

    GitSCM actual = instance.build();
    assertThat(actual.getBrowser(), instanceOf(GithubWeb.class));
    assertThat(actual.getBrowser().getRepoUrl(), is("https://github.com/qa/qa-repo"));
    assertThat(actual.getGitTool(), nullValue());
    assertThat(actual.getUserRemoteConfigs(), hasSize(1));
    UserRemoteConfig config = actual.getUserRemoteConfigs().get(0);
    assertThat(config.getName(), is("origin"));
    assertThat(config.getRefspec(), is("+refs/pull/1/head:refs/remotes/origin/PR-1 "
            + "+refs/heads/test-branch:refs/remotes/origin/test-branch"));
    assertThat(config.getUrl(), is("[email protected]:tester/test-repo.git"));
    assertThat(config.getCredentialsId(), is("user-key"));
    RemoteConfig origin = actual.getRepositoryByName("origin");
    assertThat(origin, notNullValue());
    assertThat(origin.getURIs(), hasSize(1));
    assertThat(origin.getURIs().get(0).toString(), is("[email protected]:tester/test-repo.git"));
    assertThat(origin.getFetchRefSpecs(), hasSize(2));
    assertThat(origin.getFetchRefSpecs().get(0).getSource(), is("refs/pull/1/head"));
    assertThat(origin.getFetchRefSpecs().get(0).getDestination(), is("refs/remotes/origin/PR-1"));
    assertThat(origin.getFetchRefSpecs().get(0).isForceUpdate(), is(true));
    assertThat(origin.getFetchRefSpecs().get(0).isWildcard(), is(false));
    assertThat(origin.getFetchRefSpecs().get(1).getSource(), is("refs/heads/test-branch"));
    assertThat(origin.getFetchRefSpecs().get(1).getDestination(), is("refs/remotes/origin/test-branch"));
    assertThat(origin.getFetchRefSpecs().get(1).isForceUpdate(), is(true));
    assertThat(origin.getFetchRefSpecs().get(1).isWildcard(), is(false));
    assertThat(actual.getExtensions(), containsInAnyOrder(
            instanceOf(GitSCMSourceDefaults.class),
            instanceOf(MergeWithGitSCMExtension.class)
    ));
    MergeWithGitSCMExtension merge = getExtension(actual, MergeWithGitSCMExtension.class);
    assertThat(merge.getBaseName(), is("remotes/origin/test-branch"));
    assertThat(merge.getBaseHash(), is(nullValue()));
}
 
Example #8
Source File: GitHubSCMBuilderTest.java    From github-branch-source-plugin with MIT License 4 votes vote down vote up
@Test
public void given__server_pullMerge_rev_anon__when__build__then__scmBuilt() throws Exception {
    createGitHubSCMSourceForTest(true, "https://github.test/tester/test-repo.git");
    PullRequestSCMHead head = new PullRequestSCMHead("PR-1", "qa", "qa-repo", "qa-branch", 1,
            new BranchSCMHead("test-branch"), new SCMHeadOrigin.Fork("qa/qa-repo"),
            ChangeRequestCheckoutStrategy.MERGE);
    PullRequestSCMRevision revision = new PullRequestSCMRevision(
            head,
            "deadbeefcafebabedeadbeefcafebabedeadbeef",
            "cafebabedeadbeefcafebabedeadbeefcafebabe"
    );
    source.setCredentialsId(null);
    GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, revision);
    assertThat(instance.credentialsId(), is(nullValue()));
    assertThat(instance.head(), is(head));
    assertThat(instance.revision(), is(revision));
    assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1"));
    assertThat("expecting guess value until withGitHubRemote called",
            instance.remote(), is("https://github.test/tester/test-repo.git"));
    assertThat(instance.browser(), instanceOf(GithubWeb.class));
    assertThat(instance.browser().getRepoUrl(), is("https://github.test/qa/qa-repo"));

    instance.withGitHubRemote();
    assertThat(instance.remote(), is("https://github.test/tester/test-repo.git"));

    GitSCM actual = instance.build();
    assertThat(actual.getBrowser(), instanceOf(GithubWeb.class));
    assertThat(actual.getBrowser().getRepoUrl(), is("https://github.test/qa/qa-repo"));
    assertThat(actual.getGitTool(), nullValue());
    assertThat(actual.getUserRemoteConfigs(), hasSize(1));
    UserRemoteConfig config = actual.getUserRemoteConfigs().get(0);
    assertThat(config.getName(), is("origin"));
    assertThat(config.getRefspec(), is("+refs/pull/1/head:refs/remotes/origin/PR-1 "
            + "+refs/heads/test-branch:refs/remotes/origin/test-branch"));
    assertThat(config.getUrl(), is("https://github.test/tester/test-repo.git"));
    assertThat(config.getCredentialsId(), is(nullValue()));
    RemoteConfig origin = actual.getRepositoryByName("origin");
    assertThat(origin, notNullValue());
    assertThat(origin.getURIs(), hasSize(1));
    assertThat(origin.getURIs().get(0).toString(), is("https://github.test/tester/test-repo.git"));
    assertThat(origin.getFetchRefSpecs(), hasSize(2));
    assertThat(origin.getFetchRefSpecs().get(0).getSource(), is("refs/pull/1/head"));
    assertThat(origin.getFetchRefSpecs().get(0).getDestination(), is("refs/remotes/origin/PR-1"));
    assertThat(origin.getFetchRefSpecs().get(0).isForceUpdate(), is(true));
    assertThat(origin.getFetchRefSpecs().get(0).isWildcard(), is(false));
    assertThat(origin.getFetchRefSpecs().get(1).getSource(), is("refs/heads/test-branch"));
    assertThat(origin.getFetchRefSpecs().get(1).getDestination(), is("refs/remotes/origin/test-branch"));
    assertThat(origin.getFetchRefSpecs().get(1).isForceUpdate(), is(true));
    assertThat(origin.getFetchRefSpecs().get(1).isWildcard(), is(false));
    assertThat(actual.getExtensions(), containsInAnyOrder(
            instanceOf(MergeWithGitSCMExtension.class),
            instanceOf(BuildChooserSetting.class),
            instanceOf(GitSCMSourceDefaults.class))
    );
    BuildChooserSetting chooser = getExtension(actual, BuildChooserSetting.class);
    assertThat(chooser, notNullValue());
    assertThat(chooser.getBuildChooser(), instanceOf(AbstractGitSCMSource.SpecificRevisionBuildChooser.class));
    AbstractGitSCMSource.SpecificRevisionBuildChooser revChooser =
            (AbstractGitSCMSource.SpecificRevisionBuildChooser) chooser.getBuildChooser();
    Collection<Revision> revisions = revChooser
            .getCandidateRevisions(false, "test-branch", Mockito.mock(GitClient.class), new LogTaskListener(
                    Logger.getAnonymousLogger(), Level.FINEST), null, null);
    assertThat(revisions, hasSize(1));
    assertThat(revisions.iterator().next().getSha1String(), is("cafebabedeadbeefcafebabedeadbeefcafebabe"));
    MergeWithGitSCMExtension merge = getExtension(actual, MergeWithGitSCMExtension.class);
    assertThat(merge, notNullValue());
    assertThat(merge.getBaseName(), is("remotes/origin/test-branch"));
    assertThat(merge.getBaseHash(), is("deadbeefcafebabedeadbeefcafebabedeadbeef"));
}
 
Example #9
Source File: GitHubSCMBuilderTest.java    From github-branch-source-plugin with MIT License 4 votes vote down vote up
@Test
public void given__server_pullMerge_rev_userpass__when__build__then__scmBuilt() throws Exception {
    createGitHubSCMSourceForTest(true, "https://github.test/tester/test-repo.git");
    PullRequestSCMHead head = new PullRequestSCMHead("PR-1", "qa", "qa-repo", "qa-branch", 1,
            new BranchSCMHead("test-branch"), new SCMHeadOrigin.Fork("qa/qa-repo"),
            ChangeRequestCheckoutStrategy.MERGE);
    PullRequestSCMRevision revision = new PullRequestSCMRevision(
            head,
            "deadbeefcafebabedeadbeefcafebabedeadbeef",
            "cafebabedeadbeefcafebabedeadbeefcafebabe"
    );
    source.setCredentialsId("user-pass");
    GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, revision);
    assertThat(instance.credentialsId(), is("user-pass"));
    assertThat(instance.head(), is(head));
    assertThat(instance.revision(), is(revision));
    assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1"));
    assertThat("expecting guess value until withGitHubRemote called",
            instance.remote(), is("https://github.test/tester/test-repo.git"));
    assertThat(instance.browser(), instanceOf(GithubWeb.class));
    assertThat(instance.browser().getRepoUrl(), is("https://github.test/qa/qa-repo"));

    instance.withGitHubRemote();
    assertThat(instance.remote(), is("https://github.test/tester/test-repo.git"));

    GitSCM actual = instance.build();
    assertThat(actual.getBrowser(), instanceOf(GithubWeb.class));
    assertThat(actual.getBrowser().getRepoUrl(), is("https://github.test/qa/qa-repo"));
    assertThat(actual.getGitTool(), nullValue());
    assertThat(actual.getUserRemoteConfigs(), hasSize(1));
    UserRemoteConfig config = actual.getUserRemoteConfigs().get(0);
    assertThat(config.getName(), is("origin"));
    assertThat(config.getRefspec(), is("+refs/pull/1/head:refs/remotes/origin/PR-1 "
            + "+refs/heads/test-branch:refs/remotes/origin/test-branch"));
    assertThat(config.getUrl(), is("https://github.test/tester/test-repo.git"));
    assertThat(config.getCredentialsId(), is("user-pass"));
    RemoteConfig origin = actual.getRepositoryByName("origin");
    assertThat(origin, notNullValue());
    assertThat(origin.getURIs(), hasSize(1));
    assertThat(origin.getURIs().get(0).toString(), is("https://github.test/tester/test-repo.git"));
    assertThat(origin.getFetchRefSpecs(), hasSize(2));
    assertThat(origin.getFetchRefSpecs().get(0).getSource(), is("refs/pull/1/head"));
    assertThat(origin.getFetchRefSpecs().get(0).getDestination(), is("refs/remotes/origin/PR-1"));
    assertThat(origin.getFetchRefSpecs().get(0).isForceUpdate(), is(true));
    assertThat(origin.getFetchRefSpecs().get(0).isWildcard(), is(false));
    assertThat(origin.getFetchRefSpecs().get(1).getSource(), is("refs/heads/test-branch"));
    assertThat(origin.getFetchRefSpecs().get(1).getDestination(), is("refs/remotes/origin/test-branch"));
    assertThat(origin.getFetchRefSpecs().get(1).isForceUpdate(), is(true));
    assertThat(origin.getFetchRefSpecs().get(1).isWildcard(), is(false));
    assertThat(actual.getExtensions(), containsInAnyOrder(
            instanceOf(MergeWithGitSCMExtension.class),
            instanceOf(BuildChooserSetting.class),
            instanceOf(GitSCMSourceDefaults.class))
    );
    BuildChooserSetting chooser = getExtension(actual, BuildChooserSetting.class);
    assertThat(chooser, notNullValue());
    assertThat(chooser.getBuildChooser(), instanceOf(AbstractGitSCMSource.SpecificRevisionBuildChooser.class));
    AbstractGitSCMSource.SpecificRevisionBuildChooser revChooser =
            (AbstractGitSCMSource.SpecificRevisionBuildChooser) chooser.getBuildChooser();
    Collection<Revision> revisions = revChooser
            .getCandidateRevisions(false, "test-branch", Mockito.mock(GitClient.class), new LogTaskListener(
                    Logger.getAnonymousLogger(), Level.FINEST), null, null);
    assertThat(revisions, hasSize(1));
    assertThat(revisions.iterator().next().getSha1String(), is("cafebabedeadbeefcafebabedeadbeefcafebabe"));
    MergeWithGitSCMExtension merge = getExtension(actual, MergeWithGitSCMExtension.class);
    assertThat(merge, notNullValue());
    assertThat(merge.getBaseName(), is("remotes/origin/test-branch"));
    assertThat(merge.getBaseHash(), is("deadbeefcafebabedeadbeefcafebabedeadbeef"));
}
 
Example #10
Source File: GitHubSCMBuilderTest.java    From github-branch-source-plugin with MIT License 4 votes vote down vote up
@Test
public void given__server_pullMerge_rev_userkey__when__build__then__scmBuilt() throws Exception {
    createGitHubSCMSourceForTest(true, "https://github.test/tester/test-repo.git");
    PullRequestSCMHead head = new PullRequestSCMHead("PR-1", "qa", "qa-repo", "qa-branch", 1,
            new BranchSCMHead("test-branch"), new SCMHeadOrigin.Fork("qa/qa-repo"),
            ChangeRequestCheckoutStrategy.MERGE);
    PullRequestSCMRevision revision = new PullRequestSCMRevision(
            head,
            "deadbeefcafebabedeadbeefcafebabedeadbeef",
            "cafebabedeadbeefcafebabedeadbeefcafebabe"
    );
    source.setCredentialsId("user-key");
    GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, revision);
    assertThat(instance.credentialsId(), is("user-key"));
    assertThat(instance.head(), is(head));
    assertThat(instance.revision(), is(revision));
    assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1"));
    assertThat("expecting guess value until withGitHubRemote called",
            instance.remote(), is("https://github.test/tester/test-repo.git"));
    assertThat(instance.browser(), instanceOf(GithubWeb.class));
    assertThat(instance.browser().getRepoUrl(), is("https://github.test/qa/qa-repo"));

    instance.withGitHubRemote();
    assertThat(instance.remote(), is("[email protected]:tester/test-repo.git"));

    GitSCM actual = instance.build();
    assertThat(actual.getBrowser(), instanceOf(GithubWeb.class));
    assertThat(actual.getBrowser().getRepoUrl(), is("https://github.test/qa/qa-repo"));
    assertThat(actual.getGitTool(), nullValue());
    assertThat(actual.getUserRemoteConfigs(), hasSize(1));
    UserRemoteConfig config = actual.getUserRemoteConfigs().get(0);
    assertThat(config.getName(), is("origin"));
    assertThat(config.getRefspec(), is("+refs/pull/1/head:refs/remotes/origin/PR-1 "
            + "+refs/heads/test-branch:refs/remotes/origin/test-branch"));
    assertThat(config.getUrl(), is("[email protected]:tester/test-repo.git"));
    assertThat(config.getCredentialsId(), is("user-key"));
    RemoteConfig origin = actual.getRepositoryByName("origin");
    assertThat(origin, notNullValue());
    assertThat(origin.getURIs(), hasSize(1));
    assertThat(origin.getURIs().get(0).toString(), is("[email protected]:tester/test-repo.git"));
    assertThat(origin.getFetchRefSpecs(), hasSize(2));
    assertThat(origin.getFetchRefSpecs().get(0).getSource(), is("refs/pull/1/head"));
    assertThat(origin.getFetchRefSpecs().get(0).getDestination(), is("refs/remotes/origin/PR-1"));
    assertThat(origin.getFetchRefSpecs().get(0).isForceUpdate(), is(true));
    assertThat(origin.getFetchRefSpecs().get(0).isWildcard(), is(false));
    assertThat(origin.getFetchRefSpecs().get(1).getSource(), is("refs/heads/test-branch"));
    assertThat(origin.getFetchRefSpecs().get(1).getDestination(), is("refs/remotes/origin/test-branch"));
    assertThat(origin.getFetchRefSpecs().get(1).isForceUpdate(), is(true));
    assertThat(origin.getFetchRefSpecs().get(1).isWildcard(), is(false));
    assertThat(actual.getExtensions(), containsInAnyOrder(
            instanceOf(MergeWithGitSCMExtension.class),
            instanceOf(BuildChooserSetting.class),
            instanceOf(GitSCMSourceDefaults.class))
    );
    BuildChooserSetting chooser = getExtension(actual, BuildChooserSetting.class);
    assertThat(chooser, notNullValue());
    assertThat(chooser.getBuildChooser(), instanceOf(AbstractGitSCMSource.SpecificRevisionBuildChooser.class));
    AbstractGitSCMSource.SpecificRevisionBuildChooser revChooser =
            (AbstractGitSCMSource.SpecificRevisionBuildChooser) chooser.getBuildChooser();
    Collection<Revision> revisions = revChooser
            .getCandidateRevisions(false, "test-branch", Mockito.mock(GitClient.class), new LogTaskListener(
                    Logger.getAnonymousLogger(), Level.FINEST), null, null);
    assertThat(revisions, hasSize(1));
    assertThat(revisions.iterator().next().getSha1String(), is("cafebabedeadbeefcafebabedeadbeefcafebabe"));
    MergeWithGitSCMExtension merge = getExtension(actual, MergeWithGitSCMExtension.class);
    assertThat(merge, notNullValue());
    assertThat(merge.getBaseName(), is("remotes/origin/test-branch"));
    assertThat(merge.getBaseHash(), is("deadbeefcafebabedeadbeefcafebabedeadbeef"));
}
 
Example #11
Source File: GitHubSCMBuilderTest.java    From github-branch-source-plugin with MIT License 4 votes vote down vote up
@Test
public void given__server_pullMerge_norev_anon__when__build__then__scmBuilt() throws Exception {
    createGitHubSCMSourceForTest(true, "https://github.test/tester/test-repo.git");
    PullRequestSCMHead head = new PullRequestSCMHead("PR-1", "qa", "qa-repo", "qa-branch", 1,
            new BranchSCMHead("test-branch"), new SCMHeadOrigin.Fork("qa/qa-repo"),
            ChangeRequestCheckoutStrategy.MERGE);
    source.setCredentialsId(null);
    GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, null);
    assertThat(instance.credentialsId(), is(nullValue()));
    assertThat(instance.head(), is(head));
    assertThat(instance.revision(), is(nullValue()));
    assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1"));
    assertThat("expecting guess value until withGitHubRemote called",
            instance.remote(), is("https://github.test/tester/test-repo.git"));
    assertThat(instance.browser(), instanceOf(GithubWeb.class));
    assertThat(instance.browser().getRepoUrl(), is("https://github.test/qa/qa-repo"));

    instance.withGitHubRemote();
    assertThat(instance.remote(), is("https://github.test/tester/test-repo.git"));

    GitSCM actual = instance.build();
    assertThat(actual.getBrowser(), instanceOf(GithubWeb.class));
    assertThat(actual.getBrowser().getRepoUrl(), is("https://github.test/qa/qa-repo"));
    assertThat(actual.getGitTool(), nullValue());
    assertThat(actual.getUserRemoteConfigs(), hasSize(1));
    UserRemoteConfig config = actual.getUserRemoteConfigs().get(0);
    assertThat(config.getName(), is("origin"));
    assertThat(config.getRefspec(), is("+refs/pull/1/head:refs/remotes/origin/PR-1 "
            + "+refs/heads/test-branch:refs/remotes/origin/test-branch"));
    assertThat(config.getUrl(), is("https://github.test/tester/test-repo.git"));
    assertThat(config.getCredentialsId(), is(nullValue()));
    RemoteConfig origin = actual.getRepositoryByName("origin");
    assertThat(origin, notNullValue());
    assertThat(origin.getURIs(), hasSize(1));
    assertThat(origin.getURIs().get(0).toString(), is("https://github.test/tester/test-repo.git"));
    assertThat(origin.getFetchRefSpecs(), hasSize(2));
    assertThat(origin.getFetchRefSpecs().get(0).getSource(), is("refs/pull/1/head"));
    assertThat(origin.getFetchRefSpecs().get(0).getDestination(), is("refs/remotes/origin/PR-1"));
    assertThat(origin.getFetchRefSpecs().get(0).isForceUpdate(), is(true));
    assertThat(origin.getFetchRefSpecs().get(0).isWildcard(), is(false));
    assertThat(origin.getFetchRefSpecs().get(1).getSource(), is("refs/heads/test-branch"));
    assertThat(origin.getFetchRefSpecs().get(1).getDestination(), is("refs/remotes/origin/test-branch"));
    assertThat(origin.getFetchRefSpecs().get(1).isForceUpdate(), is(true));
    assertThat(origin.getFetchRefSpecs().get(1).isWildcard(), is(false));
    assertThat(actual.getExtensions(), containsInAnyOrder(
            instanceOf(MergeWithGitSCMExtension.class),
            instanceOf(GitSCMSourceDefaults.class))
    );
    MergeWithGitSCMExtension merge = getExtension(actual, MergeWithGitSCMExtension.class);
    assertThat(merge, notNullValue());
    assertThat(merge.getBaseName(), is("remotes/origin/test-branch"));
    assertThat(merge.getBaseHash(), is(nullValue()));
}
 
Example #12
Source File: GitHubSCMBuilderTest.java    From github-branch-source-plugin with MIT License 4 votes vote down vote up
@Test
public void given__server_pullMerge_norev_userpass__when__build__then__scmBuilt() throws Exception {
    createGitHubSCMSourceForTest(true, "https://github.test/tester/test-repo.git");
    PullRequestSCMHead head = new PullRequestSCMHead("PR-1", "qa", "qa-repo", "qa-branch", 1,
            new BranchSCMHead("test-branch"), new SCMHeadOrigin.Fork("qa/qa-repo"),
            ChangeRequestCheckoutStrategy.MERGE);
    source.setCredentialsId("user-pass");
    GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, null);
    assertThat(instance.credentialsId(), is("user-pass"));
    assertThat(instance.head(), is(head));
    assertThat(instance.revision(), is(nullValue()));
    assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1"));
    assertThat("expecting guess value until withGitHubRemote called",
            instance.remote(), is("https://github.test/tester/test-repo.git"));
    assertThat(instance.browser(), instanceOf(GithubWeb.class));
    assertThat(instance.browser().getRepoUrl(), is("https://github.test/qa/qa-repo"));

    instance.withGitHubRemote();
    assertThat(instance.remote(), is("https://github.test/tester/test-repo.git"));

    GitSCM actual = instance.build();
    assertThat(actual.getBrowser(), instanceOf(GithubWeb.class));
    assertThat(actual.getBrowser().getRepoUrl(), is("https://github.test/qa/qa-repo"));
    assertThat(actual.getGitTool(), nullValue());
    assertThat(actual.getUserRemoteConfigs(), hasSize(1));
    UserRemoteConfig config = actual.getUserRemoteConfigs().get(0);
    assertThat(config.getName(), is("origin"));
    assertThat(config.getRefspec(), is("+refs/pull/1/head:refs/remotes/origin/PR-1 "
            + "+refs/heads/test-branch:refs/remotes/origin/test-branch"));
    assertThat(config.getUrl(), is("https://github.test/tester/test-repo.git"));
    assertThat(config.getCredentialsId(), is("user-pass"));
    RemoteConfig origin = actual.getRepositoryByName("origin");
    assertThat(origin, notNullValue());
    assertThat(origin.getURIs(), hasSize(1));
    assertThat(origin.getURIs().get(0).toString(), is("https://github.test/tester/test-repo.git"));
    assertThat(origin.getFetchRefSpecs(), hasSize(2));
    assertThat(origin.getFetchRefSpecs().get(0).getSource(), is("refs/pull/1/head"));
    assertThat(origin.getFetchRefSpecs().get(0).getDestination(), is("refs/remotes/origin/PR-1"));
    assertThat(origin.getFetchRefSpecs().get(0).isForceUpdate(), is(true));
    assertThat(origin.getFetchRefSpecs().get(0).isWildcard(), is(false));
    assertThat(origin.getFetchRefSpecs().get(1).getSource(), is("refs/heads/test-branch"));
    assertThat(origin.getFetchRefSpecs().get(1).getDestination(), is("refs/remotes/origin/test-branch"));
    assertThat(origin.getFetchRefSpecs().get(1).isForceUpdate(), is(true));
    assertThat(origin.getFetchRefSpecs().get(1).isWildcard(), is(false));
    assertThat(actual.getExtensions(), containsInAnyOrder(
            instanceOf(MergeWithGitSCMExtension.class),
            instanceOf(GitSCMSourceDefaults.class))
    );
    MergeWithGitSCMExtension merge = getExtension(actual, MergeWithGitSCMExtension.class);
    assertThat(merge, notNullValue());
    assertThat(merge.getBaseName(), is("remotes/origin/test-branch"));
    assertThat(merge.getBaseHash(), is(nullValue()));
}
 
Example #13
Source File: GitHubSCMBuilderTest.java    From github-branch-source-plugin with MIT License 4 votes vote down vote up
@Test
public void given__server_pullMerge_norev_userkey__when__build__then__scmBuilt() throws Exception {
    createGitHubSCMSourceForTest(true, "https://github.test/tester/test-repo.git");
    PullRequestSCMHead head = new PullRequestSCMHead("PR-1", "qa", "qa-repo", "qa-branch", 1,
            new BranchSCMHead("test-branch"), new SCMHeadOrigin.Fork("qa/qa-repo"),
            ChangeRequestCheckoutStrategy.MERGE);
    source.setCredentialsId("user-key");
    GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, null);
    assertThat(instance.credentialsId(), is("user-key"));
    assertThat(instance.head(), is(head));
    assertThat(instance.revision(), is(nullValue()));
    assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1"));
    assertThat("expecting guess value until withGitHubRemote called",
            instance.remote(), is("https://github.test/tester/test-repo.git"));
    assertThat(instance.browser(), instanceOf(GithubWeb.class));
    assertThat(instance.browser().getRepoUrl(), is("https://github.test/qa/qa-repo"));

    instance.withGitHubRemote();
    assertThat(instance.remote(), is("[email protected]:tester/test-repo.git"));

    GitSCM actual = instance.build();
    assertThat(actual.getBrowser(), instanceOf(GithubWeb.class));
    assertThat(actual.getBrowser().getRepoUrl(), is("https://github.test/qa/qa-repo"));
    assertThat(actual.getGitTool(), nullValue());
    assertThat(actual.getUserRemoteConfigs(), hasSize(1));
    UserRemoteConfig config = actual.getUserRemoteConfigs().get(0);
    assertThat(config.getName(), is("origin"));
    assertThat(config.getRefspec(), is("+refs/pull/1/head:refs/remotes/origin/PR-1 "
            + "+refs/heads/test-branch:refs/remotes/origin/test-branch"));
    assertThat(config.getUrl(), is("[email protected]:tester/test-repo.git"));
    assertThat(config.getCredentialsId(), is("user-key"));
    RemoteConfig origin = actual.getRepositoryByName("origin");
    assertThat(origin, notNullValue());
    assertThat(origin.getURIs(), hasSize(1));
    assertThat(origin.getURIs().get(0).toString(), is("[email protected]:tester/test-repo.git"));
    assertThat(origin.getFetchRefSpecs(), hasSize(2));
    assertThat(origin.getFetchRefSpecs().get(0).getSource(), is("refs/pull/1/head"));
    assertThat(origin.getFetchRefSpecs().get(0).getDestination(), is("refs/remotes/origin/PR-1"));
    assertThat(origin.getFetchRefSpecs().get(0).isForceUpdate(), is(true));
    assertThat(origin.getFetchRefSpecs().get(0).isWildcard(), is(false));
    assertThat(origin.getFetchRefSpecs().get(1).getSource(), is("refs/heads/test-branch"));
    assertThat(origin.getFetchRefSpecs().get(1).getDestination(), is("refs/remotes/origin/test-branch"));
    assertThat(origin.getFetchRefSpecs().get(1).isForceUpdate(), is(true));
    assertThat(origin.getFetchRefSpecs().get(1).isWildcard(), is(false));
    assertThat(actual.getExtensions(), containsInAnyOrder(
            instanceOf(MergeWithGitSCMExtension.class),
            instanceOf(GitSCMSourceDefaults.class))
    );
    MergeWithGitSCMExtension merge = getExtension(actual, MergeWithGitSCMExtension.class);
    assertThat(merge, notNullValue());
    assertThat(merge.getBaseName(), is("remotes/origin/test-branch"));
    assertThat(merge.getBaseHash(), is(nullValue()));
}