@Override public void setUp(CommandCall commandCall, Evaluator evaluator, ResultRecorder resultRecorder) { httpRequest = parseRequest(commandCall.getElement(), evaluator, resultRecorder); formatRequest(commandCall.getElement(), httpRequest); }
private String getExampleName(CommandCall node) { String exampleName = node.getExpression(); // use the contents of the example if there is no name. if ("".equals(exampleName) && node.getElement().isNamed("td")) { exampleName = node.getElement().getText(); } return exampleName; }
private String getExampleName(CommandCall node) { String exampleName = node.getExpression(); // use the contents of the example if there is no name. if ("".equals(exampleName) && node.getElement().isNamed("td")) { exampleName = node.getElement().getText(); } return exampleName; }
public TableSupport(CommandCall tableCommandCall) { assert tableCommandCall.getElement().isNamed("table"); this.tableCommandCall = tableCommandCall; this.table = new Table(tableCommandCall.getElement()); populateCommandCallByColumnMap(); }
public TableSupport(CommandCall tableCommandCall) { assert tableCommandCall.getElement().isNamed("table"); this.tableCommandCall = tableCommandCall; this.table = new Table(tableCommandCall.getElement()); populateCommandCallByColumnMap(); }
@Override protected void processTrueResult(CommandCall commandCall, ResultRecorder resultRecorder) { resultRecorder.record(Result.FAILURE); String expected = commandCall.getElement().getText(); announceFailure(commandCall.getElement(), expected, "== true"); }
@Override protected void processFalseResult(CommandCall commandCall, ResultRecorder resultRecorder) { resultRecorder.record(Result.SUCCESS); announceSuccess(commandCall.getElement()); }
@Override protected void processTrueResult(CommandCall commandCall, ResultRecorder resultRecorder) { resultRecorder.record(Result.SUCCESS); announceSuccess(commandCall.getElement()); } }
@Override protected void processTrueResult(CommandCall commandCall, ResultRecorder resultRecorder) { resultRecorder.record(Result.SUCCESS); announceSuccess(commandCall.getElement()); } }
@Override public void setUp(CommandCall commandCall, Evaluator evaluator, ResultRecorder resultRecorder) { stripCommandAttribute(commandCall.getElement()); variableName = commandCall.getExpression(); if (!variableName.isEmpty() && !variableName.startsWith("#")) { throw new RuntimeException(variableName + " should start with a #, to be a valid Concordion variable."); } commandCall.getChildren().setUp(evaluator, resultRecorder); }
public List<ListEntry> getListEntries() { List<ListEntry> listEntries = new ArrayList<ListEntry>(); for (int i = 0; i < listCommandCall.getElement().getChildElements().length; i++) { Element listElement = listCommandCall.getElement().getChildElements()[i]; if (listElement.isNamed("li") || listElement.isNamed("ul") || listElement.isNamed("ol")) { listEntries.add(new ListEntry(listElement)); } } return listEntries; }
private Map<Integer, CommandCall> populateCommandCallByColumnMap(Table table, CommandCall tableCommandCall) { Map<Integer, CommandCall> commandCallByColumn = new HashMap<Integer, CommandCall>(); Row headerRow = table.getLastHeaderRow(); for (CommandCall childCall : tableCommandCall.getChildren().asCollection()) { int columnIndex = headerRow.getIndexOfCell(childCall.getElement()); if (columnIndex == -1) { throw new RuntimeException("Commands must be placed on <th> elements when using 'execute' or 'verifyRows' commands on a <table>."); } commandCallByColumn.put(columnIndex, childCall); } return commandCallByColumn; }
public List<ListEntry> getListEntries() { List<ListEntry> listEntries = new ArrayList<ListEntry>(); for (int i = 0; i < listCommandCall.getElement().getChildElements().length; i++) { Element listElement = listCommandCall.getElement().getChildElements()[i]; if (listElement.isNamed("li") || listElement.isNamed("ul") || listElement.isNamed("ol")) { listEntries.add(new ListEntry(listElement)); } } return listEntries; }
private void populateCommandCallByColumnMap() { Row headerRow = getLastHeaderRow(); for (CommandCall childCall : tableCommandCall.getChildren().asCollection()) { int columnIndex = headerRow.getIndexOfCell(childCall.getElement()); if (columnIndex == -1) { throw new RuntimeException("Commands must be placed on <th> elements when using 'execute' or 'verifyRows' commands on a <table>."); } commandCallByColumn.put(columnIndex, childCall); } }
public void execute(CommandCall commandCall, Evaluator evaluator, ResultRecorder resultRecorder, Fixture fixture) { stream.println(commandCall.getElement().getText()); } });
@Override protected void process(CommandCall commandCall, Evaluator evaluator, ResultRecorder resultRecorder, Runnable runnable) { Object savedTextValue = evaluator.getVariable(TEXT_VARIABLE); Object savedHrefValue = evaluator.getVariable(HREF_VARIABLE); try { evaluator.setVariable(TEXT_VARIABLE, commandCall.getElement().getText()); evaluator.setVariable(HREF_VARIABLE, getHref(commandCall.getElement())); runnable.run(); } finally { evaluator.setVariable(TEXT_VARIABLE, savedTextValue); evaluator.setVariable(HREF_VARIABLE, savedHrefValue); } }
public static void setupCommandForExample(CommandCall node, ResultRecorder resultRecorder, String exampleName) { node.getElement().addAttribute("id", exampleName); // let's be really nice and add the implementation status text into the element itself. ImplementationStatusChecker checker = ImplementationStatusChecker.implementationStatusCheckerFor(resultRecorder.getImplementationStatus()); Element fixtureNode = new Element("p"); fixtureNode.appendText(checker.printNoteToString()); node.getElement().prependChild(fixtureNode); }
@Override protected void process(CommandCall commandCall, Evaluator evaluator, ResultRecorder resultRecorder, Runnable runnable) { try { runnable.run(); } catch (FailFastException ffe) { // We get here if a sub-fixture has thrown an exception and we want the fail fast exception to percolate up. rethrowFailFastException(resultRecorder, ffe.getCause()); } catch (Throwable t) { resultRecorder.record(Result.EXCEPTION); announceThrowableCaught(commandCall.getElement(), t, commandCall.getExpression()); rethrowFailFastException(resultRecorder, t); } }
private void normalExecution(CommandCall commandCall, Evaluator evaluator, ResultRecorder resultRecorder, Fixture fixture) { CommandCallList childCommands = commandCall.getChildren(); childCommands.setUp(evaluator, resultRecorder, fixture); evaluator.evaluate(commandCall.getExpression()); childCommands.execute(evaluator, resultRecorder, fixture); announceExecuteCompleted(commandCall.getElement()); childCommands.verify(evaluator, resultRecorder, fixture); }
private void normalExecution(CommandCall commandCall, Evaluator evaluator, ResultRecorder resultRecorder, Fixture fixture) { CommandCallList childCommands = commandCall.getChildren(); childCommands.setUp(evaluator, resultRecorder, fixture); evaluator.evaluate(commandCall.getExpression()); childCommands.execute(evaluator, resultRecorder, fixture); announceExecuteCompleted(commandCall.getElement()); childCommands.verify(evaluator, resultRecorder, fixture); }