public StatementExecutor(SlimExecutionContext context) { this.context = context; executorChain.add(new FixtureMethodExecutor(this.context)); executorChain.add(new SystemUnderTestMethodExecutor(this.context)); executorChain.add(new LibraryMethodExecutor(this.context)); addSlimHelperLibraryToLibraries(); }
@Override public Object callAndAssign(String variable, String instanceName, String methodName, Object... args) throws SlimException { try { MethodExecutionResult result = getMethodExecutionResult(instanceName, methodName, args); context.setVariable(variable, result); checkForPatternOfFixturesHandlingSymbols(variable); return result.returnValue(); } catch (Throwable e) { // NOSONAR checkExceptionForStop(e); throw new SlimException(e); } }
@Override public Object call(String instanceName, String methodName, Object... args) throws SlimException { try { return getMethodExecutionResult(instanceName, methodName, args).returnValue(); } catch (Throwable e) { // NOSONAR checkExceptionForStop(e); throw new SlimException(e); } }
@Override public void assign(String name, Object value) { context.setVariable(name, value); checkForPatternOfFixturesHandlingSymbols(name); }
@Override public StatementExecutorInterface getStatementExecutor() { StatementExecutorInterface statementExecutor = new StatementExecutor(new SlimExecutionContext(interaction)); if (timeout != null) { statementExecutor = StatementTimeoutExecutor.decorate(statementExecutor, timeout); } return statementExecutor; }
private MethodExecutionResult getMethodExecutionResult(String instanceName, String methodName, Object... args) throws Throwable { MethodExecutionResults results = new MethodExecutionResults(); Boolean ignoreSymbols = ignoreSymbols( instanceName, methodName); if (!ignoreSymbols){ args = context.replaceSymbols(args); } for (MethodExecutor anExecutorChain : executorChain) { MethodExecutionResult result = anExecutorChain.execute(instanceName, methodName, args); if (result.hasResult()) { return result; } results.add(result); } return results.getFirstResult(); }
@Override public void create(String instanceName, String className, Object... args) throws SlimException { try { context.create(instanceName, className, args); // TODO Hack for supporting SlimHelperLibrary, please remove. Object newInstance = context.getInstance(instanceName); if (newInstance instanceof StatementExecutorConsumer) { ((StatementExecutorConsumer) newInstance).setStatementExecutor(this); } } catch (SlimError e) { throw new SlimException(format("%s[%d]", className, args.length), e, SlimServer.COULD_NOT_INVOKE_CONSTRUCTOR, true); } catch (IllegalArgumentException e) { throw new SlimException(format("%s[%d]", className, args.length), e, SlimServer.COULD_NOT_INVOKE_CONSTRUCTOR, true); } catch (InvocationTargetException e) { checkExceptionForStop(e.getTargetException()); throw new SlimException(e.getTargetException(), true); } catch (Throwable e) { // NOSONAR checkExceptionForStop(e); throw new SlimException(e); } }
@Override public Object call(String instanceName, String methodName, Object... args) throws SlimException { try { return getMethodExecutionResult(instanceName, methodName, args).returnValue(); } catch (Throwable e) { // NOSONAR checkExceptionForStop(e); throw new SlimException(e); } }
@Override public void assign(String name, Object value) { context.setVariable(name, value); checkForPatternOfFixturesHandlingSymbols(name); }
@Override public StatementExecutorInterface getStatementExecutor() { StatementExecutorInterface statementExecutor = new StatementExecutor(new SlimExecutionContext(interaction)); if (timeout != null) { statementExecutor = StatementTimeoutExecutor.decorate(statementExecutor, timeout); } return statementExecutor; }
private MethodExecutionResult getMethodExecutionResult(String instanceName, String methodName, Object... args) throws Throwable { MethodExecutionResults results = new MethodExecutionResults(); Boolean ignoreSymbols = ignoreSymbols( instanceName, methodName); if (!ignoreSymbols){ args = context.replaceSymbols(args); } for (MethodExecutor anExecutorChain : executorChain) { MethodExecutionResult result = anExecutorChain.execute(instanceName, methodName, args); if (result.hasResult()) { return result; } results.add(result); } return results.getFirstResult(); }
@Override public void create(String instanceName, String className, Object... args) throws SlimException { try { context.create(instanceName, className, args); // TODO Hack for supporting SlimHelperLibrary, please remove. Object newInstance = context.getInstance(instanceName); if (newInstance instanceof StatementExecutorConsumer) { ((StatementExecutorConsumer) newInstance).setStatementExecutor(this); } } catch (SlimError e) { throw new SlimException(format("%s[%d]", className, args.length), e, SlimServer.COULD_NOT_INVOKE_CONSTRUCTOR, true); } catch (IllegalArgumentException e) { throw new SlimException(format("%s[%d]", className, args.length), e, SlimServer.COULD_NOT_INVOKE_CONSTRUCTOR, true); } catch (InvocationTargetException e) { checkExceptionForStop(e.getTargetException()); throw new SlimException(e.getTargetException(), true); } catch (Throwable e) { // NOSONAR checkExceptionForStop(e); throw new SlimException(e); } }
@Override public Object callAndAssign(String variable, String instanceName, String methodName, Object... args) throws SlimException { try { MethodExecutionResult result = getMethodExecutionResult(instanceName, methodName, args); context.setVariable(variable, result); checkForPatternOfFixturesHandlingSymbols(variable); return result.returnValue(); } catch (Throwable e) { // NOSONAR checkExceptionForStop(e); throw new SlimException(e); } }
public StatementExecutor(SlimExecutionContext context) { this.context = context; executorChain.add(new FixtureMethodExecutor(this.context)); executorChain.add(new SystemUnderTestMethodExecutor(this.context)); executorChain.add(new LibraryMethodExecutor(this.context)); addSlimHelperLibraryToLibraries(); }