Search in sources :

Example 1 with AgentsViewModel

use of com.thoughtworks.go.server.ui.AgentsViewModel 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 2 with AgentsViewModel

use of com.thoughtworks.go.server.ui.AgentsViewModel in project gocd by gocd.

the class AgentServiceIntegrationTest method enabledAgents_shouldNotIncludePendingAgents.

@Test
public void enabledAgents_shouldNotIncludePendingAgents() throws Exception {
    AgentInstance idle = AgentInstanceMother.updateUuid(AgentInstanceMother.idle(new Date(), "CCeDev01"), UUID);
    AgentInstance pending = AgentInstanceMother.pending();
    AgentInstance building = AgentInstanceMother.building();
    AgentInstance denied = AgentInstanceMother.disabled();
    createEnvironment("uat");
    EnvironmentConfig environment = environmentConfigService.named("uat");
    environment.addAgent(UUID);
    AgentInstances instances = new AgentInstances(null, new SystemEnvironment(), idle, pending, building, denied);
    AgentService agentService = getAgentService(instances);
    AgentsViewModel agents = agentService.registeredAgents();
    assertThat(agents.size(), is(3));
    for (AgentViewModel agent : agents) {
        assertThat(agent.getStatus().getConfigStatus(), not(is(AgentConfigStatus.Pending)));
    }
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) AgentInstances(com.thoughtworks.go.server.domain.AgentInstances) AgentsViewModel(com.thoughtworks.go.server.ui.AgentsViewModel) AgentViewModel(com.thoughtworks.go.server.ui.AgentViewModel) Test(org.junit.Test)

Example 3 with AgentsViewModel

use of com.thoughtworks.go.server.ui.AgentsViewModel in project gocd by gocd.

the class AgentServiceTest method shouldUnderstandFilteringAgentListBasedOnUuid.

@Test
public void shouldUnderstandFilteringAgentListBasedOnUuid() {
    AgentInstance instance1 = AgentInstance.createFromLiveAgent(AgentRuntimeInfo.fromServer(new AgentConfig("uuid-1", "host-1", "192.168.1.2"), true, "/foo/bar", 100l, "linux", false), new SystemEnvironment());
    AgentInstance instance3 = AgentInstance.createFromLiveAgent(AgentRuntimeInfo.fromServer(new AgentConfig("uuid-3", "host-3", "192.168.1.4"), true, "/baz/quux", 300l, "linux", false), new SystemEnvironment());
    when(agentInstances.filter(Arrays.asList("uuid-1", "uuid-3"))).thenReturn(Arrays.asList(instance1, instance3));
    AgentsViewModel agents = agentService.filter(Arrays.asList("uuid-1", "uuid-3"));
    AgentViewModel view1 = new AgentViewModel(instance1);
    AgentViewModel view2 = new AgentViewModel(instance3);
    assertThat(agents, is(new AgentsViewModel(view1, view2)));
    verify(agentInstances).filter(Arrays.asList("uuid-1", "uuid-3"));
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) AgentConfig(com.thoughtworks.go.config.AgentConfig) AgentsViewModel(com.thoughtworks.go.server.ui.AgentsViewModel) AgentViewModel(com.thoughtworks.go.server.ui.AgentViewModel) Test(org.junit.Test)

Aggregations

AgentInstance (com.thoughtworks.go.domain.AgentInstance)3 AgentViewModel (com.thoughtworks.go.server.ui.AgentViewModel)3 AgentsViewModel (com.thoughtworks.go.server.ui.AgentsViewModel)3 Test (org.junit.Test)2 AgentConfig (com.thoughtworks.go.config.AgentConfig)1 Resource (com.thoughtworks.go.config.Resource)1 AgentInstances (com.thoughtworks.go.server.domain.AgentInstances)1 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)1 HashSet (java.util.HashSet)1