public class TopReportMergerTest {
@Test
public void testTopReportMerge() throws Exception {
String oldXml = Files.forIO().readFrom(getClass().getResourceAsStream("top_analyzer.xml"), "utf-8");
String newXml = Files.forIO().readFrom(getClass().getResourceAsStream("top_analyzer.xml"), "utf-8");
TopReport reportOld = DefaultSaxParser.parse(oldXml);
TopReport reportNew = DefaultSaxParser.parse(newXml);
String expected = Files.forIO().readFrom(getClass().getResourceAsStream("top_analyzer_merger.xml"), "utf-8");
TopReportMerger merger = new TopReportMerger(new TopReport(reportOld.getDomain()));
reportOld.accept(merger);
reportNew.accept(merger);
Assert.assertEquals("Check the merge result!", expected.replace("\r", ""), merger.getTopReport().toString()
.replace("\r", ""));
Assert.assertEquals("Source report is changed!", newXml.replace("\r", ""), reportNew.toString().replace("\r", ""));
}