From e8ac8e3c5a0b1b86fed88de9ae2822c4cc4e01da Mon Sep 17 00:00:00 2001 From: AluAli Date: Fri, 13 Nov 2020 13:50:36 +0100 Subject: [PATCH] modified: src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java --- .../FamilyOfGeneratedGenericsTest.java | 50 +++++++++++++++++-- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java b/src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java index d8c4fb8ee..ba83e0d24 100644 --- a/src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java +++ b/src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java @@ -58,11 +58,53 @@ public class FamilyOfGeneratedGenericsTest extends TestCase { tphPositions.put("B", PositionFinder.Position.METHOD); /* - ClassConstraints should be the same as the input constraint + ClassConstraints should not be the same as the input constraint */ List classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(inputConstraints, tphPositions); - assertTrue(classConstraints.size() == 1); - assertTrue(classConstraints.get(0).getLeft().equals("A")); - assertTrue(classConstraints.get(0).getRight().equals("B")); + assertTrue(classConstraints.size() == 2); + //assertTrue(classConstraints.get(0).getLeft().equals("A")); + //assertTrue(classConstraints.get(0).getRight().equals("B")); } + + public void testSecondLineOfClassConstraints() { + /* + class Example() { + A a; + B b = a; + C anyMethod() { + F f; + return f; + } + D otherMethod(E e) { + this.b = e; + e = this.a; + return e; + } + } + */ + + List inputConstraints = new ArrayList<>(); + inputConstraints.add(new TPHConstraint("A", "B", TPHConstraint.Relation.EXTENDS)); + inputConstraints.add(new TPHConstraint("F", "C", TPHConstraint.Relation.EXTENDS)); + inputConstraints.add(new TPHConstraint("E", "B", TPHConstraint.Relation.EXTENDS)); + inputConstraints.add(new TPHConstraint("A", "E", TPHConstraint.Relation.EXTENDS)); + 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); + + List classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(inputConstraints, tphPositions); + System.out.println(classConstraints); + assertFalse(classConstraints.isEmpty()); + assertTrue(classConstraints.size() == 2); + + } + + } \ No newline at end of file