package com.codecheck123.dumb_bdd;

import java.util.concurrent.Executors;

import com.codecheck123.dumb_bdd.report.ConsoleReporter;
import com.codecheck123.dumb_bdd.report.Reporter;

public class When extends AbstractBDD {

	private final Given given;
	private final String when;
	private AssertionError assErr;
	
	When(Given given, String bddExpression){
		this.given = given;
		this.when = bddExpression;
	}
	
	public void then(String then, ExpressionRunner runner){
		try{
			evaluateExpression(then, runner);
		}catch(AssertionError e){
			assErr = e;
			throw e;
		}finally{
			Executors.newCachedThreadPool().execute(
					new Runnable() {

						@Override
						public void run() {
							String userStory = given.getUserStory().getStory();
							Reporter reporter = new ConsoleReporter(userStory,given.getAll(),when,then,assErr);
							reporter.write();
						}
					}
			);
		}
	}
}
@@ -424,16 +424,22 @@
 id then(
+final 
 String t
@@ -649,25 +649,8 @@
 () %7B
-%0A%0A%09%09%09%09%09%09@Override
 %0A%09%09%09

mark local variable as final for excess within anonymous