Skip to content

Commit

Permalink
Add test for newly detected Split Method refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
tsantalis committed Nov 5, 2024
1 parent 505f857 commit 2c884e1
Show file tree
Hide file tree
Showing 10 changed files with 2,400 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/test/java/org/refactoringminer/test/TestStatementMappings.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import gr.uom.java.xmi.diff.MoveCodeRefactoring;
import gr.uom.java.xmi.diff.ParameterizeTestRefactoring;
import gr.uom.java.xmi.diff.RenameOperationRefactoring;
import gr.uom.java.xmi.diff.SplitOperationRefactoring;
import gr.uom.java.xmi.diff.UMLAbstractClassDiff;
import gr.uom.java.xmi.diff.UMLAnonymousClassDiff;
import gr.uom.java.xmi.diff.UMLClassBaseDiff;
Expand Down Expand Up @@ -1725,6 +1726,28 @@ public void handle(String commitId, List<Refactoring> refactorings) {
Assertions.assertTrue(expected.size() == actual.size() && expected.containsAll(actual) && actual.containsAll(expected));
}

@Test
public void testSplitMethod() throws Exception {
GitHistoryRefactoringMinerImpl miner = new GitHistoryRefactoringMinerImpl();
final List<String> actual = new ArrayList<>();
miner.detectAtCommitWithGitHubAPI("https://github.com/checkstyle/checkstyle.git", "08d6efe49d2960d9bd61bfb9cca65910f0c19b58", new File(REPOS), new RefactoringHandler() {
@Override
public void handle(String commitId, List<Refactoring> refactorings) {
for (Refactoring ref : refactorings) {
if(ref instanceof SplitOperationRefactoring) {
SplitOperationRefactoring ex = (SplitOperationRefactoring)ref;
for(UMLOperationBodyMapper bodyMapper : ex.getMappers()) {
mapperInfo(bodyMapper, actual);
}
}
}
}
});

List<String> expected = IOUtils.readLines(new FileReader(EXPECTED_PATH + "checkstyle-08d6efe49d2960d9bd61bfb9cca65910f0c19b58.txt"));
Assertions.assertTrue(expected.size() == actual.size() && expected.containsAll(actual) && actual.containsAll(expected));
}

@Test
public void testConsecutiveChangedStatements() throws Exception {
GitHistoryRefactoringMinerImpl miner = new GitHistoryRefactoringMinerImpl();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import gr.uom.java.xmi.diff.MoveCodeRefactoring;
import gr.uom.java.xmi.diff.ParameterizeTestRefactoring;
import gr.uom.java.xmi.diff.RenameOperationRefactoring;
import gr.uom.java.xmi.diff.SplitOperationRefactoring;
import gr.uom.java.xmi.diff.UMLAbstractClassDiff;
import gr.uom.java.xmi.diff.UMLAnonymousClassDiff;
import gr.uom.java.xmi.diff.UMLClassBaseDiff;
Expand Down Expand Up @@ -3018,6 +3019,28 @@ public void handle(String commitId, List<Refactoring> refactorings) {
Assert.assertTrue(expected.size() == actual.size() && expected.containsAll(actual) && actual.containsAll(expected));
}

@Test
public void testSplitMethod() throws Exception {
GitHistoryRefactoringMinerImpl miner = new GitHistoryRefactoringMinerImpl();
final List<String> actual = new ArrayList<>();
miner.detectAtCommitWithGitHubAPI("https://github.com/checkstyle/checkstyle.git", "08d6efe49d2960d9bd61bfb9cca65910f0c19b58", new File(REPOS), new RefactoringHandler() {
@Override
public void handle(String commitId, List<Refactoring> refactorings) {
for (Refactoring ref : refactorings) {
if(ref instanceof SplitOperationRefactoring) {
SplitOperationRefactoring ex = (SplitOperationRefactoring)ref;
for(UMLOperationBodyMapper bodyMapper : ex.getMappers()) {
mapperInfo(bodyMapper, actual);
}
}
}
}
});

List<String> expected = IOUtils.readLines(new FileReader(EXPECTED_PATH + "checkstyle-08d6efe49d2960d9bd61bfb9cca65910f0c19b58.txt"));
Assert.assertTrue(expected.size() == actual.size() && expected.containsAll(actual) && actual.containsAll(expected));
}

@Test
public void testConsecutiveChangedStatements() throws Exception {
GitHistoryRefactoringMinerImpl miner = new GitHistoryRefactoringMinerImpl();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
public configure(aConfig Configuration) : void -> protected setupChild(aChildConf Configuration) : void
line range:148-152==line range:158-162
line range:153-153==line range:163-163
line range:156-156==line range:166-166
line range:160-162==line range:170-172
line range:146-146==line range:156-156
line range:154-154==line range:164-164
line range:155-155==line range:165-165
line range:147-163==line range:157-173
line range:158-163==line range:168-173
public configure(aConfig Configuration) : void -> public finishLocalSetup() : void
line range:138-138==line range:140-140
line range:139-139==line range:141-141
line range:141-141==line range:143-143
line range:142-142==line range:144-144
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"parentCommitId":"987da3a4c5fac3476a4461892c919c0f6d9248bd","currentCommitId":"08d6efe49d2960d9bd61bfb9cca65910f0c19b58","filesBefore":["src/checkstyle/com/puppycrawl/tools/checkstyle/Checker.java","src/checkstyle/com/puppycrawl/tools/checkstyle/TreeWalker.java","src/checkstyle/com/puppycrawl/tools/checkstyle/api/AutomaticBean.java"],"filesCurrent":["src/checkstyle/com/puppycrawl/tools/checkstyle/Checker.java","src/checkstyle/com/puppycrawl/tools/checkstyle/TreeWalker.java","src/checkstyle/com/puppycrawl/tools/checkstyle/api/AutomaticBean.java"],"renamedFilesHint":{},"repositoryDirectoriesBefore":["src","src/checkstyle/com","src/checkstyle/com/puppycrawl/tools/checkstyle","src/checkstyle/com/puppycrawl/tools","src/checkstyle","src/checkstyle/com/puppycrawl","src/checkstyle/com/puppycrawl/tools/checkstyle/api"],"repositoryDirectoriesCurrent":["src","src/checkstyle/com","src/checkstyle/com/puppycrawl/tools/checkstyle","src/checkstyle/com/puppycrawl/tools","src/checkstyle","src/checkstyle/com/puppycrawl","src/checkstyle/com/puppycrawl/tools/checkstyle/api"],"commitTime":0,"authoredTime":0,"commitAuthorName":null}
Loading

0 comments on commit 2c884e1

Please sign in to comment.