Search in sources :

Example 1 with ResourceConfigs

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

the class AgentViewModelTest method shouldMapErrors.

@Test
public void shouldMapErrors() {
    ResourceConfig resourceConfig1 = new ResourceConfig("foo");
    ResourceConfig resourceConfig2 = new ResourceConfig("bar");
    AgentConfig agentConfig = new AgentConfig("uuid", "host", "IP", new ResourceConfigs(resourceConfig1, resourceConfig2));
    agentConfig.addError(AgentConfig.IP_ADDRESS, "bad ip");
    resourceConfig1.addError(ResourceConfig.NAME, "bad name for resource1");
    resourceConfig2.addError(ResourceConfig.NAME, "bad name for resource2");
    AgentViewModel model = new AgentViewModel(AgentInstance.createFromConfig(agentConfig, mock(SystemEnvironment.class), null));
    assertThat(model.errors().isEmpty(), is(false));
    assertThat(model.errors().on(AgentConfig.IP_ADDRESS), is("bad ip"));
    assertThat(model.errors().getAllOn(ResourceConfig.NAME).contains("bad name for resource1"), is(true));
    assertThat(model.errors().getAllOn(ResourceConfig.NAME).contains("bad name for resource2"), is(true));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) ResourceConfig(com.thoughtworks.go.config.ResourceConfig) ResourceConfigs(com.thoughtworks.go.config.ResourceConfigs) Test(org.junit.Test)

Example 2 with ResourceConfigs

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

the class ResourcesTest method shouldConvertResourceListToResourceConfigs.

@Test
public void shouldConvertResourceListToResourceConfigs() {
    final Resources resources = new Resources(new Resource("foo"), new Resource("bar"));
    final ResourceConfigs resourceConfigs = resources.toResourceConfigs();
    assertThat(resourceConfigs, hasSize(2));
    assertThat(resourceConfigs, contains(new ResourceConfig("foo"), new ResourceConfig("bar")));
}
Also used : ResourceConfig(com.thoughtworks.go.config.ResourceConfig) ResourceConfigs(com.thoughtworks.go.config.ResourceConfigs) Test(org.junit.Test)

Example 3 with ResourceConfigs

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

the class TriStateSelectionTest method shouldHaveActionAddIfAllAgentsHaveThatResource.

@Test
public void shouldHaveActionAddIfAllAgentsHaveThatResource() {
    resourceConfigs.add(new ResourceConfig("all"));
    agents.add(new AgentConfig("uuid1", "host1", "127.0.0.1", new ResourceConfigs("all")));
    agents.add(new AgentConfig("uuid2", "host2", "127.0.0.2", new ResourceConfigs("all")));
    List<TriStateSelection> selections = TriStateSelection.forAgentsResources(resourceConfigs, agents);
    assertThat(selections, hasItem(new TriStateSelection("all", TriStateSelection.Action.add)));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) ResourceConfig(com.thoughtworks.go.config.ResourceConfig) ResourceConfigs(com.thoughtworks.go.config.ResourceConfigs) Test(org.junit.Test)

Example 4 with ResourceConfigs

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

the class TriStateSelectionTest method shouldHaveActionRemoveIfNoAgentsHaveResource.

@Test
public void shouldHaveActionRemoveIfNoAgentsHaveResource() {
    resourceConfigs.add(new ResourceConfig("none"));
    agents.add(new AgentConfig("uuid1", "host1", "127.0.0.1", new ResourceConfigs("one")));
    agents.add(new AgentConfig("uuid2", "host2", "127.0.0.2", new ResourceConfigs("two")));
    List<TriStateSelection> selections = TriStateSelection.forAgentsResources(resourceConfigs, agents);
    assertThat(selections, hasItem(new TriStateSelection("none", TriStateSelection.Action.remove)));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) ResourceConfig(com.thoughtworks.go.config.ResourceConfig) ResourceConfigs(com.thoughtworks.go.config.ResourceConfigs) Test(org.junit.Test)

Example 5 with ResourceConfigs

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

the class TriStateSelectionTest method shouldBeNoChangeIfAllAgentsHaveThatResource.

@Test
public void shouldBeNoChangeIfAllAgentsHaveThatResource() {
    resourceConfigs.add(new ResourceConfig("some"));
    agents.add(new AgentConfig("uuid1", "host1", "127.0.0.1", new ResourceConfigs("some")));
    agents.add(new AgentConfig("uuid2", "host2", "127.0.0.2", new ResourceConfigs()));
    List<TriStateSelection> selections = TriStateSelection.forAgentsResources(resourceConfigs, agents);
    assertThat(selections, hasItem(new TriStateSelection("some", TriStateSelection.Action.nochange)));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) ResourceConfig(com.thoughtworks.go.config.ResourceConfig) ResourceConfigs(com.thoughtworks.go.config.ResourceConfigs) Test(org.junit.Test)

Aggregations

ResourceConfigs (com.thoughtworks.go.config.ResourceConfigs)7 Test (org.junit.Test)7 ResourceConfig (com.thoughtworks.go.config.ResourceConfig)6 AgentConfig (com.thoughtworks.go.config.AgentConfig)5 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)1