Search in sources :

Example 36 with CaseInsensitiveString

use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.

the class GoDashboardTemplateConfigChangeHandlerTest method shouldRefreshAllPipelinesAssociatedWithATemplateInCacheWhenATemplateChanges.

@Test
public void shouldRefreshAllPipelinesAssociatedWithATemplateInCacheWhenATemplateChanges() throws Exception {
    CruiseConfig cruiseConfig = mock(CruiseConfig.class);
    PipelineTemplateConfig templateConfig = new PipelineTemplateConfig(new CaseInsensitiveString("template1"));
    CaseInsensitiveString pipeline1 = new CaseInsensitiveString("p1");
    CaseInsensitiveString pipeline2 = new CaseInsensitiveString("p2");
    when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
    when(cruiseConfig.pipelinesAssociatedWithTemplate(templateConfig.name())).thenReturn(a(pipeline1, pipeline2));
    handler.call(templateConfig);
    verify(cacheUpdateService).updateCacheForPipeline(pipeline1);
    verify(cacheUpdateService).updateCacheForPipeline(pipeline2);
}
Also used : PipelineTemplateConfig(com.thoughtworks.go.config.PipelineTemplateConfig) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 37 with CaseInsensitiveString

use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.

the class PipelineConfigDependencyGraphTest method shouldReturnTheSetOfFingerprintsOfAllMaterials.

