use of com.thoughtworks.go.domain.MaterialInstance in project gocd by gocd.
the class PluggableSCMMaterialPoller method checkout.
@Override
public void checkout(PluggableSCMMaterial material, File baseDir, Revision revision, SubprocessExecutionContext execCtx) {
SCMPropertyConfiguration scmPropertyConfiguration = buildSCMPropertyConfigurations(material.getScmConfig());
MaterialInstance materialInstance = materialRepository.findMaterialInstance(material);
PluggableSCMMaterialRevision pluggableSCMMaterialRevision = (PluggableSCMMaterialRevision) revision;
SCMRevision scmRevision = new SCMRevision(pluggableSCMMaterialRevision.getRevision(), pluggableSCMMaterialRevision.getTimestamp(), null, null, pluggableSCMMaterialRevision.getData(), null);
Result result = scmExtension.checkout(material.getPluginId(), scmPropertyConfiguration, baseDir.getAbsolutePath(), scmRevision);
if (!result.isSuccessful())
throw new RuntimeException("Failed to perform checkout on pluggable SCM");
}
use of com.thoughtworks.go.domain.MaterialInstance in project gocd by gocd.
the class PluggableSCMMaterialPoller method modificationsSince.
@Override
public List<Modification> modificationsSince(final PluggableSCMMaterial material, File baseDir, final Revision revision, SubprocessExecutionContext execCtx) {
SCMPropertyConfiguration scmPropertyConfiguration = buildSCMPropertyConfigurations(material.getScmConfig());
MaterialInstance materialInstance = materialRepository.findMaterialInstance(material);
PluggableSCMMaterialRevision pluggableSCMMaterialRevision = (PluggableSCMMaterialRevision) revision;
SCMRevision previouslyKnownRevision = new SCMRevision(pluggableSCMMaterialRevision.getRevision(), pluggableSCMMaterialRevision.getTimestamp(), null, null, pluggableSCMMaterialRevision.getData(), null);
MaterialPollResult pollResult = scmExtension.latestModificationSince(material.getPluginId(), scmPropertyConfiguration, materialInstance.getAdditionalDataMap(), baseDir.getAbsolutePath(), previouslyKnownRevision);
final Map<String, String> materialData = pollResult.getMaterialData();
if (materialInstance.requiresUpdate(materialData)) {
updateAdditionalData(materialInstance.getId(), materialData);
}
List<SCMRevision> scmRevisions = pollResult.getRevisions();
return getModifications(scmRevisions);
}
use of com.thoughtworks.go.domain.MaterialInstance in project gocd by gocd.
the class DownstreamInstancePopulator method apply.
public void apply(ValueStreamMap valueStreamMap) {
if (valueStreamMap.getCurrentPipeline() != null) {
Node currentPipeline = valueStreamMap.getCurrentPipeline();
populateRevisionsForAllChildrenOf(currentPipeline, new HashSet<>());
} else {
Node currentMaterial = valueStreamMap.getCurrentMaterial();
MaterialInstance currentMaterialInstance = valueStreamMap.getCurrentMaterialInstance();
populateRevisionsFor(currentMaterial, currentMaterialInstance, new HashSet<>());
}
}
use of com.thoughtworks.go.domain.MaterialInstance in project gocd by gocd.
the class GoCacheTest method get_shouldBombWhenValueIsAPersistentObjectWithoutId.
@Test
public void get_shouldBombWhenValueIsAPersistentObjectWithoutId() throws Exception {
HgMaterial material = MaterialsMother.hgMaterial();
MaterialInstance materialInstance = material.createMaterialInstance();
materialInstance.setId(10);
goCache.put("foo", materialInstance);
materialInstance.setId(-1);
try {
goCache.get("foo");
fail("should not allow getting a persistent object without id: " + materialInstance);
} catch (Exception e) {
// ok
}
}
use of com.thoughtworks.go.domain.MaterialInstance in project gocd by gocd.
the class PackageMaterialUpdaterTest method shouldUpdateToNewMaterialInstanceWhenConfigHas_Changed.
@Test
public void shouldUpdateToNewMaterialInstanceWhenConfigHas_Changed() throws Exception {
PackageMaterial material = MaterialsMother.packageMaterial();
MaterialInstance materialInstance = material.createMaterialInstance();
materialInstance.setId(1);
material.getPackageDefinition().getConfiguration().add(ConfigurationPropertyMother.create("key2", false, "value2"));
MaterialInstance newMaterialInstance = material.createMaterialInstance();
newMaterialInstance.setId(1);
File file = new File("random");
Modifications modifications = new Modifications();
when(materialRepository.find(anyLong())).thenReturn(materialInstance);
materialUpdater.insertLatestOrNewModifications(material, materialInstance, file, modifications);
verify(materialRepository).saveOrUpdate(newMaterialInstance);
verify(scmMaterialUpdater).insertLatestOrNewModifications(material, materialInstance, file, modifications);
}
Aggregations