Search in sources :

Example 56 with CaseInsensitiveString

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

the class UsernameTest method shouldAllowBuildingUsernameFromString.

@Test
public void shouldAllowBuildingUsernameFromString() {
    Username one = new Username(new CaseInsensitiveString("myusername"));
    Username two = Username.valueOf("myusername");
    assertThat(one, is(two));
}
Also used : CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 57 with CaseInsensitiveString

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

the class MaterialCheckerTest method updateChangedRevisionsShouldRetainLatestRevisionIfAllHaveBuiltBefore.

@Test
public void updateChangedRevisionsShouldRetainLatestRevisionIfAllHaveBuiltBefore() {
    CaseInsensitiveString pipelineName = new CaseInsensitiveString("pipelineName");
    GitMaterial gitMaterial = new GitMaterial("git://foo");
    BuildCause buildCause = BuildCause.createWithModifications(new MaterialRevisions(new MaterialRevision(gitMaterial, mod(10L), mod(9L), mod(8L))), "user");
    when(materialRepository.latestModificationRunByPipeline(pipelineName, gitMaterial)).thenReturn(10L);
    materialChecker.updateChangedRevisions(pipelineName, buildCause);
    MaterialRevisions actualRevisions = buildCause.getMaterialRevisions();
    assertThat(actualRevisions.getModifications(gitMaterial), is(new Modifications(mod(10L), mod(9L), mod(8L))));
    assertThat(actualRevisions.findRevisionFor(gitMaterial).isChanged(), is(false));
}
Also used : Modifications(com.thoughtworks.go.domain.materials.Modifications) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 58 with CaseInsensitiveString

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

the class MaterialCheckerTest method shouldUseLatestPipelineInstanceForDependentPipeline.

@Test
public void shouldUseLatestPipelineInstanceForDependentPipeline() throws Exception {
    DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
    Stage passedStage = StageMother.passedStageInstance("stage-name", "job-name", "pipeline-name");
    Modification modification = new Modification("Unknown", "Unknown", null, passedStage.completedDate(), "pipeline-name/1[LABEL-1]/stage-name/0");
    Mockito.when(materialRepository.findLatestModification(dependencyMaterial)).thenReturn(revisions(dependencyMaterial, modification));
    materialChecker.findLatestRevisions(new MaterialRevisions(), new Materials(dependencyMaterial));
    Mockito.verify(materialRepository).findLatestModification(dependencyMaterial);
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Materials(com.thoughtworks.go.config.materials.Materials) Stage(com.thoughtworks.go.domain.Stage) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 59 with CaseInsensitiveString

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

the class MaterialCheckerTest method shouldUseLatestPipelineInstanceForDependentPipelineGivenThePreviousRevision.

@Test
public void shouldUseLatestPipelineInstanceForDependentPipelineGivenThePreviousRevision() throws Exception {
    DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
    Stage passedStage = StageMother.passedStageInstance("stage-name", "job-name", "pipeline-name");
    MaterialRevisions materialRevisions = new MaterialRevisions();
    Modification previous = new Modification("Unknown", "Unknown", null, passedStage.completedDate(), "pipeline-name/1/stage-name/0");
    MaterialRevision previousRevision = revisions(dependencyMaterial, previous).getMaterialRevision(0);
    when(materialRepository.findModificationsSince(dependencyMaterial, previousRevision)).thenReturn(Arrays.asList(new Modification(new Date(), "pipeline-name/2/stage-name/0", "MOCK_LABEL-12", null)));
    MaterialRevisions revisionsSince = materialChecker.findRevisionsSince(materialRevisions, new Materials(dependencyMaterial), new MaterialRevisions(previousRevision), new MaterialRevisions());
    assertThat(revisionsSince.getMaterialRevision(0).getRevision().getRevision(), is("pipeline-name/2/stage-name/0"));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Materials(com.thoughtworks.go.config.materials.Materials) Stage(com.thoughtworks.go.domain.Stage) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Date(java.util.Date) Test(org.junit.Test)

Example 60 with CaseInsensitiveString

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

the class MaterialCheckerTest method updateChangedRevisionsShouldFilterRevisionsThatHaveBuiltBefore.

@Test
public void updateChangedRevisionsShouldFilterRevisionsThatHaveBuiltBefore() {
    CaseInsensitiveString pipelineName = new CaseInsensitiveString("pipelineName");
    GitMaterial gitMaterial = new GitMaterial("git://foo");
    BuildCause buildCause = BuildCause.createWithModifications(new MaterialRevisions(new MaterialRevision(gitMaterial, mod(10L), mod(9L), mod(8L))), "user");
    when(materialRepository.latestModificationRunByPipeline(pipelineName, gitMaterial)).thenReturn(9L);
    materialChecker.updateChangedRevisions(pipelineName, buildCause);
    MaterialRevisions actualRevisions = buildCause.getMaterialRevisions();
    assertThat(actualRevisions.getModifications(gitMaterial), is(new Modifications(mod(10L))));
    assertThat(actualRevisions.findRevisionFor(gitMaterial).isChanged(), is(true));
}
Also used : Modifications(com.thoughtworks.go.domain.materials.Modifications) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

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