Search in sources :

Example 1 with ResourceConfig

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));
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) AgentsViewModel(com.thoughtworks.go.server.ui.AgentsViewModel) AgentViewModel(com.thoughtworks.go.server.ui.AgentViewModel) ResourceConfig(com.thoughtworks.go.config.ResourceConfig) HashSet(java.util.HashSet)

Example 2 with ResourceConfig

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));
}
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 3 with ResourceConfig

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;
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) ResourceConfig(com.thoughtworks.go.config.ResourceConfig) Date(java.util.Date)

Example 4 with ResourceConfig

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")));
}
Also used : ResourceConfig(com.thoughtworks.go.config.ResourceConfig) ResourceConfigs(com.thoughtworks.go.config.ResourceConfigs) Test(org.junit.Test)

Example 5 with ResourceConfig

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;
}
Also used : ResourceConfig(com.thoughtworks.go.config.ResourceConfig)

Aggregations

ResourceConfig (com.thoughtworks.go.config.ResourceConfig)13 Test (org.junit.Test)8 AgentConfig (com.thoughtworks.go.config.AgentConfig)6 ResourceConfigs (com.thoughtworks.go.config.ResourceConfigs)6 AgentInstance (com.thoughtworks.go.domain.AgentInstance)3 HashSet (java.util.HashSet)2 Agents (com.thoughtworks.go.config.Agents)1 AgentViewModel (com.thoughtworks.go.server.ui.AgentViewModel)1 AgentsViewModel (com.thoughtworks.go.server.ui.AgentsViewModel)1 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)1 Date (java.util.Date)1 Before (org.junit.Before)1