From d671e74fcfa2ca303c411c7d8b09071f21a4affa Mon Sep 17 00:00:00 2001
From: AluAli <memtoo@gmx.de>
Date: Fri, 4 Dec 2020 16:44:46 +0100
Subject: [PATCH] 	modified:  
 src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java

---
 .../FamilyOfGeneratedGenericsTest.java        | 78 ++++++++++++-------
 1 file changed, 49 insertions(+), 29 deletions(-)

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<MethodConstraint> 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<TPHConstraint> inputConstraints = new ArrayList<>();
         inputConstraints.add(new TPHConstraint("A", "B", TPHConstraint.Relation.EXTENDS));
 
         HashMap<String, PairTphMethod<PositionFinder.Position, String>> tphPositions = new HashMap<>();
-        tphPositions.put("A", PositionFinder.Position.FIELD);
-        tphPositions.put("B", PositionFinder.Position.METHOD);
+        PairTphMethod<PositionFinder.Position, String> posOfA = new PairTphMethod<>(PositionFinder.Position.FIELD, null);
+        tphPositions.put("A", posOfA);
+        PairTphMethod<PositionFinder.Position, String> posOfB = new PairTphMethod<>(PositionFinder.Position.METHOD, "fReturn");
+        tphPositions.put("B", posOfB);
 
-        *//*
+        /*
         ClassConstraints should not be the same as the input constraint
-         *//*
+         */
         List<ClassConstraint> 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<TPHConstraint> 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<String, PairTphMethod<PositionFinder.Position, String>> 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<PositionFinder.Position, String> posOfA = new PairTphMethod<>(PositionFinder.Position.FIELD, null);
+        PairTphMethod<PositionFinder.Position, String> posOfB = new PairTphMethod<>(PositionFinder.Position.FIELD, null);
+        PairTphMethod<PositionFinder.Position, String> posOfC = new PairTphMethod<>(PositionFinder.Position.METHOD, "anyMethod");
+        PairTphMethod<PositionFinder.Position, String> posOfD = new PairTphMethod<>(PositionFinder.Position.METHOD, "otherMethod");
+        PairTphMethod<PositionFinder.Position, String> posOfE = new PairTphMethod<>(PositionFinder.Position.METHOD, "otherMethod");
+        PairTphMethod<PositionFinder.Position, String> 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<ClassConstraint> classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(inputConstraints, tphPositions);
         System.out.println(classConstraints);
@@ -106,7 +115,7 @@ public class FamilyOfGeneratedGenericsTest extends TestCase {
     }
 
     public void testTPHsAndGenerics() {
-        *//*
+        /*
         class TPHsAndGenerics {
             Fun1<A,B> id = x -> x;
             C id2 (D x) {
@@ -120,7 +129,7 @@ public class FamilyOfGeneratedGenericsTest extends TestCase {
                 return b;
             }
         }
-        *//*
+        */
 
         List<TPHConstraint> 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<String, PairTphMethod<PositionFinder.Position, String>> 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<PositionFinder.Position, String> posOfA = new PairTphMethod<>(PositionFinder.Position.FIELD, null);
+        PairTphMethod<PositionFinder.Position, String> posOfB = new PairTphMethod<>(PositionFinder.Position.FIELD, null);
+        PairTphMethod<PositionFinder.Position, String> posOfC = new PairTphMethod<>(PositionFinder.Position.METHOD, "id2");
+        PairTphMethod<PositionFinder.Position, String> posOfD = new PairTphMethod<>(PositionFinder.Position.METHOD, "id2");
+        PairTphMethod<PositionFinder.Position, String> posOfE = new PairTphMethod<>(PositionFinder.Position.METHOD, "m");
+        PairTphMethod<PositionFinder.Position, String> posOfF = new PairTphMethod<>(PositionFinder.Position.METHOD, "m");
+        PairTphMethod<PositionFinder.Position, String> posOfG = new PairTphMethod<>(PositionFinder.Position.METHOD, "m");
+        PairTphMethod<PositionFinder.Position, String> posOfH = new PairTphMethod<>(PositionFinder.Position.METHOD, "m2");
+        PairTphMethod<PositionFinder.Position, String> posOfI = new PairTphMethod<>(PositionFinder.Position.METHOD, "m2");
+        PairTphMethod<PositionFinder.Position, String> 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<ClassConstraint> 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);