ImmutablePipeline implements Pipeline { @Override public PipelineElement execute(final PipelineElement pipelineInput, final ExpressionResolver expressionResolver) { return stageExpressions.stream().reduce( pipelineInput, (element, expression) -> functionExpression.resolve(expression, element, expressionResolver), ImmutablePipeline::combineElements ); } ImmutablePipeline(final FunctionExpression functionExpression, final List<String> stageExpressions); @Override PipelineElement execute(final PipelineElement pipelineInput, final ExpressionResolver expressionResolver); @Override void validate(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString();  }
@Test public void execute() { prepareFunctionExpressionResponses(); final ImmutablePipeline pipeline = new ImmutablePipeline(functionExpression, STAGES); final PipelineElement result = pipeline.execute(PIPELINE_INPUT, expressionResolver); verifyResultEqualsLastResponse(result); verifyFunctionExpressionWasCalledWithIntermediateValues(); }