Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tsantalis committed Jan 1, 2025
1 parent bf2bce6 commit 8119683
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3614,6 +3614,31 @@ public boolean containsOnlyBlockMappings() {
return count > 0 && count == getMappings().size();
}

public boolean containsOnlySystemCalls() {
int count = 0;
for(AbstractCodeMapping mapping : getMappings()) {
if(mapping.getFragment1().getString().startsWith("System.") && mapping.getFragment2().getString().startsWith("System.") &&
!mapping.getFragment1().getString().equals(mapping.getFragment2().getString())) {
count++;
}
else if(mapping.getFragment1().getString().startsWith(JAVA.THROW_SPACE + "new") && mapping.getFragment2().getString().startsWith(JAVA.THROW_SPACE + "new") &&
!mapping.getFragment1().getString().equals(mapping.getFragment2().getString())) {
count++;
}
else if(mapping.getFragment1().getLocationInfo().getCodeElementType().equals(CodeElementType.BLOCK) && mapping.getFragment2().getLocationInfo().getCodeElementType().equals(CodeElementType.BLOCK)) {
count++;
}
else if(mapping.getFragment1().getLocationInfo().getCodeElementType().equals(CodeElementType.FINALLY_BLOCK) && mapping.getFragment2().getLocationInfo().getCodeElementType().equals(CodeElementType.FINALLY_BLOCK)) {
count++;
}
else if(mapping.getFragment1().getLocationInfo().getCodeElementType().equals(CodeElementType.IF_STATEMENT) && mapping.getFragment2().getLocationInfo().getCodeElementType().equals(CodeElementType.IF_STATEMENT) &&
!mapping.getFragment1().getString().equals(mapping.getFragment2().getString())) {
count++;
}
}
return count > 0 && count == getMappings().size();
}

public int mappingsWithoutBlocks() {
int count = 0;
Set<LeafMapping> subExpressionMappings = new LinkedHashSet<>();
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/gr/uom/java/xmi/diff/UMLModelDiff.java
Original file line number Diff line number Diff line change
Expand Up @@ -4623,6 +4623,9 @@ private boolean anotherAddedMethodExistsWithBetterMatchingInvocationExpression(A

private boolean extractAndMoveMatchCondition(UMLOperationBodyMapper operationBodyMapper, UMLOperationBodyMapper parentMapper, AbstractCall addedOperationInvocation) {
List<AbstractCodeMapping> mappingList = new ArrayList<AbstractCodeMapping>(operationBodyMapper.getMappings());
if(operationBodyMapper.containsOnlySystemCalls()) {
return false;
}
if(operationBodyMapper.getContainer2().isGetter() && mappingList.size() == 1) {
List<AbstractCodeMapping> parentMappingList = new ArrayList<AbstractCodeMapping>(parentMapper.getMappings());
for(AbstractCodeMapping mapping : parentMappingList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ public void testAllRefactorings() throws Exception {
GitHistoryRefactoringMinerImpl detector = new GitHistoryRefactoringMinerImpl();
TestBuilder test = new TestBuilder(detector, REPOS, Refactorings.All.getValue());
RefactoringPopulator.feedRefactoringsInstances(Refactorings.All.getValue(), Systems.FSE.getValue(), test);
test.assertExpectationsWithGitHubAPI(12404, 22, 226);
test.assertExpectationsWithGitHubAPI(12404, 21, 226);
}
}

0 comments on commit 8119683

Please sign in to comment.