// Path: src/main/java/fr/inria/gforge/spoon/assertgenerator/Logger.java
// public class Logger {
// 
// 	public static Map<String, Object> observations = new HashMap<>();
// 
// 	public static void observe(String name, Object object) {
// 		observations.put(name, object);
// 	}
// }
// 
// Path: src/main/java/fr/inria/gforge/spoon/assertgenerator/Util.java
// public static List<CtMethod> getGetters(CtLocalVariable localVariable) {
// 	return ((Set<CtMethod<?>>) localVariable.getType().getDeclaration().getMethods()).stream()
// 			.filter(method -> method.getParameters().isEmpty() &&
// 					method.getType() != localVariable.getFactory().Type().VOID_PRIMITIVE &&
// 					(method.getSimpleName().startsWith("get") ||
// 							method.getSimpleName().startsWith("is"))
// 			).collect(Collectors.toList());
// }
// 
// Path: src/main/java/fr/inria/gforge/spoon/assertgenerator/Util.java
// public static String getKey(CtMethod method) {
// 	return method.getParent(CtClass.class).getSimpleName() + "#" + method.getSimpleName();
// }
// 
// Path: src/main/java/fr/inria/gforge/spoon/assertgenerator/Util.java
// public static CtInvocation invok(CtMethod method, CtLocalVariable localVariable) {
// 	final CtExecutableReference reference = method.getReference();
// 	final CtVariableAccess variableRead = method.getFactory().createVariableRead(localVariable.getReference(), false);
// 	return method.getFactory().createInvocation(variableRead, reference);
// }


import fr.inria.gforge.spoon.assertgenerator.Logger;
import org.junit.Assert;
import spoon.reflect.code.CtExpression;
import spoon.reflect.code.CtInvocation;
import spoon.reflect.code.CtLocalVariable;
import spoon.reflect.code.CtTypeAccess;
import spoon.reflect.declaration.CtMethod;
import spoon.reflect.factory.Factory;
import spoon.reflect.reference.CtExecutableReference;
import java.util.List;
import static fr.inria.gforge.spoon.assertgenerator.Util.getGetters;
import static fr.inria.gforge.spoon.assertgenerator.Util.getKey;
import static fr.inria.gforge.spoon.assertgenerator.Util.invok;
package fr.inria.gforge.spoon.assertgenerator.workflow;




/**
 * Created by Benjamin DANGLOT
 * benjamin.danglot@inria.fr
 * on 22/06/17
 */
public class AssertionAdder {

	private Factory factory;

	public AssertionAdder(Factory factory) {
		this.factory = factory;
	}

	@SuppressWarnings("unchecked")
	public void addAssertion(CtMethod<?> testMethod, List<CtLocalVariable> ctLocalVariables) {
		ctLocalVariables.forEach(ctLocalVariable -> this.addAssertion(testMethod, ctLocalVariable));
		System.out.println(testMethod);
	}

	@SuppressWarnings("unchecked")
	void addAssertion(CtMethod testMethod, CtLocalVariable localVariable) {
		List<CtMethod> getters =
// Path: src/main/java/fr/inria/gforge/spoon/assertgenerator/Logger.java
// public class Logger {
// 
// 	public static Map<String, Object> observations = new HashMap<>();
// 
// 	public static void observe(String name, Object object) {
// 		observations.put(name, object);
// 	}
// }
// 
// Path: src/main/java/fr/inria/gforge/spoon/assertgenerator/Util.java
// public static List<CtMethod> getGetters(CtLocalVariable localVariable) {
// 	return ((Set<CtMethod<?>>) localVariable.getType().getDeclaration().getMethods()).stream()
// 			.filter(method -> method.getParameters().isEmpty() &&
// 					method.getType() != localVariable.getFactory().Type().VOID_PRIMITIVE &&
// 					(method.getSimpleName().startsWith("get") ||
// 							method.getSimpleName().startsWith("is"))
// 			).collect(Collectors.toList());
// }
// 
// Path: src/main/java/fr/inria/gforge/spoon/assertgenerator/Util.java
// public static String getKey(CtMethod method) {
// 	return method.getParent(CtClass.class).getSimpleName() + "#" + method.getSimpleName();
// }
// 
// Path: src/main/java/fr/inria/gforge/spoon/assertgenerator/Util.java
// public static CtInvocation invok(CtMethod method, CtLocalVariable localVariable) {
// 	final CtExecutableReference reference = method.getReference();
// 	final CtVariableAccess variableRead = method.getFactory().createVariableRead(localVariable.getReference(), false);
// 	return method.getFactory().createInvocation(variableRead, reference);
// }


// Path: src/main/java/fr/inria/gforge/spoon/assertgenerator/workflow/AssertionAdder.java
import fr.inria.gforge.spoon.assertgenerator.Logger;
import org.junit.Assert;
import spoon.reflect.code.CtExpression;
import spoon.reflect.code.CtInvocation;
import spoon.reflect.code.CtLocalVariable;
import spoon.reflect.code.CtTypeAccess;
import spoon.reflect.declaration.CtMethod;
import spoon.reflect.factory.Factory;
import spoon.reflect.reference.CtExecutableReference;
import java.util.List;
import static fr.inria.gforge.spoon.assertgenerator.Util.getGetters;
import static fr.inria.gforge.spoon.assertgenerator.Util.getKey;
import static fr.inria.gforge.spoon.assertgenerator.Util.invok;

package fr.inria.gforge.spoon.assertgenerator.workflow;




/**
 * Created by Benjamin DANGLOT
 * benjamin.danglot@inria.fr
 * on 22/06/17
 */
public class AssertionAdder {

	private Factory factory;

	public AssertionAdder(Factory factory) {
		this.factory = factory;
	}

	@SuppressWarnings("unchecked")
	public void addAssertion(CtMethod<?> testMethod, List<CtLocalVariable> ctLocalVariables) {
		ctLocalVariables.forEach(ctLocalVariable -> this.addAssertion(testMethod, ctLocalVariable));
		System.out.println(testMethod);
	}

	@SuppressWarnings("unchecked")
	void addAssertion(CtMethod testMethod, CtLocalVariable localVariable) {
		List<CtMethod> getters =
				getGetters(localVariable);