Search in sources :

Example 6 with Modifications

use of com.thoughtworks.go.domain.materials.Modifications in project gocd by gocd.

the class ValueStreamMapServiceTest method shouldPopulateRevisionsForUpstreamPipelines.

@Test
public void shouldPopulateRevisionsForUpstreamPipelines() {
    /*
        * git---> p1 ---> p3
        * |      v      ^
        * +---> p2 -----+
        * **/
    GitMaterial git = new GitMaterial("git");
    MaterialConfig gitConfig = git.config();
    BuildCause p3buildCause = createBuildCause(asList("p1", "p2"), new ArrayList<>());
    BuildCause p2buildCause = createBuildCauseForRevisions(asList(dependencyMaterial("p1", 2)), asList(git), ModificationsMother.multipleModificationList(0));
    BuildCause p1buildCause = createBuildCause(new ArrayList<>(), asList(git));
    Modifications modifications = p1buildCause.getMaterialRevisions().getMaterialRevision(0).getModifications();
    when(pipelineService.buildCauseFor("p3", 1)).thenReturn(p3buildCause);
    when(pipelineService.buildCauseFor("p2", 1)).thenReturn(p2buildCause);
    when(pipelineService.buildCauseFor("p1", 1)).thenReturn(p1buildCause);
    when(pipelineService.buildCauseFor("p1", 2)).thenReturn(p1buildCause);
    PipelineConfig p1Config = PipelineConfigMother.pipelineConfig("p1", new MaterialConfigs(gitConfig));
    PipelineConfig p2Config = PipelineConfigMother.pipelineConfig("p2", new MaterialConfigs(gitConfig));
    PipelineConfig p3Config = PipelineConfigMother.pipelineConfig("p3", new MaterialConfigs(new DependencyMaterialConfig(p1Config.name(), p1Config.getFirstStageConfig().name()), new DependencyMaterialConfig(p2Config.name(), p2Config.getFirstStageConfig().name())));
    CruiseConfig cruiseConfig = new BasicCruiseConfig(new BasicPipelineConfigs(p1Config, p2Config, p3Config));
    when(pipelineService.findPipelineByCounterOrLabel("p3", "1")).thenReturn(new Pipeline("p3", "LABEL-P3", p3buildCause));
    when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
    ValueStreamMapPresentationModel graph = valueStreamMapService.getValueStreamMap("p3", 1, user, result);
    VSMTestHelper.assertNodeHasRevisions(graph, "p1", new PipelineRevision("p1", 1, "LABEL-p1-1"), new PipelineRevision("p1", 2, "LABEL-p1-2"));
    VSMTestHelper.assertNodeHasRevisions(graph, "p2", new PipelineRevision("p2", 1, "LABEL-p2-1"));
    VSMTestHelper.assertNodeHasRevisions(graph, "p3", new PipelineRevision("p3", 1, "LABEL-P3"));
    VSMTestHelper.assertSCMNodeHasMaterialRevisions(graph, git.getFingerprint(), new MaterialRevision(git, false, modifications));
    verify(runStagesPopulator).apply(any(ValueStreamMap.class));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Modifications(com.thoughtworks.go.domain.materials.Modifications) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) ValueStreamMapPresentationModel(com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Example 7 with Modifications

use of com.thoughtworks.go.domain.materials.Modifications in project gocd by gocd.

the class MaterialCheckerTest method updateChangedRevisionsShouldFilterRevisionsThatHaveBuiltBefore.

@Test
public void updateChangedRevisionsShouldFilterRevisionsThatHaveBuiltBefore() {
    CaseInsensitiveString pipelineName = new CaseInsensitiveString("pipelineName");
    GitMaterial gitMaterial = new GitMaterial("git://foo");
    BuildCause buildCause = BuildCause.createWithModifications(new MaterialRevisions(new MaterialRevision(gitMaterial, mod(10L), mod(9L), mod(8L))), "user");
    when(materialRepository.latestModificationRunByPipeline(pipelineName, gitMaterial)).thenReturn(9L);
    materialChecker.updateChangedRevisions(pipelineName, buildCause);
    MaterialRevisions actualRevisions = buildCause.getMaterialRevisions();
    assertThat(actualRevisions.getModifications(gitMaterial), is(new Modifications(mod(10L))));
    assertThat(actualRevisions.findRevisionFor(gitMaterial).isChanged(), is(true));
}
Also used : Modifications(com.thoughtworks.go.domain.materials.Modifications) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 8 with Modifications

use of com.thoughtworks.go.domain.materials.Modifications in project gocd by gocd.

the class MaterialCheckerTest method updateChangedRevisionsShouldRetainLatestRevisionIfAllHaveBuiltBefore.

@Test
public void updateChangedRevisionsShouldRetainLatestRevisionIfAllHaveBuiltBefore() {
    CaseInsensitiveString pipelineName = new CaseInsensitiveString("pipelineName");
    GitMaterial gitMaterial = new GitMaterial("git://foo");
    BuildCause buildCause = BuildCause.createWithModifications(new MaterialRevisions(new MaterialRevision(gitMaterial, mod(10L), mod(9L), mod(8L))), "user");
    when(materialRepository.latestModificationRunByPipeline(pipelineName, gitMaterial)).thenReturn(10L);
    materialChecker.updateChangedRevisions(pipelineName, buildCause);
    MaterialRevisions actualRevisions = buildCause.getMaterialRevisions();
    assertThat(actualRevisions.getModifications(gitMaterial), is(new Modifications(mod(10L), mod(9L), mod(8L))));
    assertThat(actualRevisions.findRevisionFor(gitMaterial).isChanged(), is(false));
}
Also used : Modifications(com.thoughtworks.go.domain.materials.Modifications) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 9 with Modifications

use of com.thoughtworks.go.domain.materials.Modifications 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);
}
Also used : Modifications(com.thoughtworks.go.domain.materials.Modifications) PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) MaterialInstance(com.thoughtworks.go.domain.MaterialInstance) File(java.io.File) Test(org.junit.Test)

