private void annotateException(Example row, Exception e) { LOG.trace(ENTRY_WITH_TWO, row.toString(), e.toString()); Example newLastCell = row.addChild(); newLastCell.annotate(Annotations.exception(e)); LOG.trace(EXIT); }
@Override public void call(Result result) { annotatable.annotate(Annotations.exception(result.getException())); } }
protected void doCell(Column column, Example cell) { LOG.debug(ENTRY_WITH_TWO, column.toString(), cell.toString()); try { stats.tally(column.doCell(cell)); } catch (IllegalArgumentException e) { cell.annotate(exception(e)); stats.exception(); LOG.error(LOG_ERROR, e); } catch (InvocationTargetException e) { cell.annotate(exception(e)); stats.exception(); LOG.error(LOG_ERROR, e); } catch (IllegalAccessException e) { cell.annotate(exception(e)); stats.exception(); LOG.error(LOG_ERROR, e); } LOG.debug(EXIT); } }
private Column parseColumn(Example header) { LOG.trace(ENTRY_WITH, header.toString()); try { Column parsedColumn = HeaderForm.parse(header.getContent()).selectColumn(fixture); LOG.trace(EXIT_WITH, parsedColumn); return parsedColumn; } catch (NoSuchMessageException e) { header.annotate(exception(e)); stats.exception(); LOG.error(LOG_ERROR, e); Column nullColumn = new NullColumn(); LOG.trace(EXIT_WITH, nullColumn); return nullColumn; } }
private void doCell(Column column, Example cell) { LOG.trace(ENTRY_WITH_TWO, column.toString(), cell.toString()); try { stats.tally(column.doCell(cell)); } catch (InvocationTargetException e) { cell.annotate(exception(e)); stats.exception(); LOG.error(LOG_ERROR, e); } catch (IllegalAccessException e) { cell.annotate(exception(e)); stats.exception(); LOG.error(LOG_ERROR, e); } catch (IllegalArgumentException e) { cell.annotate(exception(e)); stats.exception(); LOG.error(LOG_ERROR, e); } LOG.trace(EXIT); } }
private Message parseEnterRowMessage(Example table) { LOG.trace(ENTRY_WITH, table.toString()); for (Method method : fixture.getTarget().getClass().getMethods()) { if (method.isAnnotationPresent(EnterRow.class)) { Message staticInvocation = new StaticInvocation(fixture.getTarget(), method); LOG.trace(EXIT_WITH, staticInvocation); return staticInvocation; } } try { Message checkEnterRow = fixture.check("enterRow"); LOG.trace(EXIT_WITH, checkEnterRow.toString()); return checkEnterRow; } catch (NoSuchMessageException e) { table.at(0, 1, 0).annotate(exception(e)); stats.exception(); LOG.trace(EXIT + " with null"); return null; } }
private void printErrorInCell(Example example, Exception e) { example.annotate(Annotations.exception(e)); }
private Column parseColumn(Example header) { LOG.trace(ENTRY_WITH, header.toString()); try { Column parsedColumn = HeaderForm.parse(header.getContent()).selectColumn(fixture); LOG.trace(EXIT_WITH, parsedColumn.toString()); return parsedColumn; } catch (NoSuchMessageException e) { header.annotate(exception(e)); stats.exception(); LOG.error(LOG_ERROR, e); Column nullColumn = new NullColumn(); LOG.trace(EXIT_WITH, nullColumn.toString()); return nullColumn; } }
@Override public void call(final Result result) { if (result.isException()) { statistics.exception(); annotable.annotate(Annotations.exception(result.getException())); } } }
private Row instantiateRow(Example row) { Type<Row> rowClass = loadRowType(identifier(row)); try { return rowClass.newInstance(fixture); } catch (Throwable throwable) { LOG.error(LOG_ERROR, throwable); row.firstChild().annotate(Annotations.exception(throwable)); return new SkipRow(); } }
private Row instantiateRow(Example row) { Type<Row> rowClass = loadRowType(identifier(row)); try { return rowClass.newInstance(fixture); } catch (Throwable throwable) { LOG.error(LOG_ERROR, throwable); row.firstChild().annotate(Annotations.exception(throwable)); return new SkipRow(); } }
@Override public void call(Result result) { if (result.isException() && ! shouldIgnore(result.getException())) { statistics.exception(); annotable.annotate(Annotations.exception(result.getException())); } }
@Override public void interpret(Specification table) { Example row = table.nextExample(); Example anchor = row.firstChild().lastSibling(); Action action = Action.parse(actionCells(row)); try { Call call = action.checkAgainst(fixture); call.will(Annotate.ignored(anchor.addSibling())); call.execute(); } catch (InvocationTargetException e) { LOG.error(LOG_ERROR, e); reportException(table); CollectionUtil.first(keywordCells(row)).annotate(Annotations.exception(e)); } catch (IllegalAccessException e) { LOG.error(LOG_ERROR, e); reportException(table); CollectionUtil.first(keywordCells(row)).annotate(Annotations.exception(e)); } }
@Override public void interpret(Specification table) { Example row = table.nextExample(); Example anchor = row.firstChild().lastSibling(); Action action = Action.parse(actionCells(row)); try { Call call = action.checkAgainst(fixture); call.will(Annotate.ignored(anchor.addSibling())); call.execute(); } catch (Exception e) { LOG.error(LOG_ERROR, e); reportException(table); CollectionUtil.first(keywordCells(row)).annotate(Annotations.exception(e)); } }
@Override public Interpreter selectInterpreter(Example table) { Example cells = table.at(0, 0, 0); if (cells == null) { return new SkipInterpreter(); } String interpreterName = cells.at(0).getContent(); String[] fixtureAndParameters = fixtureAndParams(cells.at(1)); try { Object[] args = isEmpty(fixtureAndParameters) ? toArray(systemUnderDevelopment) : toArray( selectFixture(fixtureAndParameters)); return LivingDoc.getInterpreter(interpreterName, args); } catch (Throwable t) { LOG.error(LOG_ERROR, t); cells.at(0).annotate(Annotations.exception(t)); return new SkipInterpreter(new Statistics(0, 0, 1, 0)); } }
@Override public void call(Result result) { if (result.isException()) { statistics.exception(); annotable.annotate(Annotations.exception(result.getException())); } else if (result.getActual() instanceof Boolean) { Boolean actual = ( Boolean ) result.getActual(); if (actual) { statistics.right(); annotable.annotate(Annotations.right()); } else { statistics.wrong(); annotable.annotate(Annotations.wrong()); } } } }
@Override public void interpret(Specification table) { Example row = table.nextExample(); Example expectedCell = row.firstChild().lastSibling(); Action action = Action.parse(actionCells(row)); try { Call call = action.checkAgainst(fixture); call.expect(expectedCell.getContent()); call.will(Annotate.right(expectedCell)).when(ResultIs.right()); call.will(Annotate.wrongWithDetails(expectedCell)).when(ResultIs.wrong()); call.will(Annotate.exception(CollectionUtil.first(keywordCells(row)))).when(ResultIs.exception()); call.will(tallyStatistics(table)); call.execute(); } catch (InvocationTargetException e) { LOG.error(LOG_ERROR, e); reportException(table); CollectionUtil.first(keywordCells(row)).annotate(Annotations.exception(e)); } catch (IllegalAccessException e) { LOG.error(LOG_ERROR, e); reportException(table); CollectionUtil.first(keywordCells(row)).annotate(Annotations.exception(e)); } }
@Override public void interpret(Specification table) { Example row = table.nextExample(); Example accept = row.firstChild(); Action action = Action.parse(actionCells(row)); try { Call call = action.checkAgainst(fixture); call.expect(ShouldBe.TRUE); call.will(Annotate.right(accept)).when(ResultIs.right()); call.will(Annotate.wrong(accept)).when(ResultIs.wrong()); call.will(Annotate.exception(accept)).when(ResultIs.exception()); call.will(tallyStatistics(table)); call.execute(); } catch (Exception e) { LOG.error(LOG_ERROR, e); reportException(table); CollectionUtil.first(keywordCells(row)).annotate(Annotations.exception(e)); } }
@Override public void interpret(Specification table) { Example row = table.nextExample(); Example expectedCell = row.firstChild().lastSibling(); Action action = Action.parse(actionCells(row)); try { Call call = action.checkAgainst(fixture); call.expect(expectedCell.getContent()); call.will(Annotate.right(expectedCell)).when(ResultIs.right()); call.will(Annotate.wrongWithDetails(expectedCell)).when(ResultIs.wrong()); call.will(Annotate.exception(CollectionUtil.first(keywordCells(row)))).when(ResultIs.exception()); call.will(tallyStatistics(table)); call.execute(); } catch (Exception e) { LOG.error(LOG_ERROR, e); reportException(table); CollectionUtil.first(keywordCells(row)).annotate(Annotations.exception(e)); } }
@Override public void interpret(Specification table) { Example row = table.nextExample(); Example reject = row.firstChild(); Action action = Action.parse(actionCells(row)); try { Call call = action.checkAgainst(fixture); call.expect(ShouldBe.either(FALSE).or(instanceOf(Exception.class))); call.will(Annotate.right(reject)).when(ResultIs.right()); call.will(Annotate.wrong(reject)).when(ResultIs.wrong()); call.will(Annotate.exception(CollectionUtil.first(keywordCells(row)))).when(ResultIs.exception()); call.will(tallyStatistics(table)); call.execute(); } catch (Exception e) { LOG.error(LOG_ERROR, e); reportException(table); CollectionUtil.first(keywordCells(row)).annotate(Annotations.exception(e)); } }