public List<String> getExampleNames() { List<String> examples = new ArrayList<String>(); if (hasExampleCommandNodes()) { if (!rootCommandNode.getChildren().isEmpty()) { // Add the main spec first to increase the chance that it will be run first by jUnit. examples.add(OUTER_EXAMPLE_NAME); } for (ExampleCommandCall exampleCall : this.examples) { examples.add(exampleCall.getExampleName()); } } return examples; }
public List<String> getExampleNames() { List<String> examples = new ArrayList<String>(); if (hasExampleCommandNodes()) { if (!rootCommandNode.getChildren().isEmpty()) { // Add the main spec first to increase the chance that it will be run first by jUnit. examples.add(OUTER_EXAMPLE_NAME); } for (ExampleCommandCall exampleCall : this.examples) { examples.add(exampleCall.getExampleName()); } } return examples; }
@Override public void verify(CommandCall commandCall, Evaluator evaluator, ResultRecorder resultRecorder) { commandCall.getChildren().verify(evaluator, resultRecorder); cleanUp(); }
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; }
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; }
@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); }
@Override public void execute(CommandCall commandCall, Evaluator evaluator, ResultRecorder resultRecorder) { commandCall.getChildren().execute(evaluator, resultRecorder); if (!variableName.isEmpty()) { evaluator.setVariable(variableName, requestCommand.getActualResult()); } }
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); } }
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 modifyTree(List<ExampleCommandCall> examples, List<CommandCall> beforeExamples) { this.getCommand().modifyCommandCallTree(this, examples, beforeExamples); List<CommandCall> childrenCopy = new ArrayList(getChildren().asCollection()); for (CommandCall childCall: childrenCopy) { childCall.modifyTree(examples, beforeExamples); } }
@Override public void execute(CommandCall commandCall, Evaluator evaluator, ResultRecorder resultRecorder, Fixture fixture) { // bypass normal execution if the modification required it. if (commandCall.bypassExecution()) { commandCall.getChildren().execute(evaluator, resultRecorder, fixture); return; } normalExecution(commandCall, evaluator, resultRecorder, fixture); }
public void modifyTree(List<ExampleCommandCall> examples, List<CommandCall> beforeExamples) { this.getCommand().modifyCommandCallTree(this, examples, beforeExamples); List<CommandCall> childrenCopy = new ArrayList(getChildren().asCollection()); for (CommandCall childCall: childrenCopy) { childCall.modifyTree(examples, beforeExamples); } }
@Override public void execute(CommandCall commandCall, Evaluator evaluator, ResultRecorder resultRecorder, Fixture fixture) { // bypass normal execution if the modification required it. if (commandCall.bypassExecution()) { commandCall.getChildren().execute(evaluator, resultRecorder, fixture); return; } normalExecution(commandCall, evaluator, resultRecorder, fixture); }
public void transferToParent(CommandCall parent) { if (getParent() != null) { getParent().getChildren().remove(this); } this.parent = parent; if (parent != null) { parent.appendChild(this); } }
public void transferToParent(CommandCall parent) { if (getParent() != null) { getParent().getChildren().remove(this); } this.parent = parent; if (parent != null) { parent.appendChild(this); } }
private void reportSurplusRows(Fixture fixture) { for (Object surplusRow : actualRows) { evaluator.setVariable(loopVariableName, surplusRow); Row detailRow = tableSupport.addDetailRow(); announceSurplusRow(detailRow.getElement()); tableSupport.copyCommandCallsTo(detailRow); commandCall.getChildren().verify(evaluator, resultRecorder, fixture); } } }
private void reportSurplusRows(Fixture fixture) { for (Object surplusRow : actualRows) { evaluator.setVariable(loopVariableName, surplusRow); Row detailRow = tableSupport.addDetailRow(); announceSurplusRow(detailRow.getElement()); tableSupport.copyCommandCallsTo(detailRow); commandCall.getChildren().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); }
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); }
@Override public void execute(CommandCall commandCall, Evaluator evaluator, ResultRecorder resultRecorder, Fixture fixture) { if (specificationDescriber != null) { resultRecorder.setSpecificationDescription(getSpecificationDescription(commandCall)); } try { announceBeforeOuterExampleEvent(commandCall.getElement(), (SummarizingResultRecorder) resultRecorder, fixture); commandCall.getChildren().processSequentially(evaluator, resultRecorder, fixture); } catch (FailFastException e) { // Ignore - it'll be re-thrown later if necessary. } finally { announceAfterOuterExampleEvent(commandCall.getElement(), (SummarizingResultRecorder) resultRecorder, fixture); } }