Search in sources :

Example 21 with CaseInsensitiveString

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

the class PipelineServiceTriangleDependencyTest method shouldNotGetTheRevisionsFromUpStreamPipelineIfTheDependencyMaterialHasNotChanged.

@Test
public void shouldNotGetTheRevisionsFromUpStreamPipelineIfTheDependencyMaterialHasNotChanged() throws Exception {
    MaterialRevisions expected = createHgMaterialWithMultipleRevisions(1L, first);
    MaterialRevision up1Revision = dependencyMaterialRevision("up1", 1, "label", "stage", 1, new Date());
    expected.addRevision(up1Revision);
    MaterialRevisions actual = createHgMaterialWithMultipleRevisions(1L, third);
    actual.addRevision(up1Revision);
    up1Revision.markAsNotChanged();
    PipelineConfig current = createPipelineConfigWithMaterialConfig("current", actual.getMaterials().get(0).config(), new DependencyMaterialConfig(new CaseInsensitiveString("up1"), new CaseInsensitiveString("first")));
    PipelineConfig up1 = createPipelineConfigWithMaterialConfig("up1", expected.getMaterials().get(0).config());
    when(pipelineDao.findBuildCauseOfPipelineByNameAndCounter("up1", 1)).thenReturn(BuildCause.createManualForced(expected, new Username(str("loser"))));
    PipelineConfigDependencyGraph dependencyGraph = new PipelineConfigDependencyGraph(current, new PipelineConfigDependencyGraph(up1));
    assertThat(service.getRevisionsBasedOnDependencies(dependencyGraph, actual), is(actual));
}
Also used : PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) Username(com.thoughtworks.go.server.domain.Username) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) ModificationsMother.dependencyMaterialRevision(com.thoughtworks.go.helper.ModificationsMother.dependencyMaterialRevision) ModificationsMother.changedDependencyMaterialRevision(com.thoughtworks.go.helper.ModificationsMother.changedDependencyMaterialRevision) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Date(java.util.Date) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 22 with CaseInsensitiveString

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

the class PipelineServiceTriangleDependencyTest method shouldGetTheRevisionsForDependencyMaterialFromUpStreamPipeline.

@Test
public void shouldGetTheRevisionsForDependencyMaterialFromUpStreamPipeline() throws Exception {
    Date modifiedTime = new Date();
    MaterialRevisions expected = new MaterialRevisions();
    expected.addRevision(dependencyMaterialRevision("up1", 1, "label", "stage", 1, modifiedTime));
    expected.addRevision(dependencyMaterialRevision("common", 3, "label", "first", 1, modifiedTime));
    MaterialRevisions actual = new MaterialRevisions();
    actual.addRevision(changedDependencyMaterialRevision("up1", 1, "label", "stage", 1, modifiedTime));
    actual.addRevision(dependencyMaterialRevision("common", 4, "label", "first", 1, modifiedTime));
    PipelineConfig current = createPipelineConfigWithMaterialConfig("current", new DependencyMaterialConfig(new CaseInsensitiveString("common"), new CaseInsensitiveString("first")), new DependencyMaterialConfig(new CaseInsensitiveString("up1"), new CaseInsensitiveString("first")));
    PipelineConfig up1 = createPipelineConfigWithMaterialConfig("up1", new DependencyMaterialConfig(new CaseInsensitiveString("common"), new CaseInsensitiveString("first")));
    PipelineConfig common = createPipelineConfigWithMaterialConfig("common", MaterialConfigsMother.hgMaterialConfig());
    Pipeline pipeline = PipelineMother.passedPipelineInstance("up1", "stage", "job");
    pipeline.setId(10);
    when(pipelineDao.findPipelineByNameAndCounter("up1", 1)).thenReturn(pipeline);
    MaterialRevisions upStreamPipelinesRevisions = new MaterialRevisions();
    upStreamPipelinesRevisions.addRevision(dependencyMaterialRevision("common", 3, "label", "first", 1, modifiedTime));
    when(materialRepository.findMaterialRevisionsForPipeline(10)).thenReturn(upStreamPipelinesRevisions);
    PipelineConfigDependencyGraph dependencyGraph = new PipelineConfigDependencyGraph(current, new PipelineConfigDependencyGraph(up1, new PipelineConfigDependencyGraph(common)));
    MaterialRevisions finalRevisions = service.getRevisionsBasedOnDependencies(dependencyGraph, actual);
    assertThat(finalRevisions, is(expected));
    for (int i = 0; i < expected.numberOfRevisions(); i++) {
        assertTrue(finalRevisions.getMaterialRevision(i) == actual.getMaterialRevision(i));
    }
}
Also used : PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Date(java.util.Date) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 23 with CaseInsensitiveString

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

