From f6d81752d96336eb9249dd7893af389e5d407877 Mon Sep 17 00:00:00 2001 From: tsantalis Date: Tue, 14 Jan 2025 16:10:26 -0500 Subject: [PATCH] Improve the sorting of body mappers Fixes matching of methods in platform-tests/src/test/java/org/junit/platform/engine/discovery/DiscoverySelectorsTests.java https://github.com/junit-team/junit5/commit/c71d6715e01e2bd65fcce9675955a851da24d384 --- .../decomposition/UMLOperationBodyMapper.java | 17 ++++++++--- .../test/TestAllRefactorings.java | 2 +- src/test/resources/oracle/data.json | 28 +++++-------------- src/test/resources/oracle/expected.txt | 2 +- 4 files changed, 22 insertions(+), 27 deletions(-) diff --git a/src/main/java/gr/uom/java/xmi/decomposition/UMLOperationBodyMapper.java b/src/main/java/gr/uom/java/xmi/decomposition/UMLOperationBodyMapper.java index ff0ad419b..aff7c7c6a 100644 --- a/src/main/java/gr/uom/java/xmi/decomposition/UMLOperationBodyMapper.java +++ b/src/main/java/gr/uom/java/xmi/decomposition/UMLOperationBodyMapper.java @@ -3968,6 +3968,9 @@ public boolean allMappingsAreIdentical() { if(mapping.getFragment1().getString().equals(mapping.getFragment2().getString())) { identical++; } + else { + break; + } } return identical == this.getMappings().size() && identical > 0; } @@ -9762,12 +9765,18 @@ else if(identicalStringRepresentation2) { otherMappings++; } } - if(thisMappings != otherMappings) { - return -Integer.compare(thisMappings, otherMappings); + int thisExactMatches = this.exactMatches(); + int otherExactMatches = operationBodyMapper.exactMatches(); + if(thisMappings > otherMappings && thisExactMatches >= otherExactMatches) { + return -1; + } + else if(thisMappings < otherMappings && thisExactMatches <= otherExactMatches) { + return 1; } + //if(thisMappings != otherMappings) { + // return -Integer.compare(thisMappings, otherMappings); + //} else { - int thisExactMatches = this.exactMatches(); - int otherExactMatches = operationBodyMapper.exactMatches(); if(thisExactMatches != otherExactMatches) { return -Integer.compare(thisExactMatches, otherExactMatches); } diff --git a/src/test/java/org/refactoringminer/test/TestAllRefactorings.java b/src/test/java/org/refactoringminer/test/TestAllRefactorings.java index 4e588344a..b4745e880 100644 --- a/src/test/java/org/refactoringminer/test/TestAllRefactorings.java +++ b/src/test/java/org/refactoringminer/test/TestAllRefactorings.java @@ -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(12402, 18, 226); + test.assertExpectationsWithGitHubAPI(12402, 16, 226); } } diff --git a/src/test/resources/oracle/data.json b/src/test/resources/oracle/data.json index ddd3d2261..46c25fca6 100644 --- a/src/test/resources/oracle/data.json +++ b/src/test/resources/oracle/data.json @@ -32367,13 +32367,6 @@ "validation": "TP", "detectionTools": "RefactoringMiner", "validators": "Nikos" - }, { - "type": "Change Parameter Type", - "description": "Change Parameter Type meta : long to meta : long[] in method private createResult(number long, meta long[]) : long[] from class org.neo4j.kernel.impl.util.ArrayQueueOutOfOrderSequence", - "comment": "

createResult() is extracted from public long[] get(), in which there is a local variable meta whose type is changing from long to long[] and is passed as argument to createResult()

", - "validation": "TP", - "detectionTools": "RefactoringMiner", - "validators": "Nikos" }, { "type": "Change Parameter Type", "description": "Change Parameter Type meta : long to meta : long[] in method public seen(number long, meta long[]) : boolean from class org.neo4j.kernel.impl.util.ArrayQueueOutOfOrderSequence", @@ -32500,13 +32493,6 @@ "validation": "TP", "detectionTools": "RefactoringMiner", "validators": "Nikos" - }, { - "type": "Rename Method", - "description": "Rename Method private pack(meta long) : long[] renamed to private createResult(number long, meta long[]) : long[] in class org.neo4j.kernel.impl.util.ArrayQueueOutOfOrderSequence", - "comment": "null", - "validation": "FP", - "detectionTools": "RefactoringMiner", - "validators": "Nikos" }, { "type": "Change Variable Type", "description": "Change Variable Type logRotationControl : LogRotationControl to logRotationControl : StoreFlusher in method public shouldWriteSomeDataIntoTheLog() : void from class org.neo4j.kernel.impl.transaction.log.PhysicalLogFileTest", @@ -32850,13 +32836,6 @@ "validation": "TP", "detectionTools": "RefactoringMiner", "validators": null - }, { - "type": "Add Parameter", - "description": "Add Parameter number : long in method private createResult(number long, meta long[]) : long[] from class org.neo4j.kernel.impl.util.ArrayQueueOutOfOrderSequence", - "comment": "null", - "validation": "FP", - "detectionTools": "RefactoringMiner", - "validators": "Nikos" }, { "type": "Remove Parameter", "description": "Remove Parameter transactionId : long in method public checkPoint(transactionId long, logPosition LogPosition) : void from class org.neo4j.kernel.impl.transaction.log.TransactionLogWriter", @@ -33347,6 +33326,13 @@ "validation": "CTP", "detectionTools": "RefactoringMiner", "validators": null + }, { + "type": "Change Parameter Type", + "description": "Change Parameter Type meta : long to meta : long[] in method private pack(meta long[]) : long[] from class org.neo4j.kernel.impl.util.ArrayQueueOutOfOrderSequence", + "comment": null, + "validation": "TP", + "detectionTools": "RefactoringMiner", + "validators": null }], "refDiffExecutionTime": 11758 }, { diff --git a/src/test/resources/oracle/expected.txt b/src/test/resources/oracle/expected.txt index 77c91ed05..d6ba5a33a 100644 --- a/src/test/resources/oracle/expected.txt +++ b/src/test/resources/oracle/expected.txt @@ -141,7 +141,7 @@ e19c6874431dc2c3046436c2ac249a0ab2ef3457, 2, 0, 0 5a38d0bca0e48853c3f7c00a0f098bada64797df, 42, 0, 1 a26b61201cd86c9a8773b418d9c84b446e95a601, 70, 0, 4 74d2cc420e5590ba3bc0ffcc15b30b76a9cbef0b, 10, 0, 5 -001de307492df8f84ad15f6aaa0bd1e748d4ce27, 161, 2, 7 +001de307492df8f84ad15f6aaa0bd1e748d4ce27, 161, 0, 7 4712de476aabe69cd762233c9641dd3cf9f8361b, 54, 0, 2 dc199688d69416da58b370ca2aa728e935fc8e0d, 25, 1, 0 77fab3caea4495798a248035f0e928f745c7c2db, 91, 0, 2