Search in sources :

Example 86 with Material

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

the class PipelineScheduleServiceTest method shouldScheduleStageAfterModifications.

@Test
public void shouldScheduleStageAfterModifications() throws Exception {
    scheduleAndCompleteInitialPipelines();
    Material stubMaterial = new TestingMaterial();
    mingleConfig.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(mingleConfig, buildCause, new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
    pipelineService.save(pipeline);
    verifyMingleScheduledWithModifications();
}
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) TestingMaterial(com.thoughtworks.go.domain.materials.TestingMaterial) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 87 with Material

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

the class PipelineServiceIntegrationTest method shouldReturnModificationsInCorrectOrder.

@Test
public void shouldReturnModificationsInCorrectOrder() throws Exception {
    File file1 = new File("file1");
    File file2 = new File("file2");
    File file3 = new File("file3");
    File file4 = new File("file4");
    Material hg1 = new HgMaterial("url1", "Dest1");
    String[] hgRevs = new String[] { "hg1_2" };
    Date latestModification = new Date();
    Date older = DateUtils.addDays(latestModification, -1);
    u.checkinFiles(hg1, "hg1_1", a(file1, file2, file3, file4), ModifiedAction.added, older);
    u.checkinFiles(hg1, "hg1_2", a(file1, file2, file3, file4), ModifiedAction.modified, latestModification);
    ScheduleTestUtil.AddedPipeline pair01 = u.saveConfigWith("pair01", "stageName", u.m(hg1));
    u.runAndPass(pair01, hgRevs);
    ReflectionUtil.invoke(pipelineSqlMapDao, "initDao");
    Pipeline pipeline = pipelineService.mostRecentFullPipelineByName("pair01");
    MaterialRevisions materialRevisions = pipeline.getBuildCause().getMaterialRevisions();
    assertThat(materialRevisions.getMaterials().size(), is(1));
    assertThat(materialRevisions.getDateOfLatestModification().getTime(), is(latestModification.getTime()));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Material(com.thoughtworks.go.domain.materials.Material) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) File(java.io.File) Date(java.util.Date) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 88 with Material

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

the class PipelineServiceIntegrationTest method shouldReturnPMRsInCorrectOrder.

@Test
public void shouldReturnPMRsInCorrectOrder() throws Exception {
    File file1 = new File("file1");
    File file2 = new File("file2");
    File file3 = new File("file3");
    File file4 = new File("file4");
    Material hg1 = new HgMaterial("url1", "Dest1");
    Material hg2 = new HgMaterial("url2", "Dest2");
    String[] hgRevs = new String[] { "h1", "h2" };
    Date latestModification = new Date();
    u.checkinFiles(hg2, "h2", a(file1, file2, file3, file4), ModifiedAction.added, org.apache.commons.lang.time.DateUtils.addDays(latestModification, -1));
    u.checkinFiles(hg1, "h1", a(file1, file2, file3, file4), ModifiedAction.added, latestModification);
    ScheduleTestUtil.AddedPipeline pair01 = u.saveConfigWith("pair01", "stageName", u.m(hg1), u.m(hg2));
    u.runAndPass(pair01, hgRevs);
    ReflectionUtil.invoke(pipelineSqlMapDao, "initDao");
    Pipeline pipeline = pipelineService.mostRecentFullPipelineByName("pair01");
    MaterialRevisions materialRevisions = pipeline.getBuildCause().getMaterialRevisions();
    Materials materials = materialRevisions.getMaterials();
    assertThat(materials.size(), is(2));
    assertThat(materials.get(0), is(hg1));
    assertThat(materials.get(1), is(hg2));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Materials(com.thoughtworks.go.config.materials.Materials) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Material(com.thoughtworks.go.domain.materials.Material) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) File(java.io.File) Date(java.util.Date) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 89 with Material

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

the class PipelineServiceTriangleDependencyTest method shouldCopyMissingRevisionsForSameMaterialThatsUsedMoreThanOnce.

