Search in sources :

Example 76 with HgMaterial

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

the class ServerHealthServiceTest method stateRelatedPipelineNames.

@Test
public void stateRelatedPipelineNames() {
    HgMaterial hgMaterial = MaterialsMother.hgMaterial();
    CruiseConfig config = new BasicCruiseConfig();
    config.addPipeline("group", PipelineConfigMother.pipelineConfig(PIPELINE_NAME, new MaterialConfigs(hgMaterial.config())));
    config.addPipeline("group", PipelineConfigMother.pipelineConfig("pipeline2", new MaterialConfigs(hgMaterial.config())));
    config.addPipeline("group", PipelineConfigMother.pipelineConfig("pipeline3"));
    serverHealthService = new ServerHealthService();
    serverHealthService.update(ServerHealthState.error("message", "description", HealthStateType.general(forPipeline(PIPELINE_NAME))));
    assertThat((serverHealthService.logs().get(0)).getPipelineNames(config), equalTo(Collections.singleton(PIPELINE_NAME)));
    serverHealthService = new ServerHealthService();
    serverHealthService.update(ServerHealthState.error("message", "description", HealthStateType.general(forStage(PIPELINE_NAME, "stage1"))));
    assertThat((serverHealthService.logs().get(0)).getPipelineNames(config), equalTo(Collections.singleton(PIPELINE_NAME)));
    serverHealthService = new ServerHealthService();
    serverHealthService.update(ServerHealthState.error("message", "description", HealthStateType.general(forJob(PIPELINE_NAME, "stage1", "job1"))));
    assertThat((serverHealthService.logs().get(0)).getPipelineNames(config), equalTo(Collections.singleton(PIPELINE_NAME)));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Test(org.junit.Test)

Example 77 with HgMaterial

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

the class ServerHealthServiceTest method noPipelineMatchMaterialStateRelatedPipelineNames.

@Test
public void noPipelineMatchMaterialStateRelatedPipelineNames() {
    HgMaterial hgMaterial = MaterialsMother.hgMaterial();
    CruiseConfig config = new BasicCruiseConfig();
    config.addPipeline("group", PipelineConfigMother.pipelineConfig(PIPELINE_NAME, new MaterialConfigs(hgMaterial.config())));
    config.addPipeline("group", PipelineConfigMother.pipelineConfig("pipeline2", new MaterialConfigs(hgMaterial.config())));
    config.addPipeline("group", PipelineConfigMother.pipelineConfig("pipeline3"));
    serverHealthService.update(ServerHealthState.error("message", "description", HealthStateType.general(forMaterial(MaterialsMother.p4Material()))));
    assertTrue((serverHealthService.logs().get(0)).getPipelineNames(config).isEmpty());
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Test(org.junit.Test)

Example 78 with HgMaterial

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

the class ServerHealthServiceTest method materialUpdateStateRelatedPipelineNames.

@Test
public void materialUpdateStateRelatedPipelineNames() {
    HgMaterial hgMaterial = MaterialsMother.hgMaterial();
    CruiseConfig config = new BasicCruiseConfig();
    config.addPipeline("group", PipelineConfigMother.pipelineConfig(PIPELINE_NAME, new MaterialConfigs(hgMaterial.config())));
    config.addPipeline("group", PipelineConfigMother.pipelineConfig("pipeline2", new MaterialConfigs(hgMaterial.config())));
    config.addPipeline("group", PipelineConfigMother.pipelineConfig("pipeline3"));
    serverHealthService.update(ServerHealthState.error("message", "description", HealthStateType.general(forMaterialUpdate(hgMaterial))));
    Set<String> pipelines = (serverHealthService.logs().get(0)).getPipelineNames(config);
    assertEquals(Sets.newHashSet("pipeline", "pipeline2"), pipelines);
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Test(org.junit.Test)

Example 79 with HgMaterial

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

the class PipelineInstanceModelTest method shouldThrowExceptionWhenCurrentRevisionForUnknownMaterialNameRequested.

@Test
public void shouldThrowExceptionWhenCurrentRevisionForUnknownMaterialNameRequested() {
    HgMaterial material = MaterialsMother.hgMaterial();
    material.setName(new CaseInsensitiveString("foo"));
    try {
        assertThat(setUpModificationFor(material).getCurrentRevision("blah").getRevision(), is("a087402bd2a7828a130c1bdf43f2d9ef8f48fd46"));
        fail("should have raised an exeption for unknown material name");
    } catch (Exception ignored) {
    }
}
Also used : HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 80 with HgMaterial

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

the class PipelineInstanceModelTest method shouldReturnIfAnyMaterialHasModifications.

@Test
public void shouldReturnIfAnyMaterialHasModifications() {
    final SvnMaterial svnMaterial = svnMaterial("http://svnurl");
    final HgMaterial hgMaterial = hgMaterial("http://hgurl", "hgdir");
    MaterialRevisions currentRevisions = ModificationsMother.getMaterialRevisions(new HashMap<Material, String>() {

        {
            put(svnMaterial, "1");
            put(hgMaterial, "a");
        }
    });
    MaterialRevisions latestRevisions = ModificationsMother.getMaterialRevisions(new HashMap<Material, String>() {

        {
            put(svnMaterial, "1");
            put(hgMaterial, "b");
        }
    });
    MaterialConfigs materialConfigs = new MaterialConfigs();
    materialConfigs.add(svnMaterial.config());
    materialConfigs.add(hgMaterial.config());
    StageInstanceModels stages = new StageInstanceModels();
    stages.addStage("unit1", JobHistory.withJob("test", JobState.Completed, JobResult.Passed, new Date()));
    stages.addFutureStage("unit2", false);
    PipelineInstanceModel model = PipelineInstanceModel.createPipeline("pipeline", -1, "label", BuildCause.createWithModifications(currentRevisions, ""), stages);
    model.setLatestRevisions(latestRevisions);
    model.setMaterialConfigs(materialConfigs);
    assertThat("svnMaterial hasNewRevisions", model.hasNewRevisions(svnMaterial.config()), is(false));
    assertThat("hgMaterial hasNewRevisions", model.hasNewRevisions(hgMaterial.config()), is(true));
    assertThat("all materials hasNewRevisions", model.hasNewRevisions(), is(true));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Material(com.thoughtworks.go.domain.materials.Material) MaterialsMother.hgMaterial(com.thoughtworks.go.helper.MaterialsMother.hgMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) MaterialsMother.svnMaterial(com.thoughtworks.go.helper.MaterialsMother.svnMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Date(java.util.Date) Test(org.junit.Test)

Aggregations

HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)121 Test (org.junit.Test)107 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)34 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)29 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)23 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)23 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)20 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)18 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)16 Material (com.thoughtworks.go.domain.materials.Material)15 P4Material (com.thoughtworks.go.config.materials.perforce.P4Material)10 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)10 Date (java.util.Date)10 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)9 ScheduleTestUtil (com.thoughtworks.go.server.service.ScheduleTestUtil)9 TimeProvider (com.thoughtworks.go.util.TimeProvider)8 Pagination (com.thoughtworks.go.server.util.Pagination)7 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)6 Modification (com.thoughtworks.go.domain.materials.Modification)6 File (java.io.File)6