Search in sources :

Example 16 with Material

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));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) TimeProvider(com.thoughtworks.go.util.TimeProvider) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Materials(com.thoughtworks.go.config.materials.Materials) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) MaterialsMother.svnMaterial(com.thoughtworks.go.helper.MaterialsMother.svnMaterial) ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) Material(com.thoughtworks.go.domain.materials.Material) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) Test(org.junit.jupiter.api.Test)

Example 17 with Material

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, "");
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Material(com.thoughtworks.go.domain.materials.Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) MaterialConfigConverter(com.thoughtworks.go.server.service.MaterialConfigConverter)

Example 18 with Material

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;
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Materials(com.thoughtworks.go.config.materials.Materials) Material(com.thoughtworks.go.domain.materials.Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision)

Example 19 with Material

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;
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Material(com.thoughtworks.go.domain.materials.Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial)

Example 20 with Material

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;
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Material(com.thoughtworks.go.domain.materials.Material) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision)

Aggregations

Material (com.thoughtworks.go.domain.materials.Material)122 Test (org.junit.jupiter.api.Test)72 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)49 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)47 Modification (com.thoughtworks.go.domain.materials.Modification)29 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)28 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)24 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)19 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)19 PluggableSCMMaterial (com.thoughtworks.go.config.materials.PluggableSCMMaterial)19 ScmMaterial (com.thoughtworks.go.config.materials.ScmMaterial)18 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)18 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)16 Materials (com.thoughtworks.go.config.materials.Materials)14 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)13 File (java.io.File)13 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)12 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)12 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)12 P4Material (com.thoughtworks.go.config.materials.perforce.P4Material)8