AnalysisSwooshMatchRecordGrouping extends AnalysisMatchRecordGrouping { @Override protected void outputRow(RichRecord row) { if (matchResultConsumer != null && matchResultConsumer.isKeepDataInMemory()) { tmpMatchResult.add(row); } else { out(row); } } AnalysisSwooshMatchRecordGrouping(MatchGroupResultConsumer matchResultConsumer);  AnalysisSwooshMatchRecordGrouping(); @Override void setSurvivorShipAlgorithmParams(SurvivorShipAlgorithmParams survivorShipAlgorithmParams); @Override void initialize(); @Override void doGroup(RichRecord currentRecord); @Override void end();  }
@Test public void testOutputRow() { double groupQuality = 0.6; List<DQAttribute<?>> originRow = new ArrayList<>(); originRow.add(new DQAttribute<>(SwooshConstants.GROUP_QUALITY, 0, "1.0")); RichRecord richRecord = new RichRecord("1", 0l, "a"); JunitResultConsumer resultConsumer = new JunitResultConsumer(); AnalysisSwooshMatchRecordGrouping analysisSwooshMatchRecordGrouping = new AnalysisSwooshMatchRecordGrouping(resultConsumer); richRecord.setRecordSize(1); richRecord.setOriginRow(originRow); richRecord.setGrpSize(1); richRecord.setMaster(true); richRecord.setGroupQuality(groupQuality); analysisSwooshMatchRecordGrouping.outputRow(richRecord); Object[] result = resultConsumer.getResult(); Assert.assertTrue("can not get correct result", result.length > 0); Assert.assertEquals("1.0", result[0]); richRecord = new RichRecord("1", 0l, "a"); richRecord.setRecordSize(1); originRow = new ArrayList<>(); originRow.add(new DQAttribute<>(SwooshConstants.GROUP_QUALITY, 0, "1.0")); richRecord.setOriginRow(originRow); richRecord.setGrpSize(1); richRecord.setMaster(false); richRecord.setGroupQuality(groupQuality); analysisSwooshMatchRecordGrouping.outputRow(richRecord); result = resultConsumer.getResult(); Assert.assertTrue("can not get correct result", result.length > 0); Assert.assertEquals(StringUtils.EMPTY, result[5]); richRecord.setGrpSize(0); analysisSwooshMatchRecordGrouping.outputRow(richRecord); result = resultConsumer.getResult(); Assert.assertTrue("can not get correct result", result.length > 0); richRecord.setGrpSize(2); analysisSwooshMatchRecordGrouping.outputRow(richRecord); result = resultConsumer.getResult(); Assert.assertTrue("can not get correct result", result.length > 0); originRow.clear(); richRecord.setMaster(true); richRecord.setMerged(true); richRecord.setGroupId("group1"); analysisSwooshMatchRecordGrouping.outputRow(richRecord); result = resultConsumer.getResult(); Assert.assertTrue("can not get correct result", result.length == 6); Assert.assertEquals("group1", result[0]); Assert.assertEquals("2", result[1]); Assert.assertEquals("true", result[2]); Assert.assertEquals("1.0", result[3]); Assert.assertEquals(String.valueOf(groupQuality), result[4]); Assert.assertEquals(StringUtils.EMPTY, result[5]); }