package strucTypes5;

import de.dhbwstuttgart.parser.JavaTXParser;
import de.dhbwstuttgart.strucTypes5.algo.TypeExpr;
import de.dhbwstuttgart.strucTypes5.assumptions.AssumptionAbstract;
import de.dhbwstuttgart.strucTypes5.assumptions.AssumptionMakerGlobal;
import de.dhbwstuttgart.strucTypes5.assumptions.AssumptionMakerLocal;
import de.dhbwstuttgart.strucTypes5.assumptions.AssumptionMap;
import de.dhbwstuttgart.strucTypes5.ausgabe.Class2String;
import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarStore;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.SourceFile;
import org.junit.Test;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

/**
 * Dieser Test prï¿½ft nur, ob .java-Dateien fehlerfrei geparst werden. Der
 * dabei erstellte Syntaxbaum wird nicht kontrolliert.
 * 
 * @author janulrich
 *
 */
public class NewOperatorTest {
	private static final String rootDirectory = System.getProperty("user.dir") + "/test/strucTypes5/";

	@Test
	public void run() {


		List<String> filenames = new ArrayList<String>();
		filenames.add("NewOperatorTest.jav");

		JavaTXParser parser = new JavaTXParser();
		try {
			for (String filename : filenames) {

				System.out.println("Teste: " + filename);

				SourceFile sf = parser.parse(new File(rootDirectory + filename));

				SourceFile sfdebug = sf;


				Class2String class2String = new Class2String();
				String s = class2String.generateStringTPH(sf.getClasses().get(0));
				System.out.println(s);

				ClassOrInterface classMain = sf.getClasses().get(0);


				TypeVarStore tvs = new TypeVarStore();

				AssumptionMakerGlobal assumptionMakerGlobal = new AssumptionMakerGlobal(classMain,tvs);
				AssumptionMakerLocal assumptionMakerLocal = new AssumptionMakerLocal(classMain.getMethods().get(0), tvs);
				List<AssumptionAbstract> assumptionAbstracts = new ArrayList<>();
				AssumptionMap assumptionMap = new AssumptionMap();
				assumptionMap.addAll(assumptionAbstracts);

				TypeExpr typeExpr = new TypeExpr(assumptionMap,classMain.getMethods().get(0) ,tvs);
				System.out.println(typeExpr.getResultConstraints());

				Class2String class1String = new Class2String();
				String s2 = class1String.generateStringTypeVars(sf.getClasses().get(0), tvs);
				System.out.println(s2);







			}

		} catch (Exception exc) {
			exc.printStackTrace();
			fail();
		}
		assertTrue("Tests durchlaufen", filenames.size() > 0);
	}
}
