Search in sources :

Example 81 with Material

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

the class ModificationsMother method createPipelineMaterialRevision.

public static MaterialRevision createPipelineMaterialRevision(String stageIdentifier) {
    Material material = MaterialsMother.dependencyMaterial();
    List<Modification> modifications = new ArrayList<>();
    modifications.add(new Modification(new Date(), stageIdentifier, "123", 1L));
    return new MaterialRevision(material, modifications);
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) Material(com.thoughtworks.go.domain.materials.Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision)

Example 82 with Material

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

the class PipelineHistoryServiceIntegrationTest method shouldUnderstandIfMaterialHasNoNewModifications.

@Test
public void shouldUnderstandIfMaterialHasNoNewModifications() throws Exception {
    Pipeline pipeline = pipelineOne.createPipelineWithFirstStageScheduled();
    Material material = pipeline.getMaterialRevisions().getMaterialRevision(0).getMaterial();
    configHelper.setViewPermissionForGroup("group1", "username");
    PipelineInstanceModels latest = pipelineHistoryService.loadWithEmptyAsDefault(pipelineOne.pipelineName, Pagination.ONE_ITEM, "username");
    PipelineInstanceModel model = latest.get(0);
    assertThat(model.hasNewRevisions(material.config()), is(false));
}
Also used : Material(com.thoughtworks.go.domain.materials.Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) Test(org.junit.Test)

Example 83 with Material

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

the class PipelineHistoryServiceIntegrationTest method shouldUnderstandIfMaterialHasNewModifications.

@Test
public void shouldUnderstandIfMaterialHasNewModifications() throws Exception {
    Pipeline pipeline = pipelineOne.createPipelineWithFirstStageScheduled();
    Material material = pipeline.getMaterialRevisions().getMaterialRevision(0).getMaterial();
    saveRev(new MaterialRevision(material, new Modification(new Date(), "2", "MOCK_LABEL-12", null)));
    configHelper.setViewPermissionForGroup("group1", "username");
    PipelineInstanceModels latest = pipelineHistoryService.loadWithEmptyAsDefault(pipelineOne.pipelineName, Pagination.ONE_ITEM, "username");
    PipelineInstanceModel model = latest.get(0);
    assertThat(model.hasNewRevisions(material.config()), is(true));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) Material(com.thoughtworks.go.domain.materials.Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) Date(java.util.Date) Test(org.junit.Test)

Example 84 with Material

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

the class PipelineScheduleServiceTest method shouldScheduleJobForAllAgentsWhenToBeRunOnAllAgents.

@Test
public void shouldScheduleJobForAllAgentsWhenToBeRunOnAllAgents() throws Exception {
    configHelper.addAgent("localhost", "uuid1");
    configHelper.addAgent("localhost", "uuid2");
    configHelper.addAgent("localhost", "uuid3");
    configHelper.addAgentToEnvironment("dev", "uuid1");
    configHelper.setRunOnAllAgents(CaseInsensitiveString.str(evolveConfig.name()), STAGE_NAME, "unit", true);
    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.toArray(), hasItemInArray(hasProperty("name", is(RunOnAllAgents.CounterBasedJobNameGenerator.appendMarker("unit", 1)))));
    assertThat(scheduledJobs.toArray(), hasItemInArray(hasProperty("agentUuid", is("uuid2"))));
    assertThat(scheduledJobs.toArray(), hasItemInArray(hasProperty("name", is(RunOnAllAgents.CounterBasedJobNameGenerator.appendMarker("unit", 2)))));
    assertThat(scheduledJobs.toArray(), hasItemInArray(hasProperty("agentUuid", is("uuid3"))));
    assertThat(scheduledJobs.size(), is(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)

Example 85 with Material

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

the class PipelineScheduleServiceTest method shouldLockPipelineWhenSchedulingIt.

@Test
public void shouldLockPipelineWhenSchedulingIt() throws Exception {
    scheduleAndCompleteInitialPipelines();
    configHelper.lockPipeline("mingle");
    Material stubMaterial = new TestingMaterial();
    mingleConfig.setMaterialConfigs(new MaterialConfigs(stubMaterial.config()));
    assertThat(pipelineLockService.isLocked("mingle"), is(false));
    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);
    assertThat(pipelineLockService.isLocked("mingle"), is(true));
}
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)

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