Skip to content
Permalink
Browse files

[JENKINS-44891] More tidy-up

  • Loading branch information...
stephenc committed Jun 14, 2017
1 parent fc5c194 commit 9d15020884f2ab3f53525f3c7d72c864cfeb5dbc
@@ -114,7 +114,8 @@ public void visitSources(@NonNull SCMSourceObserver observer) throws IOException
@NonNull
@Override
public SCMSource create(@NonNull String name) {
return new MockSCMSourceBuilder(getId() + "::" + name, controller, name)
return new MockSCMSourceBuilder(controller, name)
.withId(getId() + "::" + name)
.withRequest(request)
.build();
}
@@ -75,41 +75,6 @@
private final List<SCMSourceTrait> traits;
private transient MockSCMController controller;

@Restricted(NoExternalUse.class)
@RestrictedSince("2.2.0")
@Deprecated
public MockSCMSource(@CheckForNull String id, String controllerId, String repository, List<SCMSourceTrait> traits) {
super();
this.controllerId = controllerId;
this.repository = repository;
this.traits = new ArrayList<SCMSourceTrait>(traits);
setId(id);
}

@Restricted(NoExternalUse.class)
@RestrictedSince("2.2.0")
@Deprecated
public MockSCMSource(@CheckForNull String id, String controllerId, String repository, SCMSourceTrait... traits) {
this(controllerId, repository, Arrays.asList(traits));
setId(id);
}

@Restricted(NoExternalUse.class)
@RestrictedSince("2.2.0")
@Deprecated
public MockSCMSource(String id, MockSCMController controller, String repository, List<SCMSourceTrait> traits) {
this(controller, repository, traits);
setId(id);
}

@Restricted(NoExternalUse.class)
@RestrictedSince("2.2.0")
@Deprecated
public MockSCMSource(String id, MockSCMController controller, String repository, SCMSourceTrait... traits) {
this(controller, repository, Arrays.asList(traits));
setId(id);
}

@DataBoundConstructor
public MockSCMSource(String controllerId, String repository, List<SCMSourceTrait> traits) {
super();
@@ -28,34 +28,43 @@
import jenkins.scm.api.trait.SCMSourceBuilder;

public class MockSCMSourceBuilder extends SCMSourceBuilder<MockSCMSourceBuilder, MockSCMSource> {
private final String id;
private String id;
private final String controllerId;
private final MockSCMController controller;
private final String repository;

public MockSCMSourceBuilder(String id, MockSCMController controller, String repository) {
public MockSCMSourceBuilder(MockSCMController controller, String repository) {
super(MockSCMSource.class, repository);
this.id = id;
this.controllerId = controller.getId();
this.controller = controller;
this.repository = repository;
}

public MockSCMSourceBuilder(String id, String controllerId, String repository) {
public MockSCMSourceBuilder(String controllerId, String repository) {
super(MockSCMSource.class, repository);
this.id = id;
this.controllerId = controllerId;
this.controller = null;
this.repository = repository;
}

public final MockSCMSourceBuilder withId(String id) {
this.id = id;
return this;
}

public final String id() {
return id;
}

@NonNull
@Override
public MockSCMSource build() {
MockSCMSource source = controller == null
? new MockSCMSource(controllerId, repository, traits())
: new MockSCMSource(controller, repository, traits());
source.setId(id);
if (id != null) {
source.setId(id());
}
return source;
}
}

0 comments on commit 9d15020

Please sign in to comment.
You can’t perform that action at this time.