Search in sources :

Example 1 with PipelineLabel

use of com.thoughtworks.go.domain.label.PipelineLabel in project gocd by gocd.

the class PipelineLabelTest method shouldNotReplaceTemplateWithoutMaterial.

@Test
public void shouldNotReplaceTemplateWithoutMaterial() throws Exception {
    PipelineLabel label = new PipelineLabel("1.5.0");
    label.updateLabel(new HashMap<>());
    assertThat(label, is(new PipelineLabel("1.5.0")));
}
Also used : PipelineLabel(com.thoughtworks.go.domain.label.PipelineLabel) Test(org.junit.Test)

Example 2 with PipelineLabel

use of com.thoughtworks.go.domain.label.PipelineLabel in project gocd by gocd.

the class PipelineLabelTest method shouldReplaceTheTemplateWithMultipleMaterialRevision.

@Test
public void shouldReplaceTheTemplateWithMultipleMaterialRevision() throws Exception {
    PipelineLabel label = PipelineLabel.create("release-${svnMaterial}-${hg}");
    MaterialRevisions materialRevisions = ModificationsMother.oneUserOneFile();
    HgMaterial material = MaterialsMother.hgMaterial();
    material.setName(new CaseInsensitiveString("hg"));
    Modification modification = new Modification();
    modification.setRevision("ae09876hj");
    materialRevisions.addRevision(material, modification);
    label.updateLabel(materialRevisions.getNamedRevisions());
    assertThat(label.toString(), is("release-" + ModificationsMother.currentRevision() + "-ae09876hj"));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) PipelineLabel(com.thoughtworks.go.domain.label.PipelineLabel) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 3 with PipelineLabel

use of com.thoughtworks.go.domain.label.PipelineLabel in project gocd by gocd.

the class PipelineLabelTest method shouldReplaceTheTemplateCaseInsensitively.

@Test
public void shouldReplaceTheTemplateCaseInsensitively() throws Exception {
    PipelineLabel label = PipelineLabel.create("release-${SVNMaterial}");
    MaterialRevisions materialRevisions = ModificationsMother.oneUserOneFile();
    label.updateLabel(materialRevisions.getNamedRevisions());
    assertThat(label.toString(), is("release-" + ModificationsMother.currentRevision()));
}
Also used : PipelineLabel(com.thoughtworks.go.domain.label.PipelineLabel) Test(org.junit.Test)

Example 4 with PipelineLabel

use of com.thoughtworks.go.domain.label.PipelineLabel in project gocd by gocd.

the class PipelineLabelTest method shouldFormatLabelAccordingToCountingTemplate.

@Test
public void shouldFormatLabelAccordingToCountingTemplate() throws Exception {
    PipelineLabel label = PipelineLabel.create(testingTemplate);
    label.updateLabel(getNamedRevision(99));
    assertThat(label.toString(), is("testing.99.label"));
}
Also used : PipelineLabel(com.thoughtworks.go.domain.label.PipelineLabel) Test(org.junit.Test)

Example 5 with PipelineLabel

use of com.thoughtworks.go.domain.label.PipelineLabel in project gocd by gocd.

the class PipelineLabelTest method shouldKeepLabelIfLessThan255.

@Test
public void shouldKeepLabelIfLessThan255() {
    PipelineLabel label = PipelineLabel.create("${upstream}");
    HashMap<CaseInsensitiveString, String> namedRevisions = new HashMap<>();
    namedRevisions.put(new CaseInsensitiveString("upstream"), longLabel(154));
    label.updateLabel(namedRevisions);
    assertThat(label.toString().length(), Is.is(154));
}
Also used : HashMap(java.util.HashMap) PipelineLabel(com.thoughtworks.go.domain.label.PipelineLabel) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Aggregations

PipelineLabel (com.thoughtworks.go.domain.label.PipelineLabel)18 Test (org.junit.Test)14 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)7 Modification (com.thoughtworks.go.domain.materials.Modification)3 ScmMaterial (com.thoughtworks.go.config.materials.ScmMaterial)2 HashMap (java.util.HashMap)2 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)1 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)1