public XMLSpecification(CommandCall rootCommandNode, List<ExampleCommandCall> examples, List<CommandCall> beforeExamples) { this.rootCommandNode = rootCommandNode; if (!(rootCommandNode.getCommand() instanceof SpecificationCommand)) { throw new IllegalStateException("Expected root command to be a SpecificationCommand"); } specificationCommand = (SpecificationCommand) rootCommandNode.getCommand(); specificationCommand.start(rootCommandNode); specificationDescription = specificationCommand.getSpecificationDescription(rootCommandNode); this.examples = new ArrayList(examples); this.beforeExamples = new ArrayList(beforeExamples); }
public XMLSpecification(CommandCall rootCommandNode, List<ExampleCommandCall> examples, List<CommandCall> beforeExamples) { this.rootCommandNode = rootCommandNode; if (!(rootCommandNode.getCommand() instanceof SpecificationCommand)) { throw new IllegalStateException("Expected root command to be a SpecificationCommand"); } specificationCommand = (SpecificationCommand) rootCommandNode.getCommand(); specificationCommand.start(rootCommandNode); specificationDescription = specificationCommand.getSpecificationDescription(rootCommandNode); this.examples = new ArrayList(examples); this.beforeExamples = new ArrayList(beforeExamples); }
protected CommandCall duplicateCommandForDifferentElement(CommandCall commandCall, Element element) { return new CommandCall( null, commandCall.getCommand(), element, commandCall.getExpression(), commandCall.getResource()); }
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); } }
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); } }
protected CommandCall duplicateCommandForDifferentElement(CommandCall commandCall, Element element) { return new CommandCall( null, commandCall.getCommand(), element, commandCall.getExpression(), commandCall.getResource()); }
public void processNode(CommandCall node, Evaluator evaluator, ResultRecorder resultRecorder, Fixture fixture) { if (!node.getChildren().isEmpty()) { for (CommandCall before: beforeExamples) { SummarizingResultRecorder beforeResultRecorder = new SummarizingResultRecorder(); beforeResultRecorder.setSpecificationDescription("Running before for example " + node.getExpression()); before.getCommand().execute(before, evaluator, beforeResultRecorder, fixture); String errorText = null; if (beforeResultRecorder.hasExceptions()) { errorText = SimpleFormatter.format("Exceptions occurred in the 'before' example in '%s'. See the output specification for details.\n", specificationDescription ); } else if (beforeResultRecorder.getTotalCount() > 0) { errorText = SimpleFormatter.format("Assertions were made in the 'before' example in '%s'.\n" + "Assertions are not supported in the 'before' example.\n", specificationDescription ); } if (errorText != null) { System.err.println(errorText); throw new ConcordionAssertionError(errorText, beforeResultRecorder); } } } node.execute(evaluator, resultRecorder, fixture); }
public void processNode(CommandCall node, Evaluator evaluator, ResultRecorder resultRecorder, Fixture fixture) { if (!node.getChildren().isEmpty()) { for (CommandCall before: beforeExamples) { SummarizingResultRecorder beforeResultRecorder = new SummarizingResultRecorder(); beforeResultRecorder.setSpecificationDescription("Running before for example " + node.getExpression()); before.getCommand().execute(before, evaluator, beforeResultRecorder, fixture); String errorText = null; if (beforeResultRecorder.hasExceptions()) { errorText = SimpleFormatter.format("Exceptions occurred in the 'before' example in '%s'. See the output specification for details.\n", specificationDescription ); } else if (beforeResultRecorder.getTotalCount() > 0) { errorText = SimpleFormatter.format("Assertions were made in the 'before' example in '%s'.\n" + "Assertions are not supported in the 'before' example.\n", specificationDescription ); } if (errorText != null) { System.err.println(errorText); throw new ConcordionAssertionError(errorText, beforeResultRecorder); } } } node.execute(evaluator, resultRecorder, fixture); }