use of com.thoughtworks.go.domain.notificationdata.AgentNotificationData in project gocd by gocd.
the class JsonMessageHandler1_0_Test method shouldNotHandleAgentNotificationRequest.
@Test
public void shouldNotHandleAgentNotificationRequest() throws Exception {
thrown.expect(NotImplementedException.class);
thrown.expectMessage(String.format("Converter for %s not supported", AgentNotificationData.class.getCanonicalName()));
messageHandler.requestMessageForNotify(new AgentNotificationData(null, null, false, null, null, null, null, null, null, null));
}
use of com.thoughtworks.go.domain.notificationdata.AgentNotificationData in project gocd by gocd.
the class JsonMessageHandler2_0_Test method shouldNotHandleAgentNotificationRequest.
@Test
public void shouldNotHandleAgentNotificationRequest() throws Exception {
thrown.expect(NotImplementedException.class);
thrown.expectMessage(String.format("Converter for %s not supported", AgentNotificationData.class.getCanonicalName()));
messageHandler.requestMessageForNotify(new AgentNotificationData(null, null, false, null, null, null, null, null, null, null));
}
use of com.thoughtworks.go.domain.notificationdata.AgentNotificationData in project gocd by gocd.
the class JsonMessageHandler3_0_Test method shouldConstructAgentNotificationRequestMessage.
@Test
public void shouldConstructAgentNotificationRequestMessage() throws Exception {
Date transition_time = new Date();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_PATTERN_FOR_V3);
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
String time = simpleDateFormat.format(transition_time);
AgentNotificationData agentNotificationData = new AgentNotificationData("agent_uuid", "agent_hostname", true, "127.0.0.1", "rh", "100", "enabled", "building", "building", transition_time);
String expected = "{\n" + " \"agent_config_state\": \"enabled\",\n" + " \"agent_state\": \"building\",\n" + " \"build_state\": \"building\",\n" + " \"is_elastic\": true,\n" + " \"free_space\": \"100\",\n" + " \"host_name\": \"agent_hostname\",\n" + " \"ip_address\": \"127.0.0.1\",\n" + " \"operating_system\": \"rh\",\n" + " \"uuid\": \"agent_uuid\",\n" + " \"transition_time\": \"" + time + "\"\n" + "}\n";
String message = messageHandler.requestMessageForNotify(agentNotificationData);
JSONAssert.assertEquals(expected, message, JSONCompareMode.NON_EXTENSIBLE);
}
use of com.thoughtworks.go.domain.notificationdata.AgentNotificationData in project gocd by gocd.
the class AgentStatusChangeNotifier method onAgentStatusChange.
@Override
public void onAgentStatusChange(AgentInstance agentInstance) {
if (isAnyPluginInterestedInAgentStatus()) {
AgentNotificationData agentNotificationData = notificationDataFrom(agentInstance);
pluginNotificationQueue.post(new PluginNotificationMessage(NotificationExtension.AGENT_STATUS_CHANGE_NOTIFICATION, agentNotificationData));
}
}
use of com.thoughtworks.go.domain.notificationdata.AgentNotificationData in project gocd by gocd.
the class AgentStatusChangeNotifierTest method shouldNotifyInterestedPluginsWithAgentInformation.
@Test
public void shouldNotifyInterestedPluginsWithAgentInformation() {
AgentInstance agentInstance = AgentInstanceMother.building();
when(notificationPluginRegistry.isAnyPluginInterestedIn("agent-status")).thenReturn(true);
agentStatusChangeNotifier.onAgentStatusChange(agentInstance);
verify(pluginNotificationQueue).post(captor.capture());
assertThat(captor.getValue().getData() instanceof AgentNotificationData, is(true));
AgentNotificationData data = (AgentNotificationData) captor.getValue().getData();
assertThat(data.getUuid(), is(agentInstance.getUuid()));
assertThat(data.getHostName(), is(agentInstance.getHostname()));
assertFalse(data.isElastic());
assertThat(data.getIpAddress(), is(agentInstance.getIpAddress()));
assertThat(data.getFreeSpace(), is(agentInstance.freeDiskSpace().toString()));
assertThat(data.getAgentConfigState(), is(agentInstance.getAgentConfigStatus().name()));
assertThat(data.getAgentState(), is(agentInstance.getRuntimeStatus().agentState().name()));
assertThat(data.getBuildState(), is(agentInstance.getRuntimeStatus().buildState().name()));
}
Aggregations