the class PipelineServiceTriangleDependencyTest method shouldGetTheRevisionsFromTheUpStreamPipelineFor2SameMaterial.

@Test
public void shouldGetTheRevisionsFromTheUpStreamPipelineFor2SameMaterial() throws Exception {
    MaterialRevision up1Revision = dependencyMaterialRevision("up1", 1, "label", "stage", 1, new Date());
    up1Revision.markAsChanged();
    MaterialRevisions expected = new MaterialRevisions();
    expected.addRevision(up1Revision);
    expected.addAll(createHgMaterialWithMultipleRevisions(1L, first));
    expected.addAll(createSvnMaterialWithMultipleRevisions(2L, first));
    MaterialRevisions actual = new MaterialRevisions();
    actual.addRevision(up1Revision);
    actual.addAll(createHgMaterialWithMultipleRevisions(1L, third));
    actual.addAll(createSvnMaterialWithMultipleRevisions(2L, third));
    PipelineConfig current = createPipelineConfigWithMaterialConfig("current", new DependencyMaterialConfig(new CaseInsensitiveString("up1"), new CaseInsensitiveString("first")), MaterialConfigsMother.hgMaterialConfig(), MaterialConfigsMother.svnMaterialConfig());
    PipelineConfig up1 = createPipelineConfigWithMaterialConfig("up1", MaterialConfigsMother.hgMaterialConfig(), MaterialConfigsMother.svnMaterialConfig());
    Pipeline pipeline = PipelineMother.passedPipelineInstance("up1", "stage", "job");
    pipeline.setId(10);
    when(pipelineDao.findPipelineByNameAndCounter("up1", 1)).thenReturn(pipeline);
    when(materialRepository.findMaterialRevisionsForPipeline(10)).thenReturn(expected);
    PipelineConfigDependencyGraph dependencyGraph = new PipelineConfigDependencyGraph(current, new PipelineConfigDependencyGraph(up1));
    assertThat(service.getRevisionsBasedOnDependencies(dependencyGraph, actual), is(expected));
}
Also used : PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) ModificationsMother.dependencyMaterialRevision(com.thoughtworks.go.helper.ModificationsMother.dependencyMaterialRevision) ModificationsMother.changedDependencyMaterialRevision(com.thoughtworks.go.helper.ModificationsMother.changedDependencyMaterialRevision) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Date(java.util.Date) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 24 with CaseInsensitiveString

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

the class PipelineStagesFeedServiceIntegrationTest method shouldReturnTheCorrectLocalizedMessage.

@Test
public void shouldReturnTheCorrectLocalizedMessage() {
    FeedResolver feedResolver = new PipelineStagesFeedService(stageService, securityService).feedResolverFor("cruise");
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    feedResolver.feed(new Username(new CaseInsensitiveString("evil_hacker")), result);
    assertThat(result.message(localizer), is("User 'evil_hacker' does not have view permission on pipeline 'cruise'"));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 25 with CaseInsensitiveString

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

the class PipelinePauseServiceIntegrationTest method shouldTruncatePauseMessageIfGreaterThanAllowedLength.

@Test
public void shouldTruncatePauseMessageIfGreaterThanAllowedLength() throws Exception {
    String name = "pipeline-name";
    CruiseConfig cruiseConfig = GoConfigMother.configWithPipelines(name);
    configHelper.writeConfigFile(cruiseConfig);
    cachedGoConfig.forceReload();
    Username userName = new Username(new CaseInsensitiveString("UserFoo"));
    pipelinePauseService.pause(name, "tiny pause cause", userName);
    assertThat(pipelinePauseService.pipelinePauseInfo(name).getPauseCause(), is("tiny pause cause"));
    String stringWith255Chars = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
    pipelinePauseService.pause(name, stringWith255Chars + "aa", userName);
    assertThat(pipelinePauseService.pipelinePauseInfo(name).getPauseCause(), is(stringWith255Chars));
}
Also used : Username(com.thoughtworks.go.server.domain.Username) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Aggregations

CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)373 Test (org.junit.Test)276 Username (com.thoughtworks.go.server.domain.Username)84 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)69 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)65 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)58 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)56 Date (java.util.Date)55 Modification (com.thoughtworks.go.domain.materials.Modification)46 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)30 HashMap (java.util.HashMap)30 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)29 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)27 Before (org.junit.Before)25 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)24 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)24 Pipeline (com.thoughtworks.go.domain.Pipeline)23 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)21 ArrayList (java.util.ArrayList)21 Stage (com.thoughtworks.go.domain.Stage)20