From 2488cfa44c26e295cf3d8302d87edfc326cac6be Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 29 Jul 2026 20:41:01 +0000 Subject: [PATCH] test: improve coverage for BaseTools Co-authored-by: RoiSoleil <3462260+RoiSoleil@users.noreply.github.com> --- .../test/org/moreunit/util/BaseToolsTest.java | 37 +++++++++++++++++++ patch_objects.diff | 33 ----------------- test_check.sh | 1 - test_diviner.sh | 1 - 4 files changed, 37 insertions(+), 35 deletions(-) delete mode 100644 patch_objects.diff delete mode 100644 test_check.sh delete mode 100644 test_diviner.sh diff --git a/org.moreunit.test/test/org/moreunit/util/BaseToolsTest.java b/org.moreunit.test/test/org/moreunit/util/BaseToolsTest.java index 04d13826..c7f0c8e4 100644 --- a/org.moreunit.test/test/org/moreunit/util/BaseToolsTest.java +++ b/org.moreunit.test/test/org/moreunit/util/BaseToolsTest.java @@ -3,6 +3,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNull; import java.util.ArrayList; import java.util.Arrays; @@ -139,4 +140,40 @@ public void getListOfUnqualifiedTypeNames_should_return_list_sorted_by_raw_lengt assertEquals(result.get(1), "OneTwoThree"); assertEquals(result.get(5), "One"); } + + @Test + public void getFirstMethodWithSameNamePrefix_should_return_null_when_methodName_is_null() { + org.eclipse.jdt.core.IMethod[] methods = new org.eclipse.jdt.core.IMethod[0]; + assertNull(BaseTools.getFirstMethodWithSameNamePrefix(methods, null)); + } + + @Test + public void getFirstMethodWithSameNamePrefix_should_return_null_when_no_method_matches() { + org.eclipse.jdt.core.IMethod method1 = org.mockito.Mockito.mock(org.eclipse.jdt.core.IMethod.class); + org.mockito.Mockito.when(method1.getElementName()).thenReturn("foo"); + org.mockito.Mockito.when(method1.exists()).thenReturn(true); + + org.eclipse.jdt.core.IMethod[] methods = { method1 }; + assertNull(BaseTools.getFirstMethodWithSameNamePrefix(methods, "bar")); + } + + @Test + public void getFirstMethodWithSameNamePrefix_should_return_matching_method() { + org.eclipse.jdt.core.IMethod method1 = org.mockito.Mockito.mock(org.eclipse.jdt.core.IMethod.class); + org.mockito.Mockito.when(method1.getElementName()).thenReturn("foo"); + org.mockito.Mockito.when(method1.exists()).thenReturn(true); + + org.eclipse.jdt.core.IMethod[] methods = { method1 }; + assertEquals(method1, BaseTools.getFirstMethodWithSameNamePrefix(methods, "fooBar")); + } + + @Test + public void getFirstMethodWithSameNamePrefix_should_not_return_method_that_does_not_exist() { + org.eclipse.jdt.core.IMethod method1 = org.mockito.Mockito.mock(org.eclipse.jdt.core.IMethod.class); + org.mockito.Mockito.when(method1.getElementName()).thenReturn("foo"); + org.mockito.Mockito.when(method1.exists()).thenReturn(false); + + org.eclipse.jdt.core.IMethod[] methods = { method1 }; + assertNull(BaseTools.getFirstMethodWithSameNamePrefix(methods, "fooBar")); + } } diff --git a/patch_objects.diff b/patch_objects.diff deleted file mode 100644 index e7bc59ff..00000000 --- a/patch_objects.diff +++ /dev/null @@ -1,33 +0,0 @@ -<<<<<<< SEARCH - @Test - public void unequal_objects_should_be_seen_as_such() throws Exception - { - assertFalse(Objects.equal("abc", "aBc")); - assertFalse(Objects.equal(95, 94)); - } -} -======= - @Test - public void unequal_objects_should_be_seen_as_such() throws Exception - { - assertFalse(Objects.equal("abc", "aBc")); - assertFalse(Objects.equal(95, 94)); - } - - @Test - public void testHash() { - org.junit.jupiter.api.Assertions.assertEquals( - java.util.Arrays.hashCode(new Object[]{"a", "b"}), - Objects.hash("a", "b") - ); - org.junit.jupiter.api.Assertions.assertEquals( - java.util.Arrays.hashCode(new Object[]{null, "b"}), - Objects.hash(null, "b") - ); - org.junit.jupiter.api.Assertions.assertEquals( - java.util.Arrays.hashCode(new Object[]{}), - Objects.hash() - ); - } -} ->>>>>>> REPLACE diff --git a/test_check.sh b/test_check.sh deleted file mode 100644 index 3ed76b8b..00000000 --- a/test_check.sh +++ /dev/null @@ -1 +0,0 @@ -echo "The previous failure 'class ProjectPreferencesTest tried to access method ProjectPreferences.removeLanguage... ProjectPreferencesTest is in unnamed module ... ProjectPreferences is in unnamed module' implies the package-private access in JUnit5 module path might be an issue. Even though they are in the same package, Tycho OSGi classloaders might put them in different contexts if not exported, or since we test it, it might need to be public." diff --git a/test_diviner.sh b/test_diviner.sh deleted file mode 100644 index 068537c2..00000000 --- a/test_diviner.sh +++ /dev/null @@ -1 +0,0 @@ -# check line numbers for missing coverage