Search in sources :

Example 1 with Resource

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

the class AgentInstance method createFromConfig.

public static AgentInstance createFromConfig(AgentConfig agentInConfig, SystemEnvironment systemEnvironment) {
    AgentType type = agentInConfig.isFromLocalHost() ? AgentType.LOCAL : AgentType.REMOTE;
    AgentInstance result = new AgentInstance(agentInConfig, type, systemEnvironment);
    result.agentConfigStatus = agentInConfig.isDisabled() ? AgentConfigStatus.Disabled : AgentConfigStatus.Enabled;
    result.errors = new ConfigErrors();
    result.errors.addAll(agentInConfig.errors());
    for (Resource resource : agentInConfig.getResources()) {
        result.errors.addAll(resource.errors());
    }
    return result;
}
Also used : Resource(com.thoughtworks.go.config.Resource)

Example 2 with Resource

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

the class AgentsViewModelMother method getTwoAgents.

public static AgentsViewModel getTwoAgents() {
    AgentInstance building = AgentInstanceMother.building();
    building.getResources().add(new Resource("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) Resource(com.thoughtworks.go.config.Resource) HashSet(java.util.HashSet)

Example 3 with Resource

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

the class ResourcesTest method shouldTrimResourceNames.

@Test
public void shouldTrimResourceNames() {
    Resources resources = new Resources();
    resources.add(new Resource("foo"));
    resources.add(new Resource("foo      "));
    assertThat(resources.size(), is(1));
    Resources newResources = new Resources();
    newResources.add(new Resource("foo       "));
    newResources.add(new Resource("foo  "));
    assertThat(newResources.size(), is(1));
}
Also used : Resource(com.thoughtworks.go.config.Resource) Resources(com.thoughtworks.go.config.Resources) Test(org.junit.Test)

Example 4 with Resource

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

the class ResourcesTest method shouldGetAllResourcesNames.

@Test
public void shouldGetAllResourcesNames() {
    Resources resources = new Resources();
    resources.add(new Resource("Eoo"));
    resources.add(new Resource("Poo"));
    List<String> names = new ArrayList<>();
    names.add("Eoo");
    names.add("Poo");
    List<String> resourceNames = resources.resourceNames();
    assertThat(resourceNames, is(names));
}
Also used : Resource(com.thoughtworks.go.config.Resource) ArrayList(java.util.ArrayList) Resources(com.thoughtworks.go.config.Resources) Test(org.junit.Test)

Example 5 with Resource

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

the class ResourcesTest method shouldIgnoreCaseNamesOfResources.

@Test
public void shouldIgnoreCaseNamesOfResources() {
    Resources resources = new Resources();
    resources.add(new Resource("Eoo"));
    resources.add(new Resource("eoo"));
    assertThat(resources.size(), is(1));
}
Also used : Resource(com.thoughtworks.go.config.Resource) Resources(com.thoughtworks.go.config.Resources) Test(org.junit.Test)

Aggregations

Resource (com.thoughtworks.go.config.Resource)31 Test (org.junit.Test)22 Resources (com.thoughtworks.go.config.Resources)17 AgentConfig (com.thoughtworks.go.config.AgentConfig)5 AgentInstance (com.thoughtworks.go.domain.AgentInstance)3 JobInstance (com.thoughtworks.go.domain.JobInstance)3 EnvironmentVariableConfig (com.thoughtworks.go.config.EnvironmentVariableConfig)2 JobPlan (com.thoughtworks.go.domain.JobPlan)2 HashSet (java.util.HashSet)2 DOMElement (org.dom4j.dom.DOMElement)2 Agents (com.thoughtworks.go.config.Agents)1 ArtifactPlan (com.thoughtworks.go.config.ArtifactPlan)1 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)1 Property (com.thoughtworks.go.domain.Property)1 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)1 WaitingJobPlan (com.thoughtworks.go.domain.WaitingJobPlan)1 AgentViewModel (com.thoughtworks.go.server.ui.AgentViewModel)1 AgentsViewModel (com.thoughtworks.go.server.ui.AgentsViewModel)1 ArrayList (java.util.ArrayList)1