use of com.thoughtworks.go.server.ui.AgentViewModel 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));
}
use of com.thoughtworks.go.server.ui.AgentViewModel in project gocd by gocd.
the class AgentServiceIntegrationTest method shouldFindAnAgentForAGivenUUID.
@Test
public void shouldFindAnAgentForAGivenUUID() {
createEnabledAgent(UUID);
createEnabledAgent(UUID2);
BasicEnvironmentConfig foo = new BasicEnvironmentConfig(new CaseInsensitiveString("foo"));
foo.addAgent(UUID);
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
environmentConfigService.createEnvironment(foo, Username.ANONYMOUS, result);
assertThat(result.isSuccessful(), is(true));
AgentViewModel actual = agentService.findAgentViewModel(UUID);
assertThat(actual, is(new AgentViewModel(agentService.findAgentAndRefreshStatus(UUID), "foo")));
}
use of com.thoughtworks.go.server.ui.AgentViewModel 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)));
}
}
use of com.thoughtworks.go.server.ui.AgentViewModel 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"));
}
Aggregations