Skip to content
Permalink
Browse files

[JENKINS-43507] Fix test case in AbstractGitSCMSourceRetrieveHeadsTest

  • Loading branch information...
stephenc committed May 2, 2017
1 parent 1bb8905 commit 802e7ce073ef99ee6c6a9a0188c1df95c8ccfc9d
@@ -12,6 +12,7 @@
import jenkins.scm.api.trait.SCMBuilder;
import jenkins.scm.api.SCMSource;
import jenkins.scm.api.trait.SCMSourceContext;
import jenkins.scm.api.trait.SCMSourceRequest;
import jenkins.scm.api.trait.SCMSourceTrait;
import jenkins.scm.api.trait.SCMSourceTraitDescriptor;
import org.kohsuke.stapler.DataBoundConstructor;
@@ -31,6 +32,11 @@ public String getGitTool() {
return gitTool;
}

@Override
protected <B extends SCMSourceContext<B, R>, R extends SCMSourceRequest> void decorateContext(B context) {
((GitSCMSourceContext<?,?>)context).withGitTool(gitTool);
}

@Override
protected <B extends SCMBuilder<B, S>, S extends SCM> void decorateBuilder(B builder) {
((GitSCMBuilder<?>) builder).withGitTool(gitTool);
@@ -8,12 +8,13 @@
import hudson.FilePath;
import hudson.model.TaskListener;
import hudson.plugins.git.GitTool;
import jenkins.plugins.git.traits.GitBrowserSCMSourceTrait;
import jenkins.plugins.git.traits.GitToolSCMSourceTrait;
import jenkins.scm.api.SCMHead;
import jenkins.scm.api.SCMHeadObserver;
import jenkins.scm.api.SCMSourceDescriptor;
import jenkins.scm.api.trait.SCMSourceTrait;
import org.eclipse.jgit.transport.RefSpec;
import jenkins.scm.api.trait.SCMSourceTraitDescriptor;
import org.jenkinsci.plugins.gitclient.Git;
import org.junit.Assert;
import org.junit.Before;
@@ -55,7 +56,7 @@ public void setup() throws Exception {
// Partial mock our AbstractGitSCMSourceImpl
gitSCMSource = PowerMockito.spy(new AbstractGitSCMSourceImpl());
// Always resolve to mocked GitTool
PowerMockito.doReturn(mockedTool).when(gitSCMSource).resolveGitTool();
PowerMockito.doReturn(mockedTool).when(gitSCMSource).resolveGitTool(EXPECTED_GIT_EXE);
}

/**
@@ -68,7 +69,7 @@ public void correctGitToolIsUsed() throws Exception {
// Should throw exception confirming that Git#using was used correctly
gitSCMSource.retrieve(new SCMHead("master"), TaskListener.NULL);
} catch (GitToolNotSpecified e) {
Assert.fail("Git client was constructed wirth arbitrary git tool");
Assert.fail("Git client was constructed with arbitrary git tool");
}
}

@@ -103,7 +104,12 @@ public AbstractGitSCMSourceImpl() {
@NonNull
@Override
public List<SCMSourceTrait> getTraits() {
return Collections.<SCMSourceTrait>singletonList(new GitToolSCMSourceTrait("EXPECTED_GIT_EXE"));
return Collections.<SCMSourceTrait>singletonList(new GitToolSCMSourceTrait(EXPECTED_GIT_EXE){
@Override
public SCMSourceTraitDescriptor getDescriptor() {
return new GitBrowserSCMSourceTrait.DescriptorImpl();
}
});
}

@Override
@@ -116,11 +122,6 @@ public String getRemote() {
return "";
}

@Override
protected List<RefSpec> getRefSpecs() {
return Collections.emptyList();
}

@Override
public SCMSourceDescriptor getDescriptor() {
return new DescriptorImpl();

0 comments on commit 802e7ce

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.