public void row(List<Comment> comments, List<String> cells, Integer line, String id) { if (rows == null) { rows = new ArrayList<DataTableRow>(); } rows.add(new DataTableRow(comments, cells, line)); }
public DataTableRow toDataTableRow() { return new DataTableRow(CommentDTO.toGherkinComments(comments), cells, line, diffType); } }
private List<DataTableRow> dataTableRows(List o) { List<DataTableRow> rows = new ArrayList<DataTableRow>(o.size()); for (Object e : o) { Map row = (Map) e; rows.add(new DataTableRow(comments(row), getList(row, "cells"), getInt(row, "line"))); } return rows; }
public String getKeywordTable() { StringWriter writer = new StringWriter(); PrettyFormatter pf = new PrettyFormatter(writer, true, false); List<Row> table = new ArrayList<Row>(); for (String key : KEYWORD_KEYS) { List<String> cells = Arrays.asList(key, join(map(keywords(key), QUOTE_MAPPER), ", ")); table.add(new DataTableRow(Collections.<Comment>emptyList(), cells, -1)); } for (String key : STEP_KEYWORD_KEYS) { List<String> codeKeywordList = new ArrayList<String>(keywords.get(key)); codeKeywordList.remove("* "); String codeKeywords = join(map(map(codeKeywordList, CODE_KEYWORD_MAPPER), QUOTE_MAPPER), ", "); List<String> cells = Arrays.asList(key + " (code)", codeKeywords); table.add(new DataTableRow(Collections.<Comment>emptyList(), cells, -1)); } pf.table(table); return writer.getBuffer().toString(); }
private Step loadAndReplaceSteps(Step step, String filePathFromComment, Resource sourceResource) { DataReader dataReader; try { InputStream inputStream = sourceResource.getInputStream(); dataReader = DataReaderFactory.create(sourceResource.getFilename()); DataDTO data = dataReader.readTable(inputStream); List<DataTableRow> rows = Lists.newArrayList(); for (Integer lineNum : data.getValues().keySet()) { List<String> cells = Lists.newArrayList(data.getValues().get(lineNum)); String valueComment = String.format("# %s:%d", filePathFromComment, lineNum + 1); Comment comment = new Comment(valueComment, lineNum); List<Comment> comments = Lists.newArrayList(comment); int newLineNum = step.getLine() + 2; if (isPreview) { newLineNum += lineOffset; } DataTableRow row = new DataTableRow(comments, cells, newLineNum + 1); rows.add(row); lineOffset += 2; } // re-calculate lineOffset lineOffset = lineOffset - step.getRows().size() - 1; step = new Step(step.getComments(), step.getKeyword(), step.getName(), step.getLine(), rows, step.getDocString()); } catch (InstantiationException | IllegalAccessException | IOException e) { throw Throwables.propagate(e); } return step; }