@Test
public void shouldCopyMissingRevisionsForSameMaterialThatsUsedMoreThanOnce() throws Exception {
    PipelineConfig pipelineConfig = PipelineConfigMother.pipelineConfig("last");
    pipelineConfig.materialConfigs().clear();
    HgMaterialConfig onDirOne = MaterialConfigsMother.hgMaterialConfig("google.com", "dirOne");
    HgMaterialConfig onDirTwo = MaterialConfigsMother.hgMaterialConfig("google.com", "dirTwo");
    pipelineConfig.addMaterialConfig(onDirOne);
    pipelineConfig.addMaterialConfig(onDirTwo);
    HashMap<Material, String> materialToCommit = new HashMap<>();
    materialToCommit.put(new MaterialConfigConverter().toMaterial(onDirOne), "abc");
    materialToCommit.put(new MaterialConfigConverter().toMaterial(onDirTwo), "abc");
    MaterialRevisions revs = ModificationsMother.getMaterialRevisions(materialToCommit);
    MaterialRevisions finalRevisions = service.getRevisionsBasedOnDependencies(new PipelineConfigDependencyGraph(pipelineConfig), revs);
    assertThat(finalRevisions.getRevisions(), is(revs.getRevisions()));
}
Also used : PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) HashMap(java.util.HashMap) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Material(com.thoughtworks.go.domain.materials.Material) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 90 with Material

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

the class BuildAssignmentServiceIntegrationTest method shouldCancelAScheduledJobInCaseThePipelineIsRemovedFromTheConfig_SpecificallyAPipelineRenameToADifferentCaseAndStageNameToADifferentName.

@Test
public void shouldCancelAScheduledJobInCaseThePipelineIsRemovedFromTheConfig_SpecificallyAPipelineRenameToADifferentCaseAndStageNameToADifferentName() throws Exception {
    Material hgMaterial = new HgMaterial("url", "folder");
    String[] hgRevs = new String[] { "h1" };
    u.checkinInOrder(hgMaterial, hgRevs);
    ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("PIPELINE_WHICH_WILL_EVENTUALLY_CHANGE_CASE", u.m(hgMaterial));
    u.scheduleWith(p1, hgRevs);
    ScheduleTestUtil.AddedPipeline renamedPipeline = u.renamePipelineAndFirstStage(p1, "pipeline_which_will_eventually_change_case", "NEW_RANDOM_STAGE_NAME" + UUID.randomUUID());
    Pipeline p1_2 = u.scheduleWith(renamedPipeline, hgRevs);
    CruiseConfig cruiseConfig = configHelper.load();
    // To Reload Job Plans
    buildAssignmentService.onTimer();
    buildAssignmentService.onConfigChange(cruiseConfig);
    Stages allStages = stageDao.findAllStagesFor(p1_2.getName(), p1_2.getCounter());
    assertThat(allStages.byName(CaseInsensitiveString.str(p1.config.first().name())).getState(), is(StageState.Cancelled));
}
Also used : PipelineWithTwoStages(com.thoughtworks.go.fixture.PipelineWithTwoStages) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Material(com.thoughtworks.go.domain.materials.Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial)

Aggregations

Material (com.thoughtworks.go.domain.materials.Material)95 Test (org.junit.Test)59 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)39 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)39 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)23 Modification (com.thoughtworks.go.domain.materials.Modification)20 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)18 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)16 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)14 ScmMaterial (com.thoughtworks.go.config.materials.ScmMaterial)14 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)14 Materials (com.thoughtworks.go.config.materials.Materials)11 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)10 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)9 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)9 PluggableSCMMaterial (com.thoughtworks.go.config.materials.PluggableSCMMaterial)8 Date (java.util.Date)8 HashSet (java.util.HashSet)8 P4Material (com.thoughtworks.go.config.materials.perforce.P4Material)7 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)7