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));
}
}
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);
}
}
Aggregations