@Test public void testBlankLinesInMarkupTable_ShouldBeIgnoredDuringParsing() { Tables blankLinesInMarkupTable = new Tables(); blankLinesInMarkupTable.row(1, 2, 3).row(4, 5, 6).row(7, 8, 9); blankLinesInMarkupTable.table().row(1, 2, 3).row(4, 5, 6).row(7, 8, 9); String markup = "\n\n[ 1 ][ 2 ][ 3 ]\n\n[ 4 ][ 5 ][ 6 ]\n[ 7 ][ 8 ][ 9 ]\n\n****\n\n[ 1 ][ 2 ][ 3 ]\n[ 4 ][ 5 ][ 6 ]\n[ 7 ][ 8 ][ 9 ]\n\n"; assertEquals(blankLinesInMarkupTable, Tables.parse(markup)); }
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(); }
public Tables table() { return ( Tables ) addSibling(); }
@Test public void testShouldProcessAllRows() throws Exception { tables = parse("[rule for][calculator]\n" + "[a][b][sum?][division?]\n" + "[6][2][8][3]\n" + "[10][5][15][2]"); interpreter.interpret(spec()); assertAnnotatedRight(tables.at(0, 2, 2)); assertAnnotatedRight(tables.at(0, 2, 3)); assertAnnotatedRight(tables.at(0, 3, 2)); assertAnnotatedRight(tables.at(0, 3, 3)); }
@Test public void testATableDefinesASequenceOfActions() throws Exception { doReturn(true).when(fixture).commandTakingNoParameter(); tables = Tables.parse("[workflow][mock]\n" + "[commandTakingNoParameter]\n" + "[commandTakingNoParameter]"); interpreter.interpret(document()); verify(fixture, times(2)).commandTakingNoParameter(); }
private Interpreter interpreterFor(Tables paramTable, Fixture fixture) throws Exception { String interpreterCalled = paramTable.firstChild().firstChild().at(0).getContent(); if ("setup".equals(interpreterCalled)) { return new SetupInterpreter(fixture); } else if ("rule for".equals(interpreterCalled)) { return new DecisionTableInterpreter(fixture); } else if ("decision table".equals(interpreterCalled)) { return new DecisionTableInterpreter(fixture); } // TODO find Exception throw new Exception("No interpreter found"); }
public static Tables parse(String markup) { Doc doc = new Doc(); String[] tables = markup.split("\\*{4}"); for (String rows : tables) { if (StringUtils.isBlank(rows)) { continue; } Tables table = ( Tables ) doc.addChild(); if ( ! empty(rows)) { table.addChild(Rows.parse(rows)); } } return ( Tables ) doc.firstChild(); }
@Override public Tables newSibling() { return new Tables(); }
public AnnotationTable annotations() { FakeExample example = new Tables(); example.addChild(new Rows()); example.addChild(( Rows ) table.at(0, 0)); FakeSpecification specification = new FakeSpecification(example); interpreter.interpret(specification); prepareRWIE(specification.stats()); return new AnnotationTable(table); }
public String[] parameters() { Action action = Action.parse(row.actionCells(tables.at(0, 0))); return action.arguments(); } }
public Tables row(Object... cells) { addChild(new Rows(cells)); return this; }
@Override public String toString() { return hasChild() ? parts.toMarkup(false) : EMPTY; }
@Test public void testShouldProcessAllRows() throws Exception { tables = parse("[decision table][calculator]\n" + "[a][b][sum?][division?]\n" + "[6][2][8][3]\n" + "[10][5][15][2]"); interpreter.interpret(spec()); assertAnnotatedRight(tables.at(0, 2, 2)); assertAnnotatedRight(tables.at(0, 2, 3)); assertAnnotatedRight(tables.at(0, 3, 2)); assertAnnotatedRight(tables.at(0, 3, 3)); }
@Test public void testFindInterpeterByAliasDefinedInPropertyFileWithUmlauts() { // Prepare Tables tableUmlauts = parse("[Döit]"); // Act Interpreter interpreterUmlauts = selector.selectInterpreter(tableUmlauts); // Check assertThat(interpreterUmlauts, instanceOf(AliasInterpreter.class)); }