Search in sources :

Example 66 with MaterialConfigs

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

the class MaterialRepositoryIntegrationTest method hasPipelineEverRunWithMultipleMaterialsInPeggedRevisionsCase.

@Test
public void hasPipelineEverRunWithMultipleMaterialsInPeggedRevisionsCase() {
    HgMaterial firstMaterial = MaterialsMother.hgMaterial("first", "dest");
    MaterialRevision first1 = saveOneScmModification("first1", firstMaterial, "user", "file", "comment");
    MaterialRevision first2 = saveOneScmModification("first2", firstMaterial, "user", "file", "comment");
    HgMaterial secondMaterial = MaterialsMother.hgMaterial("second", "dest");
    MaterialRevision second1 = saveOneScmModification("second1", secondMaterial, "user", "file", "comment");
    MaterialRevision second2 = saveOneScmModification("second2", secondMaterial, "user", "file", "comment");
    MaterialRevisions firstRun = new MaterialRevisions(first1, second2);
    MaterialRevisions secondRun = new MaterialRevisions(first2, second1);
    PipelineConfig config = PipelineMother.createPipelineConfig("mingle", new MaterialConfigs(firstMaterial.config(), secondMaterial.config()), "dev");
    savePipeline(instanceFactory.createPipelineInstance(config, BuildCause.createWithModifications(firstRun, "Pavan"), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider()));
    savePipeline(instanceFactory.createPipelineInstance(config, BuildCause.createWithModifications(secondRun, "Shilpa-who-gets-along-well-with-her"), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider()));
    assertThat(repo.hasPipelineEverRunWith("mingle", new MaterialRevisions(first2, second2)), is(true));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) TimeProvider(com.thoughtworks.go.util.TimeProvider) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Test(org.junit.Test)

Example 67 with MaterialConfigs

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

the class MaterialRepositoryIntegrationTest method hasPipelineEverRunWithIsFalseWhenThereAreNewerModificationsThatHaveNotBeenBuilt.

