From 997d3b9bea4ace88d5c65334a6cfbdb4ec1002fd Mon Sep 17 00:00:00 2001 From: AluAli Date: Fri, 27 Nov 2020 15:52:31 +0100 Subject: [PATCH] modified: src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java modified: src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java --- .../insertGenerics/FamilyOfGeneratedGenerics.java | 10 +++++----- .../FamilyOfGeneratedGenericsTest.java | 12 +++++++++++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java index 882ae9c8f..0a19df706 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java @@ -13,7 +13,7 @@ public class FamilyOfGeneratedGenerics { public HashMap posOfTPHs = new HashMap<>(); public FamilyOfGeneratedGenerics(TPHExtractor tphExtractor) { this.allConstraints = tphExtractor.allCons; - this.posOfTPHs = positionConverter(tphExtractor); + this.posOfTPHs = positionConverter(tphExtractor.allTPHS); } public static List getClassConstraints(List cs, HashMap posOfTphs) { //Inputparameter List constraintsSet weg @@ -232,12 +232,12 @@ public class FamilyOfGeneratedGenerics { } - public HashMap positionConverter(TPHExtractor tphExtractor) { + public static HashMap positionConverter(HashMap allTphs) { HashMap convertedPositions = new HashMap<>(); - for(String tph: tphExtractor.allTPHS.keySet()) { - if(tphExtractor.allTPHS.get(tph)) { + for(String tph: allTphs.keySet()) { + if(allTphs.get(tph)) { //if true, then tph is a method-TPH convertedPositions.put(tph, PositionFinder.Position.METHOD); - } else { + } else { // else it is in the class-TPH convertedPositions.put(tph, PositionFinder.Position.FIELD); } } diff --git a/src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java b/src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java index cf15c5748..4cc6cd6d6 100644 --- a/src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java +++ b/src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java @@ -63,7 +63,7 @@ public class FamilyOfGeneratedGenericsTest extends TestCase { List classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(inputConstraints, tphPositions); System.out.println(classConstraints); assertTrue(classConstraints.size() == 2); - //assertTrue(classConstraints.get(0).getLeft().equals("A")); + assertTrue(classConstraints.get(0).getLeft().equals("A")); //assertTrue(classConstraints.get(0).getRight().equals("B")); } @@ -152,6 +152,16 @@ public class FamilyOfGeneratedGenericsTest extends TestCase { } + public void testPositionConverter() { + HashMap allTphsOld = new HashMap<>(); + allTphsOld.put("A", true); + allTphsOld.put("B", false); + HashMap allTphsNew = FamilyOfGeneratedGenerics.positionConverter(allTphsOld); + System.out.println(allTphsNew); + + assertTrue(allTphsNew.get("A").equals(PositionFinder.Position.METHOD)); + assertTrue(allTphsNew.get("B").equals(PositionFinder.Position.FIELD)); + } } \ No newline at end of file