Search in sources :

Example 6 with Resources

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

the class ResourcesTest method shouldValidateTree.

@Test
public void shouldValidateTree() {
    Resource resource1 = new Resource("a#");
    Resource resource2 = new Resource("b");
    Resources resources = new Resources(resource1, resource2);
    resources.validateTree(PipelineConfigSaveValidationContext.forChain(true, "group", new PipelineConfig()));
    assertThat(resource1.errors().size(), is(1));
    assertThat(resource1.errors().firstError(), is(String.format("Resource name 'a#' is not valid. Valid names much match '%s'", Resource.VALID_REGEX)));
    assertThat(resource2.errors().isEmpty(), is(true));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) Resource(com.thoughtworks.go.config.Resource) Resources(com.thoughtworks.go.config.Resources) Test(org.junit.Test)

Example 7 with Resources

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

the class ResourcesTest method shouldNotAddDuplicateResources.

@Test
public void shouldNotAddDuplicateResources() {
    Resources expected = new Resources();
    expected.add(new Resource("jdk1.4"));
    expected.add(new Resource("jdk1.5"));
    Resources actual = new Resources();
    actual.add(new Resource("jdk1.4"));
    actual.add(new Resource("jdk1.5"));
    actual.add(new Resource("Jdk1.5"));
    assertThat(expected, is(actual));
}
Also used : Resource(com.thoughtworks.go.config.Resource) Resources(com.thoughtworks.go.config.Resources) Test(org.junit.Test)

Example 8 with Resources

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

the class ResourcesTest method shouldReturnListOfResoucesAsCommaSeperatedList.

@Test
public void shouldReturnListOfResoucesAsCommaSeperatedList() {
    Resources actual = new Resources();
    actual.add(new Resource("  a  "));
    actual.add(new Resource("   b"));
    actual.add(new Resource("c"));
    assertThat(actual.exportToCsv(), is("a, b, c, "));
}
Also used : Resource(com.thoughtworks.go.config.Resource) Resources(com.thoughtworks.go.config.Resources) Test(org.junit.Test)

Example 9 with Resources

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

the class ResourcesTest method shouldNotBeAbleToAddResourceWithWhiteSpaceAsName.

@Test
public void shouldNotBeAbleToAddResourceWithWhiteSpaceAsName() {
    Resources actual = new Resources();
    actual.add(new Resource(" "));
    assertThat(actual.size(), is(0));
}
Also used : Resource(com.thoughtworks.go.config.Resource) Resources(com.thoughtworks.go.config.Resources) Test(org.junit.Test)

Example 10 with Resources

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

the class ResourcesTest method shouldHaveNiceConvenienceConstructorThatDoesSomeNiftyParsing.

@Test
public void shouldHaveNiceConvenienceConstructorThatDoesSomeNiftyParsing() {
    Resources actual = new Resources("mou, fou");
    assertThat(actual.toString(), is("fou | mou"));
}
Also used : Resources(com.thoughtworks.go.config.Resources) Test(org.junit.Test)

Aggregations

Resources (com.thoughtworks.go.config.Resources)16 Test (org.junit.Test)16 Resource (com.thoughtworks.go.config.Resource)13 Agents (com.thoughtworks.go.config.Agents)2 AgentConfig (com.thoughtworks.go.config.AgentConfig)1 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 ArrayList (java.util.ArrayList)1