diff --git a/src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java b/src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java index a9ab760e..b6eb41ce 100644 --- a/src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java +++ b/src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java @@ -31,7 +31,7 @@ public class FamilyOfGeneratedGenericsTest extends TestCase { /* MethodConstraints should be the same as the input constraint - *//* + */ List methodConstraints = FamilyOfGeneratedGenerics.getMethodConstraints(inputConstraints, tphPositions); assertTrue(methodConstraints.size() == 1); assertTrue(methodConstraints.get(0).getLeft().equals("B")); @@ -39,7 +39,7 @@ public class FamilyOfGeneratedGenericsTest extends TestCase { } public void testClassField(){ - *//* + /* class Example{ A f; B fReturn(){ @@ -47,18 +47,20 @@ public class FamilyOfGeneratedGenericsTest extends TestCase { } } gives constraint: A <. B, which is a class constraint - *//* + */ List inputConstraints = new ArrayList<>(); inputConstraints.add(new TPHConstraint("A", "B", TPHConstraint.Relation.EXTENDS)); HashMap> tphPositions = new HashMap<>(); - tphPositions.put("A", PositionFinder.Position.FIELD); - tphPositions.put("B", PositionFinder.Position.METHOD); + PairTphMethod posOfA = new PairTphMethod<>(PositionFinder.Position.FIELD, null); + tphPositions.put("A", posOfA); + PairTphMethod posOfB = new PairTphMethod<>(PositionFinder.Position.METHOD, "fReturn"); + tphPositions.put("B", posOfB); - *//* + /* ClassConstraints should not be the same as the input constraint - *//* + */ List classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(inputConstraints, tphPositions); System.out.println(classConstraints); assertTrue(classConstraints.size() == 2); @@ -67,7 +69,7 @@ public class FamilyOfGeneratedGenericsTest extends TestCase { } public void testSecondLineOfClassConstraints() { - *//* + /* class Example() { A a; B b = a; @@ -81,7 +83,7 @@ public class FamilyOfGeneratedGenericsTest extends TestCase { return e; } } - *//* + */ List inputConstraints = new ArrayList<>(); inputConstraints.add(new TPHConstraint("A", "B", TPHConstraint.Relation.EXTENDS)); @@ -91,12 +93,19 @@ public class FamilyOfGeneratedGenericsTest extends TestCase { inputConstraints.add(new TPHConstraint("E", "D", TPHConstraint.Relation.EXTENDS)); HashMap> tphPositions = new HashMap<>(); - tphPositions.put("A", PositionFinder.Position.FIELD); - tphPositions.put("B", PositionFinder.Position.FIELD); - tphPositions.put("C", PositionFinder.Position.METHOD); - tphPositions.put("F", PositionFinder.Position.METHOD); - tphPositions.put("D", PositionFinder.Position.METHOD); - tphPositions.put("E", PositionFinder.Position.METHOD); + PairTphMethod posOfA = new PairTphMethod<>(PositionFinder.Position.FIELD, null); + PairTphMethod posOfB = new PairTphMethod<>(PositionFinder.Position.FIELD, null); + PairTphMethod posOfC = new PairTphMethod<>(PositionFinder.Position.METHOD, "anyMethod"); + PairTphMethod posOfD = new PairTphMethod<>(PositionFinder.Position.METHOD, "otherMethod"); + PairTphMethod posOfE = new PairTphMethod<>(PositionFinder.Position.METHOD, "otherMethod"); + PairTphMethod posOfF = new PairTphMethod<>(PositionFinder.Position.METHOD, "anyMethod"); + + tphPositions.put("A", posOfA); + tphPositions.put("B", posOfB); + tphPositions.put("C", posOfC); + tphPositions.put("F", posOfF); + tphPositions.put("D", posOfD); + tphPositions.put("E", posOfE); List classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(inputConstraints, tphPositions); System.out.println(classConstraints); @@ -106,7 +115,7 @@ public class FamilyOfGeneratedGenericsTest extends TestCase { } public void testTPHsAndGenerics() { - *//* + /* class TPHsAndGenerics { Fun1 id = x -> x; C id2 (D x) { @@ -120,7 +129,7 @@ public class FamilyOfGeneratedGenericsTest extends TestCase { return b; } } - *//* + */ List inputConstraints = new ArrayList<>(); inputConstraints.add(new TPHConstraint("A","B", TPHConstraint.Relation.EXTENDS)); @@ -132,23 +141,34 @@ public class FamilyOfGeneratedGenericsTest extends TestCase { inputConstraints.add(new TPHConstraint("J","H", TPHConstraint.Relation.EXTENDS)); HashMap> tphPositions = new HashMap<>(); - tphPositions.put("A", PositionFinder.Position.FIELD); - tphPositions.put("B", PositionFinder.Position.FIELD); - tphPositions.put("C", PositionFinder.Position.METHOD); - tphPositions.put("D", PositionFinder.Position.METHOD); - tphPositions.put("E", PositionFinder.Position.METHOD); - tphPositions.put("F", PositionFinder.Position.METHOD); - tphPositions.put("G", PositionFinder.Position.METHOD); - tphPositions.put("H", PositionFinder.Position.METHOD); - tphPositions.put("I", PositionFinder.Position.METHOD); - tphPositions.put("J", PositionFinder.Position.METHOD); + PairTphMethod posOfA = new PairTphMethod<>(PositionFinder.Position.FIELD, null); + PairTphMethod posOfB = new PairTphMethod<>(PositionFinder.Position.FIELD, null); + PairTphMethod posOfC = new PairTphMethod<>(PositionFinder.Position.METHOD, "id2"); + PairTphMethod posOfD = new PairTphMethod<>(PositionFinder.Position.METHOD, "id2"); + PairTphMethod posOfE = new PairTphMethod<>(PositionFinder.Position.METHOD, "m"); + PairTphMethod posOfF = new PairTphMethod<>(PositionFinder.Position.METHOD, "m"); + PairTphMethod posOfG = new PairTphMethod<>(PositionFinder.Position.METHOD, "m"); + PairTphMethod posOfH = new PairTphMethod<>(PositionFinder.Position.METHOD, "m2"); + PairTphMethod posOfI = new PairTphMethod<>(PositionFinder.Position.METHOD, "m2"); + PairTphMethod posOfJ = new PairTphMethod<>(PositionFinder.Position.METHOD, "m2"); + + tphPositions.put("A", posOfA); + tphPositions.put("B", posOfB); + tphPositions.put("C", posOfC); + tphPositions.put("D", posOfD); + tphPositions.put("E", posOfE); + tphPositions.put("F", posOfF); + tphPositions.put("G", posOfG); + tphPositions.put("H", posOfH); + tphPositions.put("I", posOfI); + tphPositions.put("J", posOfJ); List classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(inputConstraints, tphPositions); System.out.println(classConstraints); assertFalse(classConstraints.isEmpty()); assertTrue(classConstraints.size() == 3); - }*/ + } public void testPositionConverter() { @@ -160,7 +180,7 @@ public class FamilyOfGeneratedGenericsTest extends TestCase { m1.getTphs().add("A"); MethodAndTPH bla = new MethodAndTPH("bla"); MethodAndTPH blubb = new MethodAndTPH("blubb"); - blubb.getTphs().add("A"); +// blubb.getTphs().add("A"); listOfMethodsAndTphs.add(bla); listOfMethodsAndTphs.add(blubb); listOfMethodsAndTphs.add(m1);