use of com.thoughtworks.go.config.ResourceConfig in project gocd by gocd.
the class AgentsViewModelMother method getTwoAgents.
public static AgentsViewModel getTwoAgents() {
AgentInstance building = AgentInstanceMother.building();
building.getResourceConfigs().add(new ResourceConfig("ruby"));
AgentInstance idle = AgentInstanceMother.idle();
HashSet<String> environments = new HashSet<>();
environments.add("hello");
environments.add("yellow");
return new AgentsViewModel(new AgentViewModel(idle, environments), new AgentViewModel(building));
}
use of com.thoughtworks.go.config.ResourceConfig 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.ResourceConfig in project gocd by gocd.
the class AgentsViewModelTest method agentsViewModel.
private AgentsViewModel agentsViewModel() {
AgentsViewModel agents = new AgentsViewModel();
AgentInstance idle = AgentInstanceMother.idle(new Date(), "CCeDev01");
AgentInstanceMother.updateOS(idle, "macos");
idle.getResourceConfigs().add(new ResourceConfig("foo"));
idle.getResourceConfigs().add(new ResourceConfig("bar"));
agents.add(new AgentViewModel(idle, "uat"));
AgentInstance building = AgentInstanceMother.building();
building.getResourceConfigs().add(new ResourceConfig("goofooboo"));
agents.add(new AgentViewModel(building, "dev", "uat"));
agents.add(new AgentViewModel(AgentInstanceMother.pending()));
agents.add(new AgentViewModel(AgentInstanceMother.disabled(), "prod"));
return agents;
}
use of com.thoughtworks.go.config.ResourceConfig 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.ResourceConfig in project gocd by gocd.
the class AgentInstance method createFromConfig.
public static AgentInstance createFromConfig(AgentConfig agentInConfig, SystemEnvironment systemEnvironment, AgentStatusChangeListener agentStatusChangeListener) {
AgentType type = agentInConfig.isFromLocalHost() ? AgentType.LOCAL : AgentType.REMOTE;
AgentInstance result = new AgentInstance(agentInConfig, type, systemEnvironment, agentStatusChangeListener);
result.agentConfigStatus = agentInConfig.isDisabled() ? AgentConfigStatus.Disabled : AgentConfigStatus.Enabled;
result.errors = new ConfigErrors();
result.errors.addAll(agentInConfig.errors());
for (ResourceConfig resourceConfig : agentInConfig.getResourceConfigs()) {
result.errors.addAll(resourceConfig.errors());
}
return result;
}
Aggregations