|
4 | 4 | import java.io.FileReader; |
5 | 5 | import java.util.ArrayList; |
6 | 6 | import java.util.LinkedHashMap; |
| 7 | +import java.util.LinkedHashSet; |
7 | 8 | import java.util.List; |
8 | 9 | import java.util.Map; |
9 | 10 | import java.util.Set; |
10 | 11 | import java.util.concurrent.ConcurrentHashMap; |
11 | 12 |
|
| 13 | +import org.apache.commons.io.FileUtils; |
12 | 14 | import org.apache.commons.io.IOUtils; |
13 | 15 | import org.apache.commons.lang3.tuple.Pair; |
14 | 16 | import org.junit.jupiter.api.Assertions; |
|
26 | 28 | import gr.uom.java.xmi.diff.ExtractOperationRefactoring; |
27 | 29 | import gr.uom.java.xmi.diff.InlineOperationRefactoring; |
28 | 30 | import gr.uom.java.xmi.diff.UMLClassDiff; |
| 31 | +import gr.uom.java.xmi.diff.UMLModelDiff; |
29 | 32 |
|
30 | 33 | public class TestJavadocDiff { |
31 | 34 | private static final String REPOS = System.getProperty("user.dir") + "/src/test/resources/oracle/commits"; |
@@ -118,6 +121,34 @@ public void testMethodCommentMappings(String url, String commitId, String classN |
118 | 121 | Assertions.assertTrue(expected.size() == actual.size() && expected.containsAll(actual) && actual.containsAll(expected)); |
119 | 122 | } |
120 | 123 |
|
| 124 | + @ParameterizedTest |
| 125 | + @CsvSource({ |
| 126 | + "GroupTreeViewModel-v1.txt, GroupTreeViewModel-v2.txt, jabgui/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java, jabRef-GroupTreeViewModel-716.txt", |
| 127 | + "GroupNodeViewModel-v1.txt, GroupNodeViewModel-v2.txt, jabgui/src/main/java/org/jabref/gui/groups/GroupNodeViewModel.java, jabRef-GroupNodeViewModel-716.txt", |
| 128 | + "NewEntryAction-v1.txt, NewEntryAction-v2.txt, jabgui/src/main/java/org/jabref/gui/importer/NewEntryAction.java, jabRef-NewEntryAction-716.txt" |
| 129 | + }) |
| 130 | + public void testMethodCommentMappings(String filePath1, String filePath2, String qualifiedName, String testResultFileName) throws Exception { |
| 131 | + final List<String> actual = new ArrayList<>(); |
| 132 | + Map<String, String> fileContentsBefore = new LinkedHashMap<String, String>(); |
| 133 | + Map<String, String> fileContentsCurrent = new LinkedHashMap<String, String>(); |
| 134 | + String contentsV1 = FileUtils.readFileToString(new File(EXPECTED_PATH + filePath1)); |
| 135 | + String contentsV2 = FileUtils.readFileToString(new File(EXPECTED_PATH + filePath2)); |
| 136 | + fileContentsBefore.put(qualifiedName, contentsV1); |
| 137 | + fileContentsCurrent.put(qualifiedName, contentsV2); |
| 138 | + UMLModel parentUMLModel = GitHistoryRefactoringMinerImpl.createModel(fileContentsBefore, new LinkedHashSet<String>()); |
| 139 | + UMLModel currentUMLModel = GitHistoryRefactoringMinerImpl.createModel(fileContentsCurrent, new LinkedHashSet<String>()); |
| 140 | + |
| 141 | + UMLModelDiff modelDiff = parentUMLModel.diff(currentUMLModel); |
| 142 | + List<UMLClassDiff> commonClassDiff = modelDiff.getCommonClassDiffList(); |
| 143 | + for(UMLClassDiff classDiff : commonClassDiff) { |
| 144 | + for(UMLOperationBodyMapper mapper : classDiff.getOperationBodyMapperList()) { |
| 145 | + commentInfo(mapper, actual); |
| 146 | + } |
| 147 | + } |
| 148 | + List<String> expected = IOUtils.readLines(new FileReader(EXPECTED_PATH + testResultFileName)); |
| 149 | + Assertions.assertTrue(expected.size() == actual.size() && expected.containsAll(actual) && actual.containsAll(expected)); |
| 150 | + } |
| 151 | + |
121 | 152 | @ParameterizedTest |
122 | 153 | @CsvSource({ |
123 | 154 | "https://github.com/jOOQ/jOOQ.git, 58a4e74d28073e7c6f15d1f225ac1c2fd9aa4357, org.jooq.tools.Convert.ConvertAll, jOOQ-58a4e74d28073e7c6f15d1f225ac1c2fd9aa4357-comments.txt", |
|
0 commit comments