Search in sources :

Example 1 with AgentRequest

use of jetbrains.buildServer.server.rest.request.AgentRequest in project teamcity-rest by JetBrains.

the class BuildCompatibleAgentsTest method testAgentRequest.

@Test
public void testAgentRequest() {
    AgentRequest resource = AgentRequest.createForTests(getBeanContext(myFixture));
    patchExpectationsForAgentRequests();
    for (SBuildAgent agent : myExpected.getAllAgents()) {
        assertCollectionEquals(agent.getName(), resource.getCompatibleBuildTypes("id:" + agent.getId(), null), myExpected.compatibleBuildTypes(agent));
    }
    for (SBuildAgent agent : myExpected.getAllAgents()) {
        assertCollectionEquals(agent.getName(), resource.geIncompatibleBuildTypes("id:" + agent.getId(), null), myExpected.incompatibleBuildTypes(agent));
    }
}
Also used : AgentRequest(jetbrains.buildServer.server.rest.request.AgentRequest) Test(org.testng.annotations.Test) BuildTest(jetbrains.buildServer.server.rest.model.BuildTest)

Example 2 with AgentRequest

use of jetbrains.buildServer.server.rest.request.AgentRequest in project teamcity-rest by JetBrains.

the class AgentTest method testEnabledComment.

@Test
public void testEnabledComment() throws ParseException {
    final MockBuildAgent agent1 = myFixture.createEnabledAgent("agent1", "runType");
    agent1.setEnabled(false, null, "test");
    assertFalse(agent1.isEnabled());
    Agent.setFieldValue(agent1, "enabled", "true", myFixture);
    assertTrue(agent1.isEnabled());
    AgentRequest resource = AgentRequest.createForTests(getBeanContext(myFixture));
    {
        AgentEnabledInfo enabledInfo = resource.getEnabledInfo("id:" + agent1.getId(), "$long");
        assertEquals(Boolean.TRUE, enabledInfo.status);
        assertEquals(null, enabledInfo.comment.text);
        assertEquals(null, enabledInfo.statusSwitchTime);
    }
    AgentEnabledInfo newEnabledInfo = new AgentEnabledInfo();
    newEnabledInfo.status = Boolean.FALSE;
    newEnabledInfo.comment = new Comment();
    newEnabledInfo.comment.text = "custom comment";
    newEnabledInfo.statusSwitchTime = "+10m";
    resource.setEnabledInfo("id:" + agent1.getId(), newEnabledInfo, "$long");
    {
        AgentEnabledInfo enabledInfo = resource.getEnabledInfo("id:" + agent1.getId(), "$long");
        assertEquals(Boolean.FALSE, enabledInfo.status);
        assertEquals("custom comment", enabledInfo.comment.text);
        assertTrue(new SimpleDateFormat("yyyyMMdd'T'HHmmssZ").parse(enabledInfo.statusSwitchTime).getTime() - new Date().getTime() - 10 * 60 * 60 * 1000 < 1000);
    }
}
Also used : AgentEnabledInfo(jetbrains.buildServer.server.rest.model.agent.AgentEnabledInfo) AgentRequest(jetbrains.buildServer.server.rest.request.AgentRequest) MockBuildAgent(jetbrains.buildServer.serverSide.impl.MockBuildAgent) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) BaseFinderTest(jetbrains.buildServer.server.rest.data.BaseFinderTest) Test(org.testng.annotations.Test)

Aggregations

AgentRequest (jetbrains.buildServer.server.rest.request.AgentRequest)2 Test (org.testng.annotations.Test)2 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)1 BuildTest (jetbrains.buildServer.server.rest.model.BuildTest)1 AgentEnabledInfo (jetbrains.buildServer.server.rest.model.agent.AgentEnabledInfo)1 MockBuildAgent (jetbrains.buildServer.serverSide.impl.MockBuildAgent)1