public static Cells parse(String markup) { Rows row = new Rows(); // The following regex uses a group representing the string between [ ] // containing any characters except ] Pattern pattern = Pattern.compile("\\[([^\\]]*)\\]"); Matcher matcher = pattern.matcher(markup); while (matcher.find()) { row.addChild(new Cells(matcher.group(1).trim())); } return ( Cells ) row.firstChild(); }
public String rowMarkedAs() { int cellToWatch = row.firstChild().remainings() - 1; return AnnotationUtil.getAnnotationOnCell(row.at(0, cellToWatch)); }
@Override public String toString() { return hasChild() ? parts.toMarkup(false) : EMPTY; } }
@Test public void testInstantiatesRowIfFirstCellOfExampleContainsFullyQualifiedClassName() { Rows rows = Rows.parse("[" + AcceptRow.class.getName() + "]"); Row row = selector.select(rows); assertThat(row, is(instanceOf(AcceptRow.class))); }
public AnnotationTable annotations() { SetOfInterpreter setOf = new SetOfInterpreter(new PlainOldFixture(this)); Rows rows = new Rows("to string"); rows.addSibling(tables.firstChild()); setOf.execute(rows); return new AnnotationTable(tables); }
@Test public void testShouldSkipWhenRowClassCannotBeInstantiated() { Rows rows = Rows.parse("[" + UninstantiableRow.class.getName() + "]"); Row row = selector.select(rows); assertThat(row, is(instanceOf(SkipRow.class))); FakeSpecification spec = specification(rows); row.interpret(spec); Assertions.assertAnnotatedException(rows.firstChild()); assertFalse(spec.hasMoreExamples()); }
@Override public Rows newChild() { return new Rows(); }
public static Rows parse(String markup) { Tables table = new Tables(); String[] rows = markup.split("\\n"); for (String cells : rows) { if (StringUtils.isBlank(cells)) { continue; } Rows row = ( Rows ) table.addChild(); if ( ! isRowEmpty(cells)) { row.addChild(Cells.parse(cells)); } } return ( Rows ) table.firstChild(); }
@Override public String toMarkup(boolean prettyPrint) { return toMarkup(this, prettyPrint); }
public Rows(Object... cells) { for (Object cell : cells) { addChild().content = cell; } }
private Object[] headers(Rows paramRow) { List<String> headerList = new ArrayList<String>(); for (int i = 0; i < paramRow.firstChild().remainings(); i ++ ) { headerList.add("foo"); } return headerList.toArray(); }
@Test public void testInstantiatesRowIfFirstCellOfExampleContainsFullyQualifiedClassName() { Rows rows = Rows.parse("[" + GivenRow.class.getName() + "]"); Row row = selector.select(rows); assertThat(row, is(instanceOf(GivenRow.class))); }
public AnnotationTable annotations() { SetOfInterpreter setOf = new SetOfInterpreter(new PlainOldFixture(this)); Rows rows = new Rows("first", "last"); rows.addSibling(tables.firstChild()); setOf.execute(rows); return new AnnotationTable(tables); }
@Test public void testShouldSkipWhenRowClassCannotBeInstantiated() { Rows rows = Rows.parse("[" + UninstantiableRow.class.getName() + "]"); Row row = selector.select(rows); assertThat(row, is(instanceOf(SkipRow.class))); FakeSpecification spec = specification(rows); row.interpret(spec); Assertions.assertAnnotatedException(rows.firstChild()); assertFalse(spec.hasMoreExamples()); }
@Override protected FakeExample newSibling() { return new Rows(); }
public static String toMarkup(Example example, boolean prettyPrint) { return toMarkup(example, prettyPrint, new MarkupPrinter.Default()); }
@Test public void testThatItAlwaysSelectsAnActionRow() { Rows rows = Rows.parse("[ anything ]"); Row row = rowSelector.select(rows); assertThat(row, is(instanceOf(ActionRow.class))); }
public AnnotationTable annotations() { SupersetOfInterpreter supersetOf = new SupersetOfInterpreter(new PlainOldFixture(this)); Rows rows = new Rows("to string"); rows.addSibling(tables.firstChild()); supersetOf.execute(rows); return new AnnotationTable(tables); }
public String rowMarkedAs() { int cellToWatch = row.firstChild().remainings() - 1; return AnnotationUtil.getAnnotationOnCell(row.at(0, cellToWatch)); }
public Tables row(Object... cells) { addChild(new Rows(cells)); return this; }