cucumber.runtime.table.DataTableDiff Maven / Gradle / Ivy
package cucumber.runtime.table;
import cucumber.api.DataTable;
import cucumber.api.TableConverter;
import gherkin.pickles.PickleRow;
import gherkin.pickles.PickleTable;
import java.util.AbstractMap.SimpleEntry;
import java.util.ArrayList;
import java.util.List;
public class DataTableDiff extends DataTable {
public enum DiffType {
NONE, DELETE, INSERT
}
private List diffTypes;
public static DataTableDiff create(List> diffTableRows, TableConverter tableConverter) {
List rows = new ArrayList(diffTableRows.size());
List diffTypes = new ArrayList(diffTableRows.size());
for (SimpleEntry row : diffTableRows) {
rows.add(row.getKey());
diffTypes.add(row.getValue());
}
return new DataTableDiff(new PickleTable(rows), diffTypes, tableConverter);
}
public DataTableDiff(PickleTable pickleTable, List diffTypes, TableConverter tableConverter) {
super(pickleTable, tableConverter);
this.diffTypes = diffTypes;
}
@Override
protected TablePrinter createTablePrinter() {
return new DiffTablePrinter(diffTypes);
}
}