package bytecode.simplifyalgo;

import static org.junit.Assert.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;

import org.junit.BeforeClass;
import org.junit.Test;
import org.objectweb.asm.Type;

import de.dhbwstuttgart.bytecode.TPHExtractor;
import de.dhbwstuttgart.bytecode.constraint.ExtendsConstraint;
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation;
import de.dhbwstuttgart.bytecode.utilities.ConstraintsFinder;
import de.dhbwstuttgart.bytecode.utilities.MethodAndTPH;
import de.dhbwstuttgart.bytecode.utilities.Simplify;
import de.dhbwstuttgart.typedeployment.TypeInsertPlacer;

/**
 * 
 * @author Fayez Abu Alia
 *
 */
public class FinderTest {

	@Test
	public void testM1() {
		List<TPHConstraint> allCons = new ArrayList<>();
		// L < M
		TPHConstraint c1 = new ExtendsConstraint("L", "M", Relation.EXTENDS);
		// L < N
		TPHConstraint c2 = new ExtendsConstraint("L", "N", Relation.EXTENDS);
		// M < O
		TPHConstraint c3 = new ExtendsConstraint("M", "O", Relation.EXTENDS);
		// M < P
		TPHConstraint c4 = new ExtendsConstraint("M", "P", Relation.EXTENDS);

		allCons.add(c1);
		allCons.add(c2);
		allCons.add(c3);
		allCons.add(c4);
		List<List<TPHConstraint>> res = new ArrayList<>();
		List<TPHConstraint> l1 = new ArrayList<>();
		List<TPHConstraint> l2 = new ArrayList<>();
		
		l1.add(c1);
		l1.add(c2);
		
		l2.add(c3);
		l2.add(c4);
		
		res.add(l1);
		res.add(l2);
		
		ConstraintsFinder finder = new ConstraintsFinder(allCons);
		
		assertEquals(finder.findConstraints(), res);
	}

}
