DataSet { public void arrangeConflictCol(String conflictCol, SurvivedResult survivoredRowNum) { List<Integer> orignalList = conflictDataMap.get().get(conflictCol); Object survivShipResult = this.survivorMap.get(conflictCol); if (orignalList == null || conflictList.size() == 0) { return; } for (int index : orignalList) { if (survivoredRowNum.isResolved()) { conflictList.get(index).remove(conflictCol); } else if (survivShipResult.equals(this.getValueAfterFiled(index - 1, conflictCol))) { conflictList.get(index).remove(conflictCol); } } } DataSet(List<Column> columns); protected  DataSet(List<Column> columns, List<Record> recordList); void initData(Object[][] input); void reset(); Collection<Attribute> getAttributesByColumn(String columnName); List<Column> getColumnList(); @Deprecated void survive(int recNum, String colName); void survive(int recNum, String colName, String ruleName); void surviveByAliveField(int recNum, String col, String aliveField); void eliminate(int recNum, String col); void finalizeComputation(); void arrangeConflictCol(String conflictCol, SurvivedResult survivoredRowNum); boolean checkDupSurValue(Object value, String colName); boolean isMostCommon(Object var, String column, boolean ignoreBlanks); boolean isMostComplete(int recNum); boolean isLongest(Object var, String column, boolean ignoreBlanks); boolean isShortest(Object var, String column, boolean ignoreBlanks); boolean isLatest(Object var, String column); boolean isEarliest(Object var, String column); boolean isLargest(Object var, String column); boolean isSmallest(Object var, String column); HashMap<String, Object> getSurvivorMap(); List<HashSet<String>> getConflictList(); HashSet<String> getConflictsOfSurvivor(); List<Record> getRecordList(); Object getValueAfterFiled(int rowNum, String colName); SoftReference<HashMap<String, List<Integer>>> getConflictDataMap(); List<Integer> getConflictDataIndexList(String colName); void addConfDataIndex(String colName, Integer index); SubDataSet createSubDataSet(String colName); HashMap<String, Integer> getSurvivorIndexMap(); List<Column> getColumnOrder(); void setColumnOrder(List<Column> columnOrder);  }
@Test public void testArrangeConflictCol() throws Exception { Column col1 = new Column("city1", "String"); Column col2 = new Column("city2", "String"); List<Column> columns = new ArrayList<>(); columns.add(col1); columns.add(col2); DataSet dataset = new DataSet(columns); Record record1 = new Record(); record1.setId(1); Attribute att1 = new Attribute(record1, col1, "value1"); Attribute att2 = new Attribute(record1, col2, "value2"); record1.putAttribute("city1", att1); record1.putAttribute("city2", att2); col1.putAttribute(record1, att1); col2.putAttribute(record1, att2); dataset.getRecordList().add(record1); record1 = new Record(); record1.setId(2); att1 = new Attribute(record1, col1, "value3"); att2 = new Attribute(record1, col2, "value4"); record1.putAttribute("city1", att1); record1.putAttribute("city2", att2); col1.putAttribute(record1, att1); col2.putAttribute(record1, att2); dataset.getRecordList().add(record1); List<Integer> conflictRowNum = new ArrayList<>(); conflictRowNum.add(0); dataset.getConflictDataMap().get().put("city2", conflictRowNum); conflictRowNum = new ArrayList<>(); conflictRowNum.add(0); dataset.getConflictDataMap().get().put("city1", conflictRowNum); Map<String, Integer> columnIndexMap = new HashMap<>(); columnIndexMap.put("city1", 0); columnIndexMap.put("city2", 1); List<HashSet<String>> conflictList = dataset.getConflictList(); HashSet<String> hashSet = new HashSet<>(); hashSet.add("city1"); hashSet.add("city2"); conflictList.add(hashSet); hashSet = new HashSet<>(); hashSet.add("city1"); hashSet.add("city2"); conflictList.add(hashSet); HashMap<String, Object> survivorMap = dataset.getSurvivorMap(); survivorMap.put("city1", "value1"); survivorMap.put("city2", "value2"); SurvivedResult survivedResult1 = new SurvivedResult(0, "city1"); survivedResult1.setResolved(true); SurvivedResult survivedResult2 = new SurvivedResult(0, "city2"); dataset.arrangeConflictCol("city1", survivedResult1); dataset.arrangeConflictCol("city2", survivedResult2); Assert.assertEquals("The size of conflict list should be 0", 0, conflictList.get(0).size()); Assert.assertEquals("The size of conflict list should be 2", 2, conflictList.get(1).size()); Iterator<String> iterator = conflictList.get(1).iterator(); String conflictColumnForFirstRecored = iterator.next(); String conflictColumnForSecondRecored = iterator.next(); Assert.assertEquals("The first conflict column in second record should be city1", "city1", conflictColumnForFirstRecored); Assert.assertEquals("The second conflict column in second record should be city2", "city2", conflictColumnForSecondRecored); dataset.getConflictDataMap().get().clear(); dataset.arrangeConflictCol("city2", survivedResult2); }