Search in sources :

Example 1 with AgentPoolAgentsConnection

use of jetbrains.buildServer.server.graphql.model.connections.agentPool.AgentPoolAgentsConnection in project teamcity-rest by JetBrains.

the class AbstractAgentPoolResolverTest method basicAgentsConnection.

public void basicAgentsConnection() throws AgentPoolCannotBeRenamedException, NoSuchAgentPoolException, AgentTypeCannotBeMovedException, PoolQuotaExceededException {
    AgentPoolManager manager = myFixture.getAgentPoolManager();
    jetbrains.buildServer.serverSide.agentPools.AgentPool evenAgents = manager.createNewAgentPool("evenAgents");
    jetbrains.buildServer.serverSide.agentPools.AgentPool oddAgents = manager.createNewAgentPool("oddAgents");
    final int num = 2;
    for (int i = 0; i < num * 2; i++) {
        MockBuildAgent agent = myFixture.createEnabledAgent("agent_" + i);
        registerAndEnableAgent(agent);
        manager.moveAgentToPool((i % 2 == 0) ? evenAgents.getAgentPoolId() : oddAgents.getAgentPoolId(), agent);
    }
    AgentPoolAgentsConnection evenConnection = myResolver.agents(new AgentPool(evenAgents), myDataFetchingEnvironment);
    assertEquals(num, evenConnection.getCount());
    for (AgentPoolAgentsConnection.AgentPoolAgentsConnectionEdge edge : evenConnection.getEdges().getData()) {
        assertEquals(evenAgents.getAgentPoolId(), edge.getNode().getData().getRealAgent().getAgentPoolId());
    }
    AgentPoolAgentsConnection oddConnection = myResolver.agents(new AgentPool(oddAgents), myDataFetchingEnvironment);
    assertEquals(num, oddConnection.getCount());
    for (AgentPoolAgentsConnection.AgentPoolAgentsConnectionEdge edge : oddConnection.getEdges().getData()) {
        assertEquals(oddAgents.getAgentPoolId(), edge.getNode().getData().getRealAgent().getAgentPoolId());
    }
}
Also used : AgentPoolAgentsConnection(jetbrains.buildServer.server.graphql.model.connections.agentPool.AgentPoolAgentsConnection) MockBuildAgent(jetbrains.buildServer.serverSide.impl.MockBuildAgent) jetbrains.buildServer.serverSide.agentPools(jetbrains.buildServer.serverSide.agentPools) AgentPool(jetbrains.buildServer.server.graphql.model.agentPool.AgentPool)

Aggregations

AgentPool (jetbrains.buildServer.server.graphql.model.agentPool.AgentPool)1 AgentPoolAgentsConnection (jetbrains.buildServer.server.graphql.model.connections.agentPool.AgentPoolAgentsConnection)1 jetbrains.buildServer.serverSide.agentPools (jetbrains.buildServer.serverSide.agentPools)1 MockBuildAgent (jetbrains.buildServer.serverSide.impl.MockBuildAgent)1