use of com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig in project gocd by gocd.
the class PipelineInstanceModelTest method shouldGetLatestRevisionForMaterial.
@Test
public void shouldGetLatestRevisionForMaterial() {
HgMaterialConfig hgMaterialConfig = MaterialConfigsMother.hgMaterialConfig();
assertThat(setUpModificationForHgMaterial().getLatestRevision(hgMaterialConfig).getRevision(), is("a087402bd2a7828a130c1bdf43f2d9ef8f48fd46"));
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig in project gocd by gocd.
the class HgTestRepo method createMaterialConfig.
public HgMaterialConfig createMaterialConfig(String dest) {
HgMaterialConfig materialConfig = materialConfig();
materialConfig.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, dest));
return materialConfig;
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig in project gocd by gocd.
the class ConfigConverter method toScmMaterialConfig.
private ScmMaterialConfig toScmMaterialConfig(CRScmMaterial crScmMaterial) {
String materialName = crScmMaterial.getName();
if (crScmMaterial instanceof CRGitMaterial) {
CRGitMaterial git = (CRGitMaterial) crScmMaterial;
String gitBranch = git.getBranch();
if (StringUtils.isBlank(gitBranch))
gitBranch = GitMaterialConfig.DEFAULT_BRANCH;
GitMaterialConfig gitConfig = new GitMaterialConfig(git.getUrl(), gitBranch, git.shallowClone());
setCommonMaterialMembers(gitConfig, crScmMaterial);
setCommonScmMaterialMembers(gitConfig, git);
return gitConfig;
} else if (crScmMaterial instanceof CRHgMaterial) {
CRHgMaterial hg = (CRHgMaterial) crScmMaterial;
return new HgMaterialConfig(new HgUrlArgument(hg.getUrl()), hg.isAutoUpdate(), toFilter(crScmMaterial), false, hg.getDirectory(), toMaterialName(materialName));
} else if (crScmMaterial instanceof CRP4Material) {
CRP4Material crp4Material = (CRP4Material) crScmMaterial;
P4MaterialConfig p4MaterialConfig = new P4MaterialConfig(crp4Material.getServerAndPort(), crp4Material.getView(), cipher);
if (crp4Material.getEncryptedPassword() != null) {
p4MaterialConfig.setEncryptedPassword(crp4Material.getEncryptedPassword());
} else {
p4MaterialConfig.setPassword(crp4Material.getPassword());
}
p4MaterialConfig.setUserName(crp4Material.getUserName());
p4MaterialConfig.setUseTickets(crp4Material.getUseTickets());
setCommonMaterialMembers(p4MaterialConfig, crScmMaterial);
setCommonScmMaterialMembers(p4MaterialConfig, crp4Material);
return p4MaterialConfig;
} else if (crScmMaterial instanceof CRSvnMaterial) {
CRSvnMaterial crSvnMaterial = (CRSvnMaterial) crScmMaterial;
SvnMaterialConfig svnMaterialConfig = new SvnMaterialConfig(crSvnMaterial.getUrl(), crSvnMaterial.getUserName(), crSvnMaterial.isCheckExternals(), cipher);
if (crSvnMaterial.getEncryptedPassword() != null) {
svnMaterialConfig.setEncryptedPassword(crSvnMaterial.getEncryptedPassword());
} else {
svnMaterialConfig.setPassword(crSvnMaterial.getPassword());
}
setCommonMaterialMembers(svnMaterialConfig, crScmMaterial);
setCommonScmMaterialMembers(svnMaterialConfig, crSvnMaterial);
return svnMaterialConfig;
} else if (crScmMaterial instanceof CRTfsMaterial) {
CRTfsMaterial crTfsMaterial = (CRTfsMaterial) crScmMaterial;
TfsMaterialConfig tfsMaterialConfig = new TfsMaterialConfig(cipher, new UrlArgument(crTfsMaterial.getUrl()), crTfsMaterial.getUserName(), crTfsMaterial.getDomain(), crTfsMaterial.getProjectPath());
if (crTfsMaterial.getEncryptedPassword() != null) {
tfsMaterialConfig.setEncryptedPassword(crTfsMaterial.getEncryptedPassword());
} else {
tfsMaterialConfig.setPassword(crTfsMaterial.getPassword());
}
setCommonMaterialMembers(tfsMaterialConfig, crTfsMaterial);
setCommonScmMaterialMembers(tfsMaterialConfig, crTfsMaterial);
return tfsMaterialConfig;
} else
throw new ConfigConvertionException(String.format("unknown scm material type '%s'", crScmMaterial));
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig in project gocd by gocd.
the class PipelineConfigDependencyGraphTest method shouldReturnTheSetOfFingerprintsOfAllMaterials.
@Test
public void shouldReturnTheSetOfFingerprintsOfAllMaterials() throws Exception {
HgMaterialConfig common = MaterialConfigsMother.hgMaterialConfig();
SvnMaterialConfig firstOrderSVNMaterial = MaterialConfigsMother.svnMaterialConfig();
GitMaterialConfig firstOrderGitMaterial = MaterialConfigsMother.gitMaterialConfig("url", "submodule", "branch", false);
P4MaterialConfig firstOrderP4Material = MaterialConfigsMother.p4MaterialConfig();
DependencyMaterialConfig up1DependencyMaterial = new DependencyMaterialConfig(new CaseInsensitiveString("up1"), new CaseInsensitiveString("first"));
DependencyMaterialConfig up2DependencyMaterial = new DependencyMaterialConfig(new CaseInsensitiveString("up2"), new CaseInsensitiveString("first"));
DependencyMaterialConfig uppestDependencyMaterial = new DependencyMaterialConfig(new CaseInsensitiveString("uppest"), new CaseInsensitiveString("first"));
PipelineConfig current = GoConfigMother.createPipelineConfigWithMaterialConfig("current", common, up1DependencyMaterial, up2DependencyMaterial);
PipelineConfig up1 = GoConfigMother.createPipelineConfigWithMaterialConfig("up1", common, firstOrderGitMaterial, uppestDependencyMaterial);
PipelineConfig up2 = GoConfigMother.createPipelineConfigWithMaterialConfig("up2", firstOrderSVNMaterial, common, uppestDependencyMaterial);
PipelineConfig uppest = GoConfigMother.createPipelineConfigWithMaterialConfig("uppest", common, firstOrderP4Material);
PipelineConfigDependencyGraph uppestGraph = new PipelineConfigDependencyGraph(uppest);
PipelineConfigDependencyGraph up1Graph = new PipelineConfigDependencyGraph(up1, uppestGraph);
PipelineConfigDependencyGraph up2Graph = new PipelineConfigDependencyGraph(up2, uppestGraph);
PipelineConfigDependencyGraph dependencyGraph = new PipelineConfigDependencyGraph(current, up1Graph, up2Graph);
assertThat(dependencyGraph.allMaterialFingerprints().size(), is(7));
assertThat(dependencyGraph.allMaterialFingerprints(), hasItems(common.getFingerprint(), firstOrderSVNMaterial.getFingerprint(), firstOrderGitMaterial.getFingerprint(), firstOrderP4Material.getFingerprint(), up1DependencyMaterial.getFingerprint(), up2DependencyMaterial.getFingerprint(), uppestDependencyMaterial.getFingerprint()));
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig in project gocd by gocd.
the class CruiseConfigTestBase method shouldReturnAllUniqueSchedulableScmMaterials.
@Test
public void shouldReturnAllUniqueSchedulableScmMaterials() {
final MaterialConfig svnMaterialConfig = new SvnMaterialConfig("http://svn_url_1", "username", "password", false);
svnMaterialConfig.setAutoUpdate(false);
final MaterialConfig svnMaterialConfigWithAutoUpdate = new SvnMaterialConfig("http://svn_url_2", "username", "password", false);
svnMaterialConfigWithAutoUpdate.setAutoUpdate(true);
final MaterialConfig hgMaterialConfig = new HgMaterialConfig("http://hg_url", null);
hgMaterialConfig.setAutoUpdate(false);
final MaterialConfig gitMaterialConfig = new GitMaterialConfig("http://git_url");
gitMaterialConfig.setAutoUpdate(false);
final MaterialConfig tfsMaterialConfig = new TfsMaterialConfig(mock(GoCipher.class), new UrlArgument("http://tfs_url"), "username", "domain", "password", "project_path");
tfsMaterialConfig.setAutoUpdate(false);
final MaterialConfig p4MaterialConfig = new P4MaterialConfig("http://p4_url", "view", "username");
p4MaterialConfig.setAutoUpdate(false);
final MaterialConfig dependencyMaterialConfig = MaterialConfigsMother.dependencyMaterialConfig();
final PluggableSCMMaterialConfig pluggableSCMMaterialConfig = MaterialConfigsMother.pluggableSCMMaterialConfig("scm-id-1", null, null);
pluggableSCMMaterialConfig.getSCMConfig().setAutoUpdate(false);
final PipelineConfig p1 = PipelineConfigMother.pipelineConfig("pipeline1", new MaterialConfigs(svnMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
final PipelineConfig p2 = PipelineConfigMother.pipelineConfig("pipeline2", new MaterialConfigs(svnMaterialConfig, gitMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
final PipelineConfig p3 = PipelineConfigMother.pipelineConfig("pipeline3", new MaterialConfigs(hgMaterialConfig, dependencyMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
final PipelineConfig p4 = PipelineConfigMother.pipelineConfig("pipeline4", new MaterialConfigs(p4MaterialConfig, pluggableSCMMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
final PipelineConfig p5 = PipelineConfigMother.pipelineConfig("pipeline5", new MaterialConfigs(svnMaterialConfigWithAutoUpdate, tfsMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
cruiseConfig.getGroups().add(new BasicPipelineConfigs(p1, p2, p3, p4, p5));
final Set<MaterialConfig> materials = cruiseConfig.getAllUniquePostCommitSchedulableMaterials();
assertThat(materials.size(), is(6));
assertThat(materials, hasItems(svnMaterialConfig, hgMaterialConfig, gitMaterialConfig, tfsMaterialConfig, p4MaterialConfig, pluggableSCMMaterialConfig));
assertThat(materials, not(hasItem(svnMaterialConfigWithAutoUpdate)));
}
Aggregations