Search in sources :

Example 11 with Materials

use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.

the class MaterialCheckerTest method shouldNOTSkipFindingRevisionsSinceForMaterialsThatAreNewlyAdded.

@Test
public void shouldNOTSkipFindingRevisionsSinceForMaterialsThatAreNewlyAdded() throws Exception {
    SvnMaterial svnMaterial = new SvnMaterial("svnUrl", null, null, false);
    SvnMaterial svnExternalMaterial = new SvnMaterial("svnExternalUrl", null, null, false);
    Modification svnExternalModification = new Modification("user", "external commit", "em@il", new Date(), "3");
    MaterialRevision previousSvnRevision = new MaterialRevision(svnMaterial, mod(1L));
    Modification svnModification = new Modification("user", "commend", "em@il", new Date(), "2");
    MaterialRevisions latestRevisions = new MaterialRevisions(new MaterialRevision(svnMaterial, svnModification), new MaterialRevision(svnExternalMaterial, svnExternalModification));
    Mockito.when(materialRepository.findModificationsSince(svnMaterial, previousSvnRevision)).thenReturn(modifications(svnModification));
    MaterialRevisions revisionsSince = materialChecker.findRevisionsSince(new MaterialRevisions(), new Materials(svnMaterial, svnExternalMaterial), new MaterialRevisions(previousSvnRevision), latestRevisions);
    assertThat(revisionsSince, is(new MaterialRevisions(new MaterialRevision(svnMaterial, svnModification), new MaterialRevision(svnExternalMaterial, svnExternalModification))));
    Mockito.verify(materialRepository).findModificationsSince(svnMaterial, previousSvnRevision);
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Materials(com.thoughtworks.go.config.materials.Materials) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Date(java.util.Date) Test(org.junit.Test)

Example 12 with Materials

use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.

the class MaterialCheckerTest method shouldUseLatestPipelineInstanceForDependentPipelineGivenThePreviousRevision.

@Test
public void shouldUseLatestPipelineInstanceForDependentPipelineGivenThePreviousRevision() throws Exception {
    DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
    Stage passedStage = StageMother.passedStageInstance("stage-name", "job-name", "pipeline-name");
    MaterialRevisions materialRevisions = new MaterialRevisions();
    Modification previous = new Modification("Unknown", "Unknown", null, passedStage.completedDate(), "pipeline-name/1/stage-name/0");
    MaterialRevision previousRevision = revisions(dependencyMaterial, previous).getMaterialRevision(0);
    when(materialRepository.findModificationsSince(dependencyMaterial, previousRevision)).thenReturn(Arrays.asList(new Modification(new Date(), "pipeline-name/2/stage-name/0", "MOCK_LABEL-12", null)));
    MaterialRevisions revisionsSince = materialChecker.findRevisionsSince(materialRevisions, new Materials(dependencyMaterial), new MaterialRevisions(previousRevision), new MaterialRevisions());
    assertThat(revisionsSince.getMaterialRevision(0).getRevision().getRevision(), is("pipeline-name/2/stage-name/0"));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Materials(com.thoughtworks.go.config.materials.Materials) Stage(com.thoughtworks.go.domain.Stage) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Date(java.util.Date) Test(org.junit.Test)

Example 13 with Materials

use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.

the class MaterialCheckerTest method shouldUseLatestPipelineInstanceForDependentPipeline.

@Test
public void shouldUseLatestPipelineInstanceForDependentPipeline() throws Exception {
    DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
    Stage passedStage = StageMother.passedStageInstance("stage-name", "job-name", "pipeline-name");
    Modification modification = new Modification("Unknown", "Unknown", null, passedStage.completedDate(), "pipeline-name/1[LABEL-1]/stage-name/0");
    Mockito.when(materialRepository.findLatestModification(dependencyMaterial)).thenReturn(revisions(dependencyMaterial, modification));
    materialChecker.findLatestRevisions(new MaterialRevisions(), new Materials(dependencyMaterial));
    Mockito.verify(materialRepository).findLatestModification(dependencyMaterial);
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Materials(com.thoughtworks.go.config.materials.Materials) Stage(com.thoughtworks.go.domain.Stage) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 14 with Materials

use of com.thoughtworks.go.config.materials.Materials 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 15 with Materials

use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.

the class MixedMultipleMaterialsTest method shouldGetLatestModificationswithThreeRepositories.

@Test
public void shouldGetLatestModificationswithThreeRepositories() throws Exception {
    HgMaterial hgMaterial = hgRepo.material();
    SvnMaterial svnMaterial = svnRepo.createMaterial("multiple-materials/trunk/part1", "part1");
    GitMaterial gitMaterial = gitRepo.createMaterial();
    Materials materials = new Materials(hgMaterial, svnMaterial, gitMaterial);
    MaterialRevisions revisions = materials.latestModification(pipelineDir, new TestSubprocessExecutionContext());
    assertThat(revisions.getMaterialRevision(0).numberOfModifications(), is(1));
    assertThat(revisions.getMaterialRevision(0).getRevision(), is(new Modifications(hgRepo.latestModifications()).latestRevision(hgMaterial)));
    assertThat(revisions.getMaterialRevision(1).numberOfModifications(), is(1));
    assertThat(revisions.getMaterialRevision(1).getRevision(), is(latestRevision(svnMaterial, pipelineDir, new TestSubprocessExecutionContext())));
    assertThat(revisions.getMaterialRevision(2).numberOfModifications(), is(1));
    assertThat(revisions.getMaterialRevision(2).getRevision(), is(new Modifications(gitRepo.latestModifications()).latestRevision(gitMaterial)));
    assertThat(revisions.toString(), revisions.totalNumberOfModifications(), is(3));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Materials(com.thoughtworks.go.config.materials.Materials) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Test(org.junit.Test)

Aggregations

Materials (com.thoughtworks.go.config.materials.Materials)58 Test (org.junit.Test)48 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)24 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)19 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)19 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)16 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)14 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)13 Material (com.thoughtworks.go.domain.materials.Material)10 Modification (com.thoughtworks.go.domain.materials.Modification)10 File (java.io.File)10 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)9 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)9 Date (java.util.Date)9 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)8 MaterialRevisionsMatchers.containsModifiedFile (com.thoughtworks.go.config.MaterialRevisionsMatchers.containsModifiedFile)5 P4Material (com.thoughtworks.go.config.materials.perforce.P4Material)5 Stage (com.thoughtworks.go.domain.Stage)5 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)5 PackageMaterial (com.thoughtworks.go.config.materials.PackageMaterial)4