use of com.thoughtworks.go.config.materials.PluggableSCMMaterial in project gocd by gocd.
the class PipelineMother method pipelineWithAllTypesOfMaterials.
public static Pipeline pipelineWithAllTypesOfMaterials(String pipelineName, String stageName, String jobName, String fixedMaterialRevisionForAllMaterials) {
GitMaterial gitMaterial = MaterialsMother.gitMaterial("http://user:password@gitrepo.com", null, "branch");
HgMaterial hgMaterial = MaterialsMother.hgMaterial("http://user:password@hgrepo.com");
SvnMaterial svnMaterial = MaterialsMother.svnMaterial("http://user:password@svnrepo.com", null, "username", "password", false, null);
TfsMaterial tfsMaterial = MaterialsMother.tfsMaterial("http://user:password@tfsrepo.com");
P4Material p4Material = MaterialsMother.p4Material("127.0.0.1:1666", "username", "password", "view", false);
DependencyMaterial dependencyMaterial = MaterialsMother.dependencyMaterial();
PackageMaterial packageMaterial = MaterialsMother.packageMaterial();
PluggableSCMMaterial pluggableSCMMaterial = MaterialsMother.pluggableSCMMaterial();
Materials materials = new Materials(gitMaterial, hgMaterial, svnMaterial, tfsMaterial, p4Material, dependencyMaterial, packageMaterial, pluggableSCMMaterial);
return new Pipeline(pipelineName, BuildCause.createWithModifications(ModificationsMother.modifyOneFile(materials, fixedMaterialRevisionForAllMaterials), ""), StageMother.passedStageInstance(stageName, jobName, pipelineName));
}
use of com.thoughtworks.go.config.materials.PluggableSCMMaterial in project gocd by gocd.
the class PluggableSCMPostCommitHookImplementer method prune.
@Override
public Set<Material> prune(Set<Material> materials, Map params) {
HashSet<Material> prunedCollection = new HashSet<>();
String paramSCMName = (String) params.get(SCM_NAME);
if (StringUtils.isNotBlank(paramSCMName)) {
for (Material material : materials) {
if (material instanceof PluggableSCMMaterial && paramSCMName.equalsIgnoreCase(((PluggableSCMMaterial) material).getScmConfig().getName())) {
prunedCollection.add(material);
}
}
}
return prunedCollection;
}
use of com.thoughtworks.go.config.materials.PluggableSCMMaterial in project gocd by gocd.
the class PluggableSCMMaterialUpdaterIntegrationTest method shouldUpdateMaterialInstanceWhenAdditionalDataIsUpdatedDuringLatestModification.
@Test
public void shouldUpdateMaterialInstanceWhenAdditionalDataIsUpdatedDuringLatestModification() throws Exception {
final PluggableSCMMaterial material = MaterialsMother.pluggableSCMMaterial();
final MaterialInstance materialInstance = material.createMaterialInstance();
materialRepository.saveOrUpdate(materialInstance);
Map<String, String> data = new HashMap<>();
data.put("k1", "v1");
when(scmExtension.getLatestRevision(any(String.class), any(SCMPropertyConfiguration.class), any(Map.class), any(String.class))).thenReturn(new MaterialPollResult(data, new SCMRevision()));
mockSCMExtensionInPoller();
scmMaterialUpdater = new ScmMaterialUpdater(materialRepository, materialChecker, subprocessExecutionContext, materialService);
pluggableSCMMaterialUpdater = new PluggableSCMMaterialUpdater(materialRepository, scmMaterialUpdater, transactionTemplate);
transactionTemplate.execute(new TransactionCallback() {
@Override
public Object doInTransaction(TransactionStatus transactionStatus) {
pluggableSCMMaterialUpdater.insertLatestOrNewModifications(material, materialInstance, new File(""), new Modifications());
return null;
}
});
MaterialInstance actualInstance = materialRepository.findMaterialInstance(material);
assertThat(actualInstance.getAdditionalDataMap(), is(data));
}
use of com.thoughtworks.go.config.materials.PluggableSCMMaterial in project gocd by gocd.
the class FaninDependencyResolutionTest method shouldResolveDiamondDependencyWithPluggableSCMMaterial.
@Test
public void shouldResolveDiamondDependencyWithPluggableSCMMaterial() {
/*
+---> P1 ---+
| v
scm1 P3
| ^
+--> P2 ----+
*/
int i = 1;
PluggableSCMMaterial pluggableSCMMaterial = MaterialsMother.pluggableSCMMaterial();
u.addSCMConfig(pluggableSCMMaterial.getScmConfig());
String[] pkg_revs = { "scm1-1", "scm1-2" };
u.checkinInOrder(pluggableSCMMaterial, u.d(i++), pkg_revs);
ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("p1", u.m(pluggableSCMMaterial));
ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("p2", u.m(pluggableSCMMaterial));
ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("p3", u.m(p1), u.m(p2));
String p1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "scm1-1");
String p2_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "scm1-1");
String p2_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "scm1-2");
MaterialRevisions given = u.mrs(u.mr(p1, true, p1_1), u.mr(p2, true, p2_2));
MaterialRevisions expected = u.mrs(u.mr(p1, true, p1_1), u.mr(p2, true, p2_1));
assertThat(getRevisionsBasedOnDependencies(p3, goConfigDao.load(), given), is(expected));
}
use of com.thoughtworks.go.config.materials.PluggableSCMMaterial in project gocd by gocd.
the class MaterialInstanceTest method shouldAnswerRequiresUpdate.
@Test
public void shouldAnswerRequiresUpdate() {
PluggableSCMMaterial material = MaterialsMother.pluggableSCMMaterial();
MaterialInstance materialInstance = material.createMaterialInstance();
// null
materialInstance.setAdditionalData(null);
assertThat(materialInstance.requiresUpdate(null), is(false));
assertThat(materialInstance.requiresUpdate(new HashMap<>()), is(false));
// empty
materialInstance.setAdditionalData(JsonHelper.toJsonString(new HashMap<String, String>()));
assertThat(materialInstance.requiresUpdate(null), is(false));
assertThat(materialInstance.requiresUpdate(new HashMap<>()), is(false));
// with data
Map<String, String> data = new HashMap<>();
data.put("k1", "v1");
data.put("k2", "v2");
materialInstance.setAdditionalData(JsonHelper.toJsonString(data));
assertThat(materialInstance.requiresUpdate(null), is(true));
assertThat(materialInstance.requiresUpdate(new HashMap<>()), is(true));
assertThat(materialInstance.requiresUpdate(data), is(false));
// missing key-value
Map<String, String> dataWithMissingKey = new HashMap<>(data);
dataWithMissingKey.remove("k1");
assertThat(materialInstance.requiresUpdate(dataWithMissingKey), is(true));
// extra key-value
Map<String, String> dataWithExtraKey = new HashMap<>(data);
dataWithExtraKey.put("k3", "v3");
assertThat(materialInstance.requiresUpdate(dataWithExtraKey), is(true));
}
Aggregations