use of cucumber.deps.difflib.Delta in project cucumber-jvm by cucumber.
the class TableDiffer method createTableDiff.
private DataTable createTableDiff(Map<Integer, Delta> deltasByLine) {
List<DataTableRow> diffTableRows = new ArrayList<DataTableRow>();
List<List<String>> rows = from.raw();
for (int i = 0; i < rows.size(); i++) {
Delta delta = deltasByLine.get(i);
if (delta == null) {
diffTableRows.add(from.getGherkinRows().get(i));
} else {
addRowsToTableDiff(diffTableRows, delta);
// skipping lines involved in a delta
if (delta.getType() == Delta.TYPE.CHANGE || delta.getType() == Delta.TYPE.DELETE) {
i += delta.getOriginal().getLines().size() - 1;
} else {
diffTableRows.add(from.getGherkinRows().get(i));
}
}
}
// Can have new lines at end
Delta remainingDelta = deltasByLine.get(rows.size());
if (remainingDelta != null) {
addRowsToTableDiff(diffTableRows, remainingDelta);
}
return new DataTable(diffTableRows, from.getTableConverter());
}
use of cucumber.deps.difflib.Delta in project cucumber-jvm by cucumber.
the class TableDiffer method calculateDiffs.
public void calculateDiffs() throws TableDiffException {
Patch patch = DiffUtils.diff(from.diffableRows(), to.diffableRows());
List<Delta> deltas = patch.getDeltas();
if (!deltas.isEmpty()) {
Map<Integer, Delta> deltasByLine = createDeltasByLine(deltas);
throw new TableDiffException(from, to, createTableDiff(deltasByLine));
}
}