@Test
public void shouldReturnTheSetOfFingerprintsOfAllMaterials() throws Exception {
    HgMaterialConfig common = MaterialConfigsMother.hgMaterialConfig();
    SvnMaterialConfig firstOrderSVNMaterial = MaterialConfigsMother.svnMaterialConfig();
    GitMaterialConfig firstOrderGitMaterial = MaterialConfigsMother.gitMaterialConfig("url", "submodule", "branch", false);
    P4MaterialConfig firstOrderP4Material = MaterialConfigsMother.p4MaterialConfig();
    DependencyMaterialConfig up1DependencyMaterial = new DependencyMaterialConfig(new CaseInsensitiveString("up1"), new CaseInsensitiveString("first"));
    DependencyMaterialConfig up2DependencyMaterial = new DependencyMaterialConfig(new CaseInsensitiveString("up2"), new CaseInsensitiveString("first"));
    DependencyMaterialConfig uppestDependencyMaterial = new DependencyMaterialConfig(new CaseInsensitiveString("uppest"), new CaseInsensitiveString("first"));
    PipelineConfig current = GoConfigMother.createPipelineConfigWithMaterialConfig("current", common, up1DependencyMaterial, up2DependencyMaterial);
    PipelineConfig up1 = GoConfigMother.createPipelineConfigWithMaterialConfig("up1", common, firstOrderGitMaterial, uppestDependencyMaterial);
    PipelineConfig up2 = GoConfigMother.createPipelineConfigWithMaterialConfig("up2", firstOrderSVNMaterial, common, uppestDependencyMaterial);
    PipelineConfig uppest = GoConfigMother.createPipelineConfigWithMaterialConfig("uppest", common, firstOrderP4Material);
    PipelineConfigDependencyGraph uppestGraph = new PipelineConfigDependencyGraph(uppest);
    PipelineConfigDependencyGraph up1Graph = new PipelineConfigDependencyGraph(up1, uppestGraph);
    PipelineConfigDependencyGraph up2Graph = new PipelineConfigDependencyGraph(up2, uppestGraph);
    PipelineConfigDependencyGraph dependencyGraph = new PipelineConfigDependencyGraph(current, up1Graph, up2Graph);
    assertThat(dependencyGraph.allMaterialFingerprints().size(), is(7));
    assertThat(dependencyGraph.allMaterialFingerprints(), hasItems(common.getFingerprint(), firstOrderSVNMaterial.getFingerprint(), firstOrderGitMaterial.getFingerprint(), firstOrderP4Material.getFingerprint(), up1DependencyMaterial.getFingerprint(), up2DependencyMaterial.getFingerprint(), uppestDependencyMaterial.getFingerprint()));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) MaterialConfigsMother.filteredHgMaterialConfig(com.thoughtworks.go.helper.MaterialConfigsMother.filteredHgMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 38 with CaseInsensitiveString

use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.

the class PipelineTimelineTest method assertBeforeAfter.

private void assertBeforeAfter(PipelineTimeline mods, PipelineTimelineEntry actual, PipelineTimelineEntry before, PipelineTimelineEntry after) {
    PipelineTimelineEntry actualBefore = mods.runBefore(actual.getId(), new CaseInsensitiveString(pipelineName));
    PipelineTimelineEntry actualAfter = mods.runAfter(actual.getId(), new CaseInsensitiveString(pipelineName));
    assertEquals("Expected " + before + " to be before " + actual + ". Got " + actualBefore, actualBefore, before);
    assertEquals("Expected " + after + " to be after " + actual + ". Got " + actualAfter, actualAfter, after);
}
Also used : PipelineTimelineEntry(com.thoughtworks.go.domain.PipelineTimelineEntry) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 39 with CaseInsensitiveString

use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.

the class StageNotificationServiceTest method shouldNotHaveFailedTestsSectionWhenThereAreNoFailedTests.

@Test
public void shouldNotHaveFailedTestsSectionWhenThereAreNoFailedTests() {
    String jezMail = prepareOneMatchedUser();
    stubPipelineAndStage(new Date());
    when(systemEnvironment.isShineEnabled()).thenReturn(true);
    when(shineDao.failedTestsFor(stageIdentifier)).thenReturn(new ArrayList<>());
    stageNotificationService.sendNotifications(stageIdentifier, StageEvent.Fails, new Username(new CaseInsensitiveString("loser")));
    String body = inMemoryEmailNotificationTopic.getBody(jezMail);
    assertThat(body, not(containsString(StageNotificationService.FAILED_TEST_SECTION)));
}
Also used : Username(com.thoughtworks.go.server.domain.Username) Matchers.anyString(org.mockito.Matchers.anyString) StringContains.containsString(org.hamcrest.core.StringContains.containsString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Date(java.util.Date) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 40 with CaseInsensitiveString

use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.

the class StageNotificationServiceTest method stubPipelineAndStage.

private void stubPipelineAndStage(Date date) {
    final PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfig("go", "dev", "compile", "test", "twist");
    final Modification svnModification = new Modification("lgao", "Fixing the not checked in files", "jez@cruise.com", date, "123");
    svnModification.createModifiedFile("build.xml", "some_dir", ModifiedAction.added);
    svnModification.createModifiedFile("some.xml", "other_dir", ModifiedAction.deleted);
    Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, new ManualBuild(new Username(new CaseInsensitiveString("loser"))).onModifications(new MaterialRevisions(new MaterialRevision(new MaterialConfigConverter().toMaterials(pipelineConfig.materialConfigs()).get(0), svnModification)), false, null), new DefaultSchedulingContext("loser"), "md5-test", new TimeProvider());
    Stage stage = pipeline.getStages().get(0);
    when(stageService.findStageWithIdentifier(stageIdentifier)).thenReturn(stage);
    stage.setPipelineId(100L);
    when(pipelineService.fullPipelineById(100)).thenReturn(pipeline);
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) TimeProvider(com.thoughtworks.go.util.TimeProvider) Username(com.thoughtworks.go.server.domain.Username) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Aggregations

CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)392 Test (org.junit.Test)277 Username (com.thoughtworks.go.server.domain.Username)80 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)65 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)65 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)57 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)56 Date (java.util.Date)50 Modification (com.thoughtworks.go.domain.materials.Modification)44 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)30 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)28 Before (org.junit.Before)28 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)27 HashMap (java.util.HashMap)26 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)24 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)24 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)19 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)19 ArrayList (java.util.ArrayList)19 Pipeline (com.thoughtworks.go.domain.Pipeline)18