From 5a32cd800d028a1b08746119b3dd07948ea66373 Mon Sep 17 00:00:00 2001 From: tsantalis Date: Mon, 9 Dec 2024 09:33:25 -0500 Subject: [PATCH] Fix NPE --- src/main/java/gr/uom/java/xmi/diff/UMLModelDiff.java | 4 +++- .../org/refactoringminer/test/TestStatementMappings.java | 4 +++- .../test/TestStatementMappingsJunit4.java | 4 +++- .../junit5-48dd35c9002c80eeb666f56489785d1bf47f9aa4.txt | 9 +++++++++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main/java/gr/uom/java/xmi/diff/UMLModelDiff.java b/src/main/java/gr/uom/java/xmi/diff/UMLModelDiff.java index 06de55598f..a3db17bf65 100644 --- a/src/main/java/gr/uom/java/xmi/diff/UMLModelDiff.java +++ b/src/main/java/gr/uom/java/xmi/diff/UMLModelDiff.java @@ -1124,7 +1124,9 @@ private TreeSet optimize(TreeSet diffSet if(op1.getBodyHashCode() == op2.getBodyHashCode()) { identicalBodies++; } - if(op1.getActualSignature().equals(op2.getActualSignature())) { + String actualSignature1 = op1.getActualSignature(); + String actualSignature2 = op2.getActualSignature(); + if(actualSignature1 != null && actualSignature2 != null && actualSignature1.equals(actualSignature2)) { identicalSignatures++; } } diff --git a/src/test/java/org/refactoringminer/test/TestStatementMappings.java b/src/test/java/org/refactoringminer/test/TestStatementMappings.java index 1a2e4afcbc..70c4ae8e47 100644 --- a/src/test/java/org/refactoringminer/test/TestStatementMappings.java +++ b/src/test/java/org/refactoringminer/test/TestStatementMappings.java @@ -1770,7 +1770,9 @@ public void testConsecutiveChangedStatements() throws Exception { if(mapper.getContainer1().getName().equals("convertsTagFilterOption") && mapper.getContainer2().getName().equals("convertsTagFilterOption")) { mapperInfo(mapper, actual); } - //TODO add junit-console/src/main/java/org/junit/gen5/console/tasks/DiscoveryRequestCreator.java applyFilters() + if(mapper.getContainer1().getName().equals("applyFilters") && mapper.getContainer2().getName().equals("applyFilters")) { + mapperInfo(mapper, actual); + } } } List expected = IOUtils.readLines(new FileReader(EXPECTED_PATH + "junit5-48dd35c9002c80eeb666f56489785d1bf47f9aa4.txt")); diff --git a/src/test/java/org/refactoringminer/test/TestStatementMappingsJunit4.java b/src/test/java/org/refactoringminer/test/TestStatementMappingsJunit4.java index 1e7dd1b863..b9695b0109 100644 --- a/src/test/java/org/refactoringminer/test/TestStatementMappingsJunit4.java +++ b/src/test/java/org/refactoringminer/test/TestStatementMappingsJunit4.java @@ -3188,7 +3188,9 @@ public void testConsecutiveChangedStatements() throws Exception { if(mapper.getContainer1().getName().equals("convertsTagFilterOption") && mapper.getContainer2().getName().equals("convertsTagFilterOption")) { mapperInfo(mapper, actual); } - //TODO add junit-console/src/main/java/org/junit/gen5/console/tasks/DiscoveryRequestCreator.java applyFilters() + if(mapper.getContainer1().getName().equals("applyFilters") && mapper.getContainer2().getName().equals("applyFilters")) { + mapperInfo(mapper, actual); + } } } List expected = IOUtils.readLines(new FileReader(EXPECTED_PATH + "junit5-48dd35c9002c80eeb666f56489785d1bf47f9aa4.txt")); diff --git a/src/test/resources/mappings/junit5-48dd35c9002c80eeb666f56489785d1bf47f9aa4.txt b/src/test/resources/mappings/junit5-48dd35c9002c80eeb666f56489785d1bf47f9aa4.txt index d9d30de627..8ec4beeee5 100644 --- a/src/test/resources/mappings/junit5-48dd35c9002c80eeb666f56489785d1bf47f9aa4.txt +++ b/src/test/resources/mappings/junit5-48dd35c9002c80eeb666f56489785d1bf47f9aa4.txt @@ -10,6 +10,15 @@ line range:58-60==line range:58-60 line range:61-63==line range:61-63 line range:49-51==line range:49-51 line range:52-54==line range:52-54 +private applyFilters(discoveryRequest TestDiscoveryRequest, options CommandLineOptions) : void -> private applyFilters(discoveryRequest TestDiscoveryRequest, options CommandLineOptions) : void +line range:66-66==line range:66-66 +line range:66-66==line range:66-66 +line range:68-68==line range:68-68 +line range:71-71==line range:71-71 +line range:67-69==line range:67-69 +line range:70-72==line range:70-72 +line range:67-69==line range:67-69 +line range:70-72==line range:70-72 public convertsTagFilterOption() : void -> public convertsTagFilterOption() : void line range:133-133==line range:133-133 line range:137-137==line range:137-137