ProblemAnalyzer extends AbstractMessageAnalyzer<ProblemReport> implements LogEnabled, Initializable { @Override public void process(MessageTree tree) { String domain = tree.getDomain(); ProblemReport report = m_reportManager.getHourlyReport(getStartTime(), domain, true); report.addIp(tree.getIpAddress()); Machine machine = report.findOrCreateMachine(tree.getIpAddress()); for (ProblemHandler handler : m_handlers) { handler.handle(machine, tree); } }  @Override synchronized void doCheckpoint(boolean atEnd); @Override void enableLogging(Logger logger); Set<String> getDomains(); @Override ProblemReport getReport(String domain); @Override ReportManager<ProblemReport> getReportManager(); @Override void initialize(); @Override void process(MessageTree tree); static final String ID; }
@Test public void testProcess() throws Exception { for (int i = 1; i <= 100; i++) { MessageTree tree = generateMessageTree(i); m_analyzer.process(tree); } ProblemReport report = m_analyzer.getReport(m_domain); String expected = Files.forIO().readFrom(getClass().getResourceAsStream("problem_analyzer.xml"), "utf-8"); ProblemReport expected4report = com.dianping.cat.consumer.problem.model.transform.DefaultSaxParser.parse(expected); Assert.assertTrue(TestHelper.isEquals(expected4report,report)); }