SubDataSet extends DataSet { @Override public Object getValueAfterFiled(int rowNum, String colName) { if (!isInputVialid(rowNum)) { return null; } Record record = this.getRecordList().get(rowNum + 1); Attribute originalAttribute = record.getAttribute(colName); if (this.fillAttributeMap != null) { FilledAttribute filledAttribute = this.fillAttributeMap.get(originalAttribute); if (filledAttribute != null) { return filledAttribute.getValue(); } } return originalAttribute.getValue(); } SubDataSet(DataSet dataSet, List<Integer> conflictDataIndexList); @Override Collection<Attribute> getAttributesByColumn(String columnName); @Override Object getValueAfterFiled(int rowNum, String colName); List<Integer> getDataSetIndex(); DataSet getOrignialDataSet(); void addFillAttributeMap(FilledAttribute filledAttribute); Map<Attribute, FilledAttribute> getFillAttributeMap(); @Override boolean checkDupSurValue(Object value, String colName);  }
@Test public void testGetValueAfterFiled() { 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); 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); SubDataSet subDataSet = new SubDataSet(dataset, null); Object valueAfterFiled = subDataSet.getValueAfterFiled(-1, "city1"); Assert.assertEquals("The value of first row on city1 column is value1", "value1", valueAfterFiled); valueAfterFiled = subDataSet.getValueAfterFiled(0, "city2"); Assert.assertEquals("The value of second row on city2 column is value4", "value4", valueAfterFiled); valueAfterFiled = subDataSet.getValueAfterFiled(-2, "city2"); Assert.assertEquals("The value of -1th row on city2 column is null", null, valueAfterFiled); valueAfterFiled = subDataSet.getValueAfterFiled(1, "city2"); Assert.assertEquals("The value of third row on city2 column is null", null, valueAfterFiled); }