@Test
public void hasPipelineEverRunWithIsFalseWhenThereAreNewerModificationsThatHaveNotBeenBuilt() {
    HgMaterial hgMaterial = MaterialsMother.hgMaterial("hgUrl", "dest");
    MaterialRevision materialRevision = saveOneScmModification(hgMaterial, "user", "file");
    PipelineConfig pipelineConfig = PipelineMother.createPipelineConfig("mingle", new MaterialConfigs(hgMaterial.config()), "dev");
    MaterialRevisions materialRevisions = new MaterialRevisions(materialRevision);
    Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, BuildCause.createManualForced(materialRevisions, Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
    pipelineSqlMapDao.save(pipeline);
    MaterialRevision notBuiltRevision = saveOneScmModification(hgMaterial, "user", "file2");
    MaterialRevisions revisions = new MaterialRevisions(new MaterialRevision(hgMaterial, notBuiltRevision.getLatestModification()));
    assertThat(repo.hasPipelineEverRunWith("mingle", revisions), is(false));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) TimeProvider(com.thoughtworks.go.util.TimeProvider) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Test(org.junit.Test)

Example 68 with MaterialConfigs

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

the class MaterialRepositoryIntegrationTest method shouldReturnMaterialRevisionsWithEmptyModificationsWhenNoModifications.

@Test
public void shouldReturnMaterialRevisionsWithEmptyModificationsWhenNoModifications() throws Exception {
    Material material = material();
    repo.saveOrUpdate(material.createMaterialInstance());
    MaterialRevisions materialRevisions = repo.findLatestRevisions(new MaterialConfigs(material.config()));
    assertThat(materialRevisions.numberOfRevisions(), is(1));
    MaterialRevision materialRevision = materialRevisions.getMaterialRevision(0);
    assertThat(materialRevision.getMaterial(), is(material));
    assertThat(materialRevision.getModifications().size(), is(0));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) Test(org.junit.Test)

Example 69 with MaterialConfigs

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

the class PipelineScheduleServiceTest method shouldForceStagePlanWithModificationsSinceLast.

@Test
public void shouldForceStagePlanWithModificationsSinceLast() throws Exception {
    Pipeline completedMingle = scheduleAndCompleteInitialPipelines();
    pipelineDao.loadPipeline(completedMingle.getId());
    TestingMaterial testingMaterial = new TestingMaterial();
    mingleConfig.setMaterialConfigs(new MaterialConfigs(testingMaterial.config()));
    MaterialRevisions revisions = new MaterialRevisions();
    revisions.addRevision(testingMaterial, testingMaterial.modificationsSince(null, null, subprocessExecutionContext));
    BuildCause buildCause = BuildCause.createManualForced(revisions, Username.ANONYMOUS);
    dbHelper.saveMaterials(buildCause.getMaterialRevisions());
    Pipeline forcedPipeline = instanceFactory.createPipelineInstance(mingleConfig, buildCause, new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
    pipelineService.save(forcedPipeline);
    verifyMingleScheduledWithModifications();
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) TimeProvider(com.thoughtworks.go.util.TimeProvider) TestingMaterial(com.thoughtworks.go.domain.materials.TestingMaterial) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 70 with MaterialConfigs

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

the class PipelineScheduleServiceTest method shouldScheduleMultipleJobsWhenToBeRunMultipleInstance.

@Test
public void shouldScheduleMultipleJobsWhenToBeRunMultipleInstance() throws Exception {
    configHelper.setRunMultipleInstance(CaseInsensitiveString.str(evolveConfig.name()), STAGE_NAME, "unit", 2);
    Material stubMaterial = new TestingMaterial();
    evolveConfig.setMaterialConfigs(new MaterialConfigs(stubMaterial.config()));
    MaterialRevisions revisions = new MaterialRevisions();
    revisions.addRevision(stubMaterial, ((TestingMaterial) stubMaterial).modificationsSince(null, null, subprocessExecutionContext));
    BuildCause buildCause = BuildCause.createWithModifications(revisions, "");
    dbHelper.saveMaterials(buildCause.getMaterialRevisions());
    Pipeline pipeline = instanceFactory.createPipelineInstance(evolveConfig, buildCause, new DefaultSchedulingContext(DEFAULT_APPROVED_BY, environmentConfigService.agentsForPipeline(evolveConfig.name())), md5, new TimeProvider());
    pipelineService.save(pipeline);
    Stage instance = scheduleService.scheduleStage(pipeline, STAGE_NAME, "anyone", new ScheduleService.NewStageInstanceCreator(goConfigService), new ScheduleService.ExceptioningErrorHandler());
    JobInstances scheduledJobs = instance.getJobInstances();
    assertThat(scheduledJobs.size(), is(2));
    assertThat(scheduledJobs.toArray(), hasItemInArray(hasProperty("name", is(RunMultipleInstance.CounterBasedJobNameGenerator.appendMarker("unit", 1)))));
    assertThat(scheduledJobs.toArray(), hasItemInArray(hasProperty("name", is(RunMultipleInstance.CounterBasedJobNameGenerator.appendMarker("unit", 2)))));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) TimeProvider(com.thoughtworks.go.util.TimeProvider) Material(com.thoughtworks.go.domain.materials.Material) TestingMaterial(com.thoughtworks.go.domain.materials.TestingMaterial) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) TestingMaterial(com.thoughtworks.go.domain.materials.TestingMaterial) Test(org.junit.Test)

Aggregations

MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)218 Test (org.junit.Test)158 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)35 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)33 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)32 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)32 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)27 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)25 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)25 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)25 TimeProvider (com.thoughtworks.go.util.TimeProvider)25 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)21 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)19 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)19 ValueStreamMapPresentationModel (com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel)16 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)15 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)14 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)14 Material (com.thoughtworks.go.domain.materials.Material)14 Materials (com.thoughtworks.go.config.materials.Materials)12