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));
}
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")));
}
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)));
}
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)));
}
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)));
}
Aggregations