use of com.thoughtworks.go.domain.materials.Material in project gocd by gocd.
the class PipelineSqlMapDaoIntegrationTest method shouldStoreAndRetrieveMultipleSvnMaterials.
@Test
public void shouldStoreAndRetrieveMultipleSvnMaterials() throws SQLException {
SvnMaterial svnMaterial1 = svnMaterial("svnUrl1", "folder1");
SvnMaterial svnMaterial2 = svnMaterial("svnUrl2", "folder2");
PipelineConfig pipelineConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("mingle", "dev");
pipelineConfig.setMaterialConfigs(new MaterialConfigs(svnMaterial1.config(), svnMaterial2.config()));
Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, BuildCause.createManualForced(modifyOneFile(pipelineConfig), Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
assertNotInserted(pipeline.getId());
savePipeline(pipeline);
Pipeline pipelineFromDB = pipelineDao.loadPipeline(pipeline.getId());
Materials materials = pipelineFromDB.getMaterials();
assertThat(materials, hasItem((Material) svnMaterial1));
assertThat(materials, hasItem((Material) svnMaterial2));
}
use of com.thoughtworks.go.domain.materials.Material in project gocd by gocd.
the class ModificationsMother method modifyNoFiles.
public static BuildCause modifyNoFiles(PipelineConfig config) {
MaterialRevisions materialRevisions = new MaterialRevisions();
for (Material material : new MaterialConfigConverter().toMaterials(config.materialConfigs())) {
ArrayList<Modification> list = new ArrayList<>();
list.add(new Modification("no-user", "comment", "dummy-email", new Date(), "Dummy Modification" + UUID.randomUUID().toString()));
materialRevisions.addRevision(material, list);
}
return BuildCause.createWithModifications(materialRevisions, "");
}
use of com.thoughtworks.go.domain.materials.Material in project gocd by gocd.
the class ModificationsMother method modifyOneFile.
public static MaterialRevisions modifyOneFile(Materials materials, String revision, String comment, String committer) {
MaterialRevisions materialRevisions = new MaterialRevisions();
Materials expandedMaterials = new Materials();
for (Material material : materials) {
expandedMaterials.add(material);
}
for (Material material : expandedMaterials) {
Modification modification;
if (material instanceof DependencyMaterial) {
DependencyMaterial dependencyMaterial = (DependencyMaterial) material;
modification = oneModifiedFile(committer, dependencyMaterial.getPipelineName() + "/1/" + dependencyMaterial.getStageName() + "/" + revision, TWO_DAYS_AGO_CHECKIN, dependencyMaterial.getPipelineName() + "-1.2.3");
} else {
modification = oneModifiedFile(committer, revision, comment, TWO_DAYS_AGO_CHECKIN);
}
materialRevisions.addRevision(new MaterialRevision(material, true, modification));
}
return materialRevisions;
}
use of com.thoughtworks.go.domain.materials.Material in project gocd by gocd.
the class ModificationsMother method createP4MaterialRevisions.
public static MaterialRevisions createP4MaterialRevisions(Modification modification) {
List<Modification> modifications = new ArrayList<>();
modifications.add(modification);
Material svnMaterial = MaterialsMother.p4Material();
MaterialRevisions revisions = new MaterialRevisions();
revisions.addRevision(svnMaterial, modifications);
return revisions;
}
use of com.thoughtworks.go.domain.materials.Material in project gocd by gocd.
the class FanInGraph method createFinalRevisionsForScmChildren.
private List<MaterialRevision> createFinalRevisionsForScmChildren(PipelineTimelineEntry latestRootNodeInstance, List<RootFanInNode> scmChildren, List<DependencyFanInNode> depChildren) {
Set<FaninScmMaterial> scmMaterialsFromDepChildren = scmMaterialsOfDepChildren(depChildren);
List<MaterialRevision> finalRevisions = new ArrayList<>();
for (RootFanInNode child : scmChildren) {
child.setScmRevision(scmMaterialsFromDepChildren);
MaterialConfig materialConfig = child.materialConfig;
Material material = materialConfigConverter.toMaterial(materialConfig);
MaterialRevision revision = new MaterialRevision(material);
if (latestRootNodeInstance != null) {
PipelineInstanceModel pipeline = pipelineDao.findPipelineHistoryByNameAndCounter(latestRootNodeInstance.getPipelineName(), latestRootNodeInstance.getCounter());
for (MaterialRevision materialRevision : pipeline.getCurrentRevisions()) {
if (materialRevision.getMaterial().getFingerprint().equals(child.materialConfig.getFingerprint())) {
List<Modification> modificationsSince = materialRepository.findModificationsSinceAndUptil(material, materialRevision, child.scmRevision);
revision.addModifications(modificationsSince);
break;
}
}
}
if (revision.getModifications().isEmpty() && child.scmRevision == null) {
MaterialRevisions latestRevisions = materialRepository.findLatestRevisions(new MaterialConfigs(materialConfig));
finalRevisions.addAll(latestRevisions.getRevisions());
continue;
}
if (revision.getModifications().isEmpty()) {
revision = new MaterialRevision(material, materialRepository.findModificationWithRevision(material, child.scmRevision.revision));
}
finalRevisions.add(revision);
}
return finalRevisions;
}
Aggregations