Example 10 with Modifications

use of com.thoughtworks.go.domain.materials.Modifications in project gocd by gocd.

the class PackageMaterialUpdaterTest method shouldNotUpdateMaterialInstanceWhenConfigHas_NOT_Changed.

@Test
public void shouldNotUpdateMaterialInstanceWhenConfigHas_NOT_Changed() throws Exception {
    PackageMaterial material = MaterialsMother.packageMaterial();
    MaterialInstance materialInstance = material.createMaterialInstance();
    File file = new File("random");
    Modifications modifications = new Modifications();
    materialUpdater.insertLatestOrNewModifications(material, materialInstance, file, modifications);
    verify(materialRepository, never()).saveOrUpdate(Matchers.<MaterialInstance>any());
    verify(scmMaterialUpdater).insertLatestOrNewModifications(material, materialInstance, file, modifications);
}
Also used : Modifications(com.thoughtworks.go.domain.materials.Modifications) PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) MaterialInstance(com.thoughtworks.go.domain.MaterialInstance) File(java.io.File) Test(org.junit.Test)

Aggregations

Modifications (com.thoughtworks.go.domain.materials.Modifications)35 Test (org.junit.Test)29 Modification (com.thoughtworks.go.domain.materials.Modification)21 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)15 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)12 Date (java.util.Date)12 PluggableSCMMaterial (com.thoughtworks.go.config.materials.PluggableSCMMaterial)10 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)10 MaterialInstance (com.thoughtworks.go.domain.MaterialInstance)9 File (java.io.File)8 HashMap (java.util.HashMap)6 LinkedHashMap (java.util.LinkedHashMap)6 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)5 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)5 PackageMaterialRevision (com.thoughtworks.go.domain.materials.packagematerial.PackageMaterialRevision)5 PluggableSCMMaterialRevision (com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialRevision)5 SCM (com.thoughtworks.go.domain.scm.SCM)5 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)4 TransactionStatus (org.springframework.transaction.TransactionStatus)4 TransactionCallback (org.springframework.transaction.support.TransactionCallback)4