ProblemReportMerger extends DefaultMerger { protected List<String> mergeList(List<String> oldMessages, List<String> newMessages, int size) { int originalSize = oldMessages.size(); if (originalSize < size) { int remainingSize = size - originalSize; if (remainingSize >= newMessages.size()) { oldMessages.addAll(newMessages); } else { oldMessages.addAll(newMessages.subList(0, remainingSize)); } } return oldMessages; } ProblemReportMerger(ProblemReport problemReport); @Override void visitProblemReport(ProblemReport problemReport); @Override void mergeGraphTrend(GraphTrend to, GraphTrend from);  }
@Test public void testMergeList() { ProblemReportMerger merger = new ProblemReportMerger(new ProblemReport("cat")); List<String> list1 = buildList1(); merger.mergeList(list1, buildList2(), 10); Assert.assertEquals(10, list1.size()); list1 = buildList1(); merger.mergeList(list1, buildList2(), 25); Assert.assertEquals(25, list1.size()); list1 = buildList1(); merger.mergeList(list1, buildList2(), 30); Assert.assertEquals(30, list1.size()); list1 = buildList1(); merger.mergeList(list1, buildList2(), 40); Assert.assertEquals(30, list1.size()); }