HeartbeatAnalyzer extends AbstractMessageAnalyzer<HeartbeatReport> implements LogEnabled { @Override protected void process(MessageTree tree) { String domain = tree.getDomain(); if (m_serverFilterConfigManager.validateDomain(domain)) { HeartbeatReport report = m_reportManager.getHourlyReport(getStartTime(), domain, true); report.addIp(tree.getIpAddress()); List<Heartbeat> heartbeats = tree.getHeartbeats(); for (Heartbeat h : heartbeats) { if (h.getType().equalsIgnoreCase("heartbeat")) { processHeartbeat(report, h, tree); } } } }  @Override synchronized void doCheckpoint(boolean atEnd); @Override void enableLogging(Logger logger); @Override HeartbeatReport getReport(String domain); @Override ReportManager<HeartbeatReport> getReportManager(); @Override boolean isEligable(MessageTree tree); static final String ID; }
@Test public void testProcess() throws Exception { for (int i = 1; i <= 10; i++) { MessageTree tree = ((DefaultMessageTree) generateMessageTree(i)).copyForTest(); m_analyzer.process(tree); } HeartbeatReport report = m_analyzer.getReport(m_domain); String expected = Files.forIO().readFrom(getClass().getResourceAsStream("heartbeat_analyzer.xml"), "utf-8"); Assert.assertEquals(expected.replaceAll("\r", ""), report.toString().replaceAll("\r", "")); }