From bf619bb621324bffbf8b547e14aad7b4c173814d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 17 Sep 2025 18:39:46 +0000 Subject: [PATCH 01/13] build(deps): bump rexml in /docs in the bundler group across 1 directory Bumps the bundler group with 1 update in the /docs directory: [rexml](https://github.com/ruby/rexml). Updates `rexml` from 3.3.9 to 3.4.2 - [Release notes](https://github.com/ruby/rexml/releases) - [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md) - [Commits](https://github.com/ruby/rexml/compare/v3.3.9...v3.4.2) --- updated-dependencies: - dependency-name: rexml dependency-version: 3.4.2 dependency-type: indirect dependency-group: bundler ... Signed-off-by: dependabot[bot] --- docs/Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Gemfile.lock b/docs/Gemfile.lock index 4353c85d1..3d0674460 100644 --- a/docs/Gemfile.lock +++ b/docs/Gemfile.lock @@ -239,7 +239,7 @@ GEM rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) - rexml (3.3.9) + rexml (3.4.2) rouge (3.26.0) ruby2_keywords (0.0.5) rubyzip (2.3.2) From c0ad1d775b30e8c92d9c9c641dc2fa94edd04dc6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Sep 2025 15:08:17 +0000 Subject: [PATCH 02/13] build(deps): bump org.mockito:mockito-junit-jupiter Bumps [org.mockito:mockito-junit-jupiter](https://github.com/mockito/mockito) from 5.19.0 to 5.20.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v5.19.0...v5.20.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-junit-jupiter dependency-version: 5.20.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index eaff64cbe..2b13b937c 100644 --- a/pom.xml +++ b/pom.xml @@ -47,7 +47,7 @@ true 5.13.4 - 5.19.0 + 5.20.0 2.20.0 8.12.6 4.38.0 From 516942ea8973a48450afb9a29bc3395e98779ff2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Sep 2025 15:08:21 +0000 Subject: [PATCH 03/13] build(deps): bump org.apache.maven.plugins:maven-compiler-plugin Bumps [org.apache.maven.plugins:maven-compiler-plugin](https://github.com/apache/maven-compiler-plugin) from 3.14.0 to 3.14.1. - [Release notes](https://github.com/apache/maven-compiler-plugin/releases) - [Commits](https://github.com/apache/maven-compiler-plugin/compare/maven-compiler-plugin-3.14.0...maven-compiler-plugin-3.14.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-compiler-plugin dependency-version: 3.14.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index eaff64cbe..1a23c3387 100644 --- a/pom.xml +++ b/pom.xml @@ -365,7 +365,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.14.0 + 3.14.1 21 21 From e4a47891c7030b2e72661e3c6edfdfd007896e63 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Sep 2025 15:08:26 +0000 Subject: [PATCH 04/13] build(deps): bump org.projectlombok:lombok from 1.18.40 to 1.18.42 Bumps [org.projectlombok:lombok](https://github.com/projectlombok/lombok) from 1.18.40 to 1.18.42. - [Changelog](https://github.com/projectlombok/lombok/blob/master/doc/changelog.markdown) - [Commits](https://github.com/projectlombok/lombok/compare/v1.18.40...v1.18.42) --- updated-dependencies: - dependency-name: org.projectlombok:lombok dependency-version: 1.18.42 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index eaff64cbe..a34fe6b62 100644 --- a/pom.xml +++ b/pom.xml @@ -124,7 +124,7 @@ org.projectlombok lombok - 1.18.40 + 1.18.42 From ac5db5669613ad881720562989668d2b93f127b5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Sep 2025 15:08:29 +0000 Subject: [PATCH 05/13] build(deps): bump net.datafaker:datafaker from 2.4.4 to 2.5.0 Bumps [net.datafaker:datafaker](https://github.com/datafaker-net/datafaker) from 2.4.4 to 2.5.0. - [Release notes](https://github.com/datafaker-net/datafaker/releases) - [Changelog](https://github.com/datafaker-net/datafaker/blob/main/RELEASE_PROCESS.md) - [Commits](https://github.com/datafaker-net/datafaker/compare/2.4.4...2.5.0) --- updated-dependencies: - dependency-name: net.datafaker:datafaker dependency-version: 2.5.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index eaff64cbe..461950fd5 100644 --- a/pom.xml +++ b/pom.xml @@ -250,7 +250,7 @@ net.datafaker datafaker - 2.4.4 + 2.5.0 From 4734bf4680f854222460c8cab410ec9e04d70a31 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Sep 2025 15:08:41 +0000 Subject: [PATCH 06/13] build(deps): bump org.codehaus.mojo:flatten-maven-plugin Bumps [org.codehaus.mojo:flatten-maven-plugin](https://github.com/mojohaus/flatten-maven-plugin) from 1.7.2 to 1.7.3. - [Release notes](https://github.com/mojohaus/flatten-maven-plugin/releases) - [Commits](https://github.com/mojohaus/flatten-maven-plugin/compare/1.7.2...1.7.3) --- updated-dependencies: - dependency-name: org.codehaus.mojo:flatten-maven-plugin dependency-version: 1.7.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index eaff64cbe..c79e575f9 100644 --- a/pom.xml +++ b/pom.xml @@ -485,7 +485,7 @@ org.codehaus.mojo flatten-maven-plugin - 1.7.2 + 1.7.3 true ossrh From 86b68a3455c1d2cc1c38ad03b63fc650f0f717f0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Sep 2025 15:08:48 +0000 Subject: [PATCH 07/13] build(deps): bump org.apache.maven.plugins:maven-javadoc-plugin Bumps [org.apache.maven.plugins:maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.11.3 to 3.12.0. - [Release notes](https://github.com/apache/maven-javadoc-plugin/releases) - [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.11.3...maven-javadoc-plugin-3.12.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-javadoc-plugin dependency-version: 3.12.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- spectrum/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spectrum/pom.xml b/spectrum/pom.xml index 7fed88531..87fa70466 100644 --- a/spectrum/pom.xml +++ b/spectrum/pom.xml @@ -328,7 +328,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.11.3 + 3.12.0 -Xdoclint:none From 720845d81d6a5fc00654c22a01bc92a4174bbf85 Mon Sep 17 00:00:00 2001 From: Giulio Longfils Date: Mon, 22 Sep 2025 22:12:40 +0200 Subject: [PATCH 08/13] refactor: leveraging reified varargs to avoid explicit casting --- .../giulong/spectrum/utils/Reflections.java | 19 ++++++++----- .../spectrum/drivers/AppiumGenericTest.java | 7 ++--- .../spectrum/drivers/EspressoTest.java | 14 ++++------ .../giulong/spectrum/drivers/Mac2Test.java | 7 ++--- .../spectrum/drivers/UiAutomator2Test.java | 14 ++++------ .../giulong/spectrum/drivers/WindowsTest.java | 7 ++--- .../spectrum/drivers/XCUITestTest.java | 14 ++++------ .../spectrum/internals/AppiumLogTest.java | 4 +-- .../spectrum/internals/DriverLogTest.java | 4 +-- .../SpectrumLocatingElementHandlerTest.java | 2 +- .../giulong/spectrum/utils/HtmlUtilsTest.java | 8 +++--- .../spectrum/utils/ReflectionsTest.java | 28 ++++++++++--------- .../giulong/spectrum/utils/YamlUtilsTest.java | 6 ++-- 13 files changed, 66 insertions(+), 68 deletions(-) diff --git a/spectrum/src/main/java/io/github/giulong/spectrum/utils/Reflections.java b/spectrum/src/main/java/io/github/giulong/spectrum/utils/Reflections.java index 80373cb85..d9d994578 100644 --- a/spectrum/src/main/java/io/github/giulong/spectrum/utils/Reflections.java +++ b/spectrum/src/main/java/io/github/giulong/spectrum/utils/Reflections.java @@ -59,14 +59,14 @@ public static Field getField(final String fieldName, final Object object) { return field; } - @SneakyThrows - public static Object getFieldValue(final String fieldName, final Object object) { - log.trace("Getting value of field {}.{}", object.getClass().getSimpleName(), fieldName); - return getField(fieldName, object).get(object); - } + @SafeVarargs + public static T getFieldValue(final String fieldName, final Object object, final T... reified) { + if (reified == null || reified.length > 0) { + throw new IllegalArgumentException("Do not pass arguments as last parameter"); + } - public static T getFieldValue(final String fieldName, final Object object, final Class clazz) { - return clazz.cast(getFieldValue(fieldName, object)); + final Object value = getValueOf(getField(fieldName, object), object); + return getClassOf(reified).cast(value); } public static void setField(final String fieldName, final Object object, final Object value) { @@ -112,6 +112,11 @@ public static List getAnnotatedFieldsValues(final Object object, final Cl .toList(); } + @SuppressWarnings("unchecked") + public static Class getClassOf(final T[] array) { + return (Class) array.getClass().getComponentType(); + } + @SneakyThrows static Object getValueOf(final Field field, final Object object) { return field.get(object); diff --git a/spectrum/src/test/java/io/github/giulong/spectrum/drivers/AppiumGenericTest.java b/spectrum/src/test/java/io/github/giulong/spectrum/drivers/AppiumGenericTest.java index 06abd6c0d..de4c9966c 100644 --- a/spectrum/src/test/java/io/github/giulong/spectrum/drivers/AppiumGenericTest.java +++ b/spectrum/src/test/java/io/github/giulong/spectrum/drivers/AppiumGenericTest.java @@ -51,9 +51,8 @@ void beforeEach() { @Test @DisplayName("buildCapabilities should build a new instance of capabilities and set the capabilities from the yaml on it") void buildCapabilitiesAbsoluteAppPath() { - MockedConstruction desiredCapabilitiesMockedConstruction = mockConstruction(MutableCapabilities.class, (mock, context) -> { - assertEquals(capabilities, context.arguments().getFirst()); - }); + MockedConstruction desiredCapabilitiesMockedConstruction = mockConstruction(MutableCapabilities.class, + (mock, context) -> assertEquals(capabilities, context.arguments().getFirst())); when(configuration.getDrivers()).thenReturn(drivers); when(drivers.getAppiumGeneric()).thenReturn(appiumGenericConfiguration); @@ -61,7 +60,7 @@ void buildCapabilitiesAbsoluteAppPath() { appiumGeneric.buildCapabilities(); - final Capabilities actual = Reflections.getFieldValue("capabilities", appiumGeneric, Capabilities.class); + final Capabilities actual = Reflections.getFieldValue("capabilities", appiumGeneric); assertEquals(desiredCapabilitiesMockedConstruction.constructed().getFirst(), actual); desiredCapabilitiesMockedConstruction.close(); diff --git a/spectrum/src/test/java/io/github/giulong/spectrum/drivers/EspressoTest.java b/spectrum/src/test/java/io/github/giulong/spectrum/drivers/EspressoTest.java index bdd5ce905..6345a1332 100644 --- a/spectrum/src/test/java/io/github/giulong/spectrum/drivers/EspressoTest.java +++ b/spectrum/src/test/java/io/github/giulong/spectrum/drivers/EspressoTest.java @@ -50,9 +50,8 @@ void buildCapabilities() { final String appPath = path.toString(); final String appAbsolutePath = path.toAbsolutePath().toString(); - MockedConstruction desiredCapabilitiesMockedConstruction = mockConstruction(EspressoOptions.class, (mock, context) -> { - assertEquals(capabilities, context.arguments().getFirst()); - }); + MockedConstruction desiredCapabilitiesMockedConstruction = mockConstruction(EspressoOptions.class, + (mock, context) -> assertEquals(capabilities, context.arguments().getFirst())); when(configuration.getDrivers()).thenReturn(drivers); when(drivers.getEspresso()).thenReturn(espressoConfiguration); @@ -62,7 +61,7 @@ void buildCapabilities() { espresso.buildCapabilities(); - final EspressoOptions actual = Reflections.getFieldValue("capabilities", espresso, EspressoOptions.class); + final EspressoOptions actual = Reflections.getFieldValue("capabilities", espresso); assertEquals(desiredCapabilitiesMockedConstruction.constructed().getFirst(), actual); verify(capabilities).put(APP_CAPABILITY, appAbsolutePath); @@ -75,9 +74,8 @@ void buildCapabilities() { void buildCapabilitiesAbsoluteAppPath() { final String appPath = Path.of("absolute", "path").toAbsolutePath().toString(); - MockedConstruction desiredCapabilitiesMockedConstruction = mockConstruction(EspressoOptions.class, (mock, context) -> { - assertEquals(capabilities, context.arguments().getFirst()); - }); + MockedConstruction desiredCapabilitiesMockedConstruction = mockConstruction(EspressoOptions.class, + (mock, context) -> assertEquals(capabilities, context.arguments().getFirst())); when(configuration.getDrivers()).thenReturn(drivers); when(drivers.getEspresso()).thenReturn(espressoConfiguration); @@ -87,7 +85,7 @@ void buildCapabilitiesAbsoluteAppPath() { espresso.buildCapabilities(); - final EspressoOptions actual = Reflections.getFieldValue("capabilities", espresso, EspressoOptions.class); + final EspressoOptions actual = Reflections.getFieldValue("capabilities", espresso); assertEquals(desiredCapabilitiesMockedConstruction.constructed().getFirst(), actual); desiredCapabilitiesMockedConstruction.close(); diff --git a/spectrum/src/test/java/io/github/giulong/spectrum/drivers/Mac2Test.java b/spectrum/src/test/java/io/github/giulong/spectrum/drivers/Mac2Test.java index ad7886184..2a319089b 100644 --- a/spectrum/src/test/java/io/github/giulong/spectrum/drivers/Mac2Test.java +++ b/spectrum/src/test/java/io/github/giulong/spectrum/drivers/Mac2Test.java @@ -50,9 +50,8 @@ void beforeEach() { @Test @DisplayName("buildCapabilities should build a new instance of mac2Options and set the capabilities from the yaml on it") void buildCapabilitiesAbsoluteAppPath() { - MockedConstruction desiredCapabilitiesMockedConstruction = mockConstruction(Mac2Options.class, (mock, context) -> { - assertEquals(capabilities, context.arguments().getFirst()); - }); + MockedConstruction desiredCapabilitiesMockedConstruction = mockConstruction(Mac2Options.class, + (mock, context) -> assertEquals(capabilities, context.arguments().getFirst())); when(configuration.getDrivers()).thenReturn(drivers); when(drivers.getMac2()).thenReturn(mac2Configuration); @@ -60,7 +59,7 @@ void buildCapabilitiesAbsoluteAppPath() { mac2.buildCapabilities(); - final Mac2Options actual = Reflections.getFieldValue("capabilities", mac2, Mac2Options.class); + final Mac2Options actual = Reflections.getFieldValue("capabilities", mac2); assertEquals(desiredCapabilitiesMockedConstruction.constructed().getFirst(), actual); desiredCapabilitiesMockedConstruction.close(); diff --git a/spectrum/src/test/java/io/github/giulong/spectrum/drivers/UiAutomator2Test.java b/spectrum/src/test/java/io/github/giulong/spectrum/drivers/UiAutomator2Test.java index 3dd136c31..57b7af9db 100644 --- a/spectrum/src/test/java/io/github/giulong/spectrum/drivers/UiAutomator2Test.java +++ b/spectrum/src/test/java/io/github/giulong/spectrum/drivers/UiAutomator2Test.java @@ -51,9 +51,8 @@ void buildCapabilities() { final String appPath = path.toString(); final String appAbsolutePath = path.toAbsolutePath().toString(); - MockedConstruction desiredCapabilitiesMockedConstruction = mockConstruction(UiAutomator2Options.class, (mock, context) -> { - assertEquals(capabilities, context.arguments().getFirst()); - }); + MockedConstruction desiredCapabilitiesMockedConstruction = mockConstruction(UiAutomator2Options.class, + (mock, context) -> assertEquals(capabilities, context.arguments().getFirst())); when(configuration.getDrivers()).thenReturn(drivers); when(drivers.getUiAutomator2()).thenReturn(uiAutomator2Configuration); @@ -63,7 +62,7 @@ void buildCapabilities() { uiAutomator2.buildCapabilities(); - final UiAutomator2Options actual = Reflections.getFieldValue("capabilities", uiAutomator2, UiAutomator2Options.class); + final UiAutomator2Options actual = Reflections.getFieldValue("capabilities", uiAutomator2); assertEquals(desiredCapabilitiesMockedConstruction.constructed().getFirst(), actual); verify(capabilities).put(APP_CAPABILITY, appAbsolutePath); @@ -77,9 +76,8 @@ void buildCapabilities() { void buildCapabilitiesAbsoluteAppPath() { final String appPath = Path.of("absolute", "path").toAbsolutePath().toString(); - MockedConstruction desiredCapabilitiesMockedConstruction = mockConstruction(UiAutomator2Options.class, (mock, context) -> { - assertEquals(capabilities, context.arguments().getFirst()); - }); + MockedConstruction desiredCapabilitiesMockedConstruction = mockConstruction(UiAutomator2Options.class, + (mock, context) -> assertEquals(capabilities, context.arguments().getFirst())); when(configuration.getDrivers()).thenReturn(drivers); when(drivers.getUiAutomator2()).thenReturn(uiAutomator2Configuration); @@ -89,7 +87,7 @@ void buildCapabilitiesAbsoluteAppPath() { uiAutomator2.buildCapabilities(); - final UiAutomator2Options actual = Reflections.getFieldValue("capabilities", uiAutomator2, UiAutomator2Options.class); + final UiAutomator2Options actual = Reflections.getFieldValue("capabilities", uiAutomator2); assertEquals(desiredCapabilitiesMockedConstruction.constructed().getFirst(), actual); desiredCapabilitiesMockedConstruction.close(); diff --git a/spectrum/src/test/java/io/github/giulong/spectrum/drivers/WindowsTest.java b/spectrum/src/test/java/io/github/giulong/spectrum/drivers/WindowsTest.java index 97a653bd2..895234997 100644 --- a/spectrum/src/test/java/io/github/giulong/spectrum/drivers/WindowsTest.java +++ b/spectrum/src/test/java/io/github/giulong/spectrum/drivers/WindowsTest.java @@ -79,9 +79,8 @@ void configureWaitsOf() { @Test @DisplayName("buildCapabilities should build a new instance of windowsOptions and set the capabilities from the yaml on it") void buildCapabilitiesAbsoluteAppPath() { - MockedConstruction desiredCapabilitiesMockedConstruction = mockConstruction(WindowsOptions.class, (mock, context) -> { - assertEquals(capabilities, context.arguments().getFirst()); - }); + MockedConstruction desiredCapabilitiesMockedConstruction = mockConstruction(WindowsOptions.class, + (mock, context) -> assertEquals(capabilities, context.arguments().getFirst())); when(configuration.getDrivers()).thenReturn(drivers); when(drivers.getWindows()).thenReturn(windowsConfiguration); @@ -89,7 +88,7 @@ void buildCapabilitiesAbsoluteAppPath() { windows.buildCapabilities(); - final WindowsOptions actual = Reflections.getFieldValue("capabilities", windows, WindowsOptions.class); + final WindowsOptions actual = Reflections.getFieldValue("capabilities", windows); assertEquals(desiredCapabilitiesMockedConstruction.constructed().getFirst(), actual); desiredCapabilitiesMockedConstruction.close(); diff --git a/spectrum/src/test/java/io/github/giulong/spectrum/drivers/XCUITestTest.java b/spectrum/src/test/java/io/github/giulong/spectrum/drivers/XCUITestTest.java index 8b80d20c8..1a106e16a 100644 --- a/spectrum/src/test/java/io/github/giulong/spectrum/drivers/XCUITestTest.java +++ b/spectrum/src/test/java/io/github/giulong/spectrum/drivers/XCUITestTest.java @@ -56,9 +56,8 @@ void buildCapabilities() { final String appPath = path.toString(); final String appAbsolutePath = path.toAbsolutePath().toString(); - MockedConstruction desiredCapabilitiesMockedConstruction = mockConstruction(XCUITestOptions.class, (mock, context) -> { - assertEquals(capabilities, context.arguments().getFirst()); - }); + MockedConstruction desiredCapabilitiesMockedConstruction = mockConstruction(XCUITestOptions.class, + (mock, context) -> assertEquals(capabilities, context.arguments().getFirst())); when(configuration.getDrivers()).thenReturn(drivers); when(drivers.getXcuiTest()).thenReturn(xcuiTestConfiguration); @@ -68,7 +67,7 @@ void buildCapabilities() { xcuiTest.buildCapabilities(); - final XCUITestOptions actual = Reflections.getFieldValue("capabilities", xcuiTest, XCUITestOptions.class); + final XCUITestOptions actual = Reflections.getFieldValue("capabilities", xcuiTest); assertEquals(desiredCapabilitiesMockedConstruction.constructed().getFirst(), actual); verify(capabilities).put(APP_CAPABILITY, appAbsolutePath); @@ -82,9 +81,8 @@ void buildCapabilities() { void buildCapabilitiesAbsoluteAppPath() { final String appPath = Path.of("absolute", "path").toAbsolutePath().toString(); - MockedConstruction desiredCapabilitiesMockedConstruction = mockConstruction(XCUITestOptions.class, (mock, context) -> { - assertEquals(capabilities, context.arguments().getFirst()); - }); + MockedConstruction desiredCapabilitiesMockedConstruction = mockConstruction(XCUITestOptions.class, + (mock, context) -> assertEquals(capabilities, context.arguments().getFirst())); when(configuration.getDrivers()).thenReturn(drivers); when(drivers.getXcuiTest()).thenReturn(xcuiTestConfiguration); @@ -94,7 +92,7 @@ void buildCapabilitiesAbsoluteAppPath() { xcuiTest.buildCapabilities(); - final XCUITestOptions actual = Reflections.getFieldValue("capabilities", xcuiTest, XCUITestOptions.class); + final XCUITestOptions actual = Reflections.getFieldValue("capabilities", xcuiTest); assertEquals(desiredCapabilitiesMockedConstruction.constructed().getFirst(), actual); desiredCapabilitiesMockedConstruction.close(); diff --git a/spectrum/src/test/java/io/github/giulong/spectrum/internals/AppiumLogTest.java b/spectrum/src/test/java/io/github/giulong/spectrum/internals/AppiumLogTest.java index 678d1c890..6b22b945d 100644 --- a/spectrum/src/test/java/io/github/giulong/spectrum/internals/AppiumLogTest.java +++ b/spectrum/src/test/java/io/github/giulong/spectrum/internals/AppiumLogTest.java @@ -55,7 +55,7 @@ void writeFlush() { final char c = '\n'; appiumLog.write(c); - final StringBuffer stringBuffer = Reflections.getFieldValue("stringBuffer", appiumLog, StringBuffer.class); + final StringBuffer stringBuffer = Reflections.getFieldValue("stringBuffer", appiumLog); verify(stringBuffer).setLength(0); } @@ -67,7 +67,7 @@ void flush() { assertEquals(stringBuffers.getFirst(), Reflections.getFieldValue("stringBuffer", appiumLog)); appiumLog.flush(); - final StringBuffer stringBuffer = Reflections.getFieldValue("stringBuffer", appiumLog, StringBuffer.class); + final StringBuffer stringBuffer = Reflections.getFieldValue("stringBuffer", appiumLog); verify(stringBuffer).setLength(0); } diff --git a/spectrum/src/test/java/io/github/giulong/spectrum/internals/DriverLogTest.java b/spectrum/src/test/java/io/github/giulong/spectrum/internals/DriverLogTest.java index 11f74af32..8f6792b88 100644 --- a/spectrum/src/test/java/io/github/giulong/spectrum/internals/DriverLogTest.java +++ b/spectrum/src/test/java/io/github/giulong/spectrum/internals/DriverLogTest.java @@ -55,7 +55,7 @@ void writeFlush() { final char c = '\n'; driverLog.write(c); - final StringBuffer stringBuffer = Reflections.getFieldValue("stringBuffer", driverLog, StringBuffer.class); + final StringBuffer stringBuffer = Reflections.getFieldValue("stringBuffer", driverLog); verify(stringBuffer).setLength(0); } @@ -67,7 +67,7 @@ void flush() { assertEquals(stringBuffers.getFirst(), Reflections.getFieldValue("stringBuffer", driverLog)); driverLog.flush(); - final StringBuffer stringBuffer = Reflections.getFieldValue("stringBuffer", driverLog, StringBuffer.class); + final StringBuffer stringBuffer = Reflections.getFieldValue("stringBuffer", driverLog); verify(stringBuffer).setLength(0); } diff --git a/spectrum/src/test/java/io/github/giulong/spectrum/internals/page_factory/SpectrumLocatingElementHandlerTest.java b/spectrum/src/test/java/io/github/giulong/spectrum/internals/page_factory/SpectrumLocatingElementHandlerTest.java index 5d907b9d8..bcc695c13 100644 --- a/spectrum/src/test/java/io/github/giulong/spectrum/internals/page_factory/SpectrumLocatingElementHandlerTest.java +++ b/spectrum/src/test/java/io/github/giulong/spectrum/internals/page_factory/SpectrumLocatingElementHandlerTest.java @@ -50,7 +50,7 @@ class SpectrumLocatingElementHandlerTest { void constructor(final boolean secured) { final SpectrumLocatingElementHandler handler = new SpectrumLocatingElementHandler(elementLocator, secured); - Assertions.assertEquals(secured, Reflections.getFieldValue("secured", handler, Boolean.class)); + Assertions.assertEquals(secured, Reflections.getFieldValue("secured", handler)); } @SuppressWarnings({"checkstyle:IllegalThrows"}) diff --git a/spectrum/src/test/java/io/github/giulong/spectrum/utils/HtmlUtilsTest.java b/spectrum/src/test/java/io/github/giulong/spectrum/utils/HtmlUtilsTest.java index 5e19e248d..2af33c8b5 100644 --- a/spectrum/src/test/java/io/github/giulong/spectrum/utils/HtmlUtilsTest.java +++ b/spectrum/src/test/java/io/github/giulong/spectrum/utils/HtmlUtilsTest.java @@ -93,10 +93,10 @@ void sessionOpened() { htmlUtils.sessionOpened(); - assertEquals(videoTemplate, Reflections.getFieldValue("videoTemplate", htmlUtils, String.class)); - assertEquals(divTemplate, Reflections.getFieldValue("divTemplate", htmlUtils, String.class)); - assertEquals(divFrameTemplate, Reflections.getFieldValue("frameTemplate", htmlUtils, String.class)); - assertEquals(divImageTemplate, Reflections.getFieldValue("inlineImageTemplate", htmlUtils, String.class)); + assertEquals(videoTemplate, Reflections.getFieldValue("videoTemplate", htmlUtils)); + assertEquals(divTemplate, Reflections.getFieldValue("divTemplate", htmlUtils)); + assertEquals(divFrameTemplate, Reflections.getFieldValue("frameTemplate", htmlUtils)); + assertEquals(divImageTemplate, Reflections.getFieldValue("inlineImageTemplate", htmlUtils)); } @Test diff --git a/spectrum/src/test/java/io/github/giulong/spectrum/utils/ReflectionsTest.java b/spectrum/src/test/java/io/github/giulong/spectrum/utils/ReflectionsTest.java index a0dcd81d7..0f0bb856d 100644 --- a/spectrum/src/test/java/io/github/giulong/spectrum/utils/ReflectionsTest.java +++ b/spectrum/src/test/java/io/github/giulong/spectrum/utils/ReflectionsTest.java @@ -5,17 +5,14 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import org.junit.jupiter.params.provider.ValueSource; +import org.junit.jupiter.params.provider.*; import java.lang.reflect.Field; import java.lang.reflect.ParameterizedType; import java.util.List; import java.util.stream.Stream; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.params.provider.Arguments.arguments; class ReflectionsTest { @@ -76,7 +73,7 @@ void getFieldNotFound() { } @Test - @DisplayName("getFieldValue should return the value of the field with the provided name on the provided object") + @DisplayName("getFieldValue should return the value of the field with the provided name on the provided object, casted to the generic class") void getFieldValue() { final String fieldName = "fieldString"; final String value = "value"; @@ -85,14 +82,19 @@ void getFieldValue() { assertEquals(value, Reflections.getFieldValue(fieldName, dummy)); } - @Test - @DisplayName("getFieldValue should return the value of the field with the provided name on the provided object, casted to the provided class") - void getFieldValueCast() { - final String fieldName = "fieldString"; - final String value = "value"; - final Dummy dummy = new Dummy(value); + @DisplayName("getFieldValue should throw an IllegalArgumentException if reified args are passed") + @ParameterizedTest(name = "with reified {0}") + @NullSource + @MethodSource("getFieldValueExceptionValuesProvider") + void getFieldValueException(final Dummy[] reified) { + final Exception exception = assertThrows(IllegalArgumentException.class, () -> Reflections.getFieldValue("fieldString", new Dummy("value"), reified)); + assertEquals("Do not pass arguments as last parameter", exception.getMessage()); + } - assertEquals(value, Reflections.getFieldValue(fieldName, dummy, String.class)); + static Stream getFieldValueExceptionValuesProvider() { + return Stream.of( + arguments((Object) new Dummy[]{new Dummy("value")}) + ); } @Test diff --git a/spectrum/src/test/java/io/github/giulong/spectrum/utils/YamlUtilsTest.java b/spectrum/src/test/java/io/github/giulong/spectrum/utils/YamlUtilsTest.java index d9b67d114..bd8491e5f 100644 --- a/spectrum/src/test/java/io/github/giulong/spectrum/utils/YamlUtilsTest.java +++ b/spectrum/src/test/java/io/github/giulong/spectrum/utils/YamlUtilsTest.java @@ -79,7 +79,7 @@ void construction() { "LogSummaryReporter", "TxtSummaryReporter", "HtmlSummaryReporter" - ), Reflections.getFieldValue("yamlMapper", yamlUtils, YAMLMapper.class).getRegisteredModuleIds()); + ), ((YAMLMapper) Reflections.getFieldValue("yamlMapper", yamlUtils)).getRegisteredModuleIds()); assertEquals(Set.of( "jackson-datatype-jsr310", @@ -88,9 +88,9 @@ void construction() { "boolean", "Level", "Duration" - ), Reflections.getFieldValue("dynamicConfYamlMapper", yamlUtils, YAMLMapper.class).getRegisteredModuleIds()); + ), ((YAMLMapper) Reflections.getFieldValue("dynamicConfYamlMapper", yamlUtils)).getRegisteredModuleIds()); - assertFalse(Reflections.getFieldValue("writer", yamlUtils, ObjectWriter.class).isEnabled(SerializationFeature.FAIL_ON_EMPTY_BEANS)); + assertFalse(((ObjectWriter) Reflections.getFieldValue("writer", yamlUtils)).isEnabled(SerializationFeature.FAIL_ON_EMPTY_BEANS)); } @Test From 651668736e7f917cf62b34035d0877413dd9041b Mon Sep 17 00:00:00 2001 From: Giulio Longfils Date: Wed, 24 Sep 2025 20:38:21 +0200 Subject: [PATCH 09/13] refactor: resolving jackson readValue deprecation by using overloaded method --- .../java/io/github/giulong/spectrum/utils/YamlUtils.java | 4 ++-- .../io/github/giulong/spectrum/utils/YamlUtilsTest.java | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/spectrum/src/main/java/io/github/giulong/spectrum/utils/YamlUtils.java b/spectrum/src/main/java/io/github/giulong/spectrum/utils/YamlUtils.java index 86267dff2..d3b59bfc8 100644 --- a/spectrum/src/main/java/io/github/giulong/spectrum/utils/YamlUtils.java +++ b/spectrum/src/main/java/io/github/giulong/spectrum/utils/YamlUtils.java @@ -135,7 +135,7 @@ SimpleModule buildDynamicModuleFor(final Class clazz, final String file) { @SneakyThrows T read(final ObjectReader reader, final String file, final Class clazz) { - return reader.readValue(classLoader.getResource(file), clazz); + return reader.readValue(classLoader.getResourceAsStream(file), clazz); } T read(final FileProvider fileProvider, final String file, final Class clazz) { @@ -175,6 +175,6 @@ void updateWithFile(final T t, final String file, final FileProvider filePro fileProvider .augment(yamlMapper) .withValueToUpdate(t) - .readValue(classLoader.getResource(fileFound)); + .readValue(classLoader.getResourceAsStream(fileFound)); } } diff --git a/spectrum/src/test/java/io/github/giulong/spectrum/utils/YamlUtilsTest.java b/spectrum/src/test/java/io/github/giulong/spectrum/utils/YamlUtilsTest.java index bd8491e5f..ac0766cea 100644 --- a/spectrum/src/test/java/io/github/giulong/spectrum/utils/YamlUtilsTest.java +++ b/spectrum/src/test/java/io/github/giulong/spectrum/utils/YamlUtilsTest.java @@ -17,7 +17,6 @@ import java.io.IOException; import java.io.InputStream; -import java.net.URL; import java.util.Objects; import java.util.Set; @@ -163,7 +162,7 @@ void readDynamicDeserializable() throws IOException { Reflections.setField("dynamicConfYamlMapper", yamlUtils, yamlMapper); when(yamlMapper.reader()).thenReturn(reader); - when(reader.readValue(any(URL.class), eq(clazz))).thenReturn(testYaml); + when(reader.readValue(any(InputStream.class), eq(clazz))).thenReturn(testYaml); when(reader.withValueToUpdate(testYaml)).thenReturn(reader); when(reader.readValue(jsonNode)).thenReturn(testYaml); @@ -180,7 +179,7 @@ void updateWithFile(final String file) throws IOException { when(fileProvider.find(file)).thenReturn(file); when(fileProvider.augment(yamlMapper)).thenReturn(reader); when(reader.withValueToUpdate(testYaml)).thenReturn(reader); - when(reader.readValue(any(URL.class))).thenReturn(testYaml); + when(reader.readValue(any(InputStream.class))).thenReturn(testYaml); yamlUtils.updateWithClientFile(testYaml, file); } @@ -209,7 +208,7 @@ void updateWithInternalFile() throws IOException { when(fileProvider.find(file)).thenReturn(file); when(fileProvider.augment(yamlMapper)).thenReturn(reader); when(reader.withValueToUpdate(testYaml)).thenReturn(reader); - when(reader.readValue(any(URL.class))).thenReturn(testYaml); + when(reader.readValue(any(InputStream.class))).thenReturn(testYaml); yamlUtils.updateWithInternalFile(testYaml, file); } From 948827867303b232353958db1b7d10f9ec265cdf Mon Sep 17 00:00:00 2001 From: Giulio Longfils Date: Wed, 24 Sep 2025 21:26:15 +0200 Subject: [PATCH 10/13] build: removing EDGE_BINARY env var in gh actions since EdgeWebDriver issue 102 is closed --- .github/workflows/build.yml | 4 ---- it-bidi/src/test/resources/configuration.yaml | 2 -- it/src/test/resources/configuration.yaml | 2 -- 3 files changed, 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index be75b2586..bc8796a7c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -61,14 +61,10 @@ jobs: profiles: browsers directives: -DbrowsersTests moduleName: it - env: - EDGE_BINARY: /usr/bin/microsoft-edge - os: macos-latest profiles: macos directives: -DmacosTests moduleName: it-macos - env: - EDGE_BINARY: /usr/bin/microsoft-edge - os: windows-latest profiles: browsers directives: -DbrowsersTests diff --git a/it-bidi/src/test/resources/configuration.yaml b/it-bidi/src/test/resources/configuration.yaml index 0ecf33e73..332584c27 100644 --- a/it-bidi/src/test/resources/configuration.yaml +++ b/it-bidi/src/test/resources/configuration.yaml @@ -14,8 +14,6 @@ drivers: edge: args: - --headless=new - experimentalOptions: - binary: ${EDGE_BINARY:-} video: frames: diff --git a/it/src/test/resources/configuration.yaml b/it/src/test/resources/configuration.yaml index 3c1c2a00a..49d6aa900 100644 --- a/it/src/test/resources/configuration.yaml +++ b/it/src/test/resources/configuration.yaml @@ -13,8 +13,6 @@ drivers: edge: args: - --headless=new - experimentalOptions: - binary: ${EDGE_BINARY:-} video: frames: From ab1ae3c54f24cb36b35a718b8d89eafbe4f5bbcf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Sep 2025 19:18:28 +0000 Subject: [PATCH 11/13] build(deps): bump com.puppycrawl.tools:checkstyle from 11.0.1 to 11.1.0 Bumps [com.puppycrawl.tools:checkstyle](https://github.com/checkstyle/checkstyle) from 11.0.1 to 11.1.0. - [Release notes](https://github.com/checkstyle/checkstyle/releases) - [Commits](https://github.com/checkstyle/checkstyle/compare/checkstyle-11.0.1...checkstyle-11.1.0) --- updated-dependencies: - dependency-name: com.puppycrawl.tools:checkstyle dependency-version: 11.1.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9a0101d99..e43edaa4b 100644 --- a/pom.xml +++ b/pom.xml @@ -323,7 +323,7 @@ com.puppycrawl.tools checkstyle - 11.0.1 + 11.1.0 com.github.sevntu-checkstyle From 7179a6362f9251a72ddde61eec1cea74536c97ff Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Sep 2025 19:20:25 +0000 Subject: [PATCH 12/13] build(deps): bump net.datafaker:datafaker from 2.5.0 to 2.5.1 Bumps [net.datafaker:datafaker](https://github.com/datafaker-net/datafaker) from 2.5.0 to 2.5.1. - [Release notes](https://github.com/datafaker-net/datafaker/releases) - [Changelog](https://github.com/datafaker-net/datafaker/blob/main/RELEASE_PROCESS.md) - [Commits](https://github.com/datafaker-net/datafaker/compare/2.5.0...2.5.1) --- updated-dependencies: - dependency-name: net.datafaker:datafaker dependency-version: 2.5.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9a0101d99..dd6fdb39d 100644 --- a/pom.xml +++ b/pom.xml @@ -250,7 +250,7 @@ net.datafaker datafaker - 2.5.0 + 2.5.1 From af86dd960f2103ea05b1f74807f1e3df27c232a2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Sep 2025 20:15:20 +0000 Subject: [PATCH 13/13] build(deps): bump org.sonatype.central:central-publishing-maven-plugin Bumps [org.sonatype.central:central-publishing-maven-plugin](https://github.com/sonatype/central-publishing-maven-plugin) from 0.8.0 to 0.9.0. - [Commits](https://github.com/sonatype/central-publishing-maven-plugin/commits) --- updated-dependencies: - dependency-name: org.sonatype.central:central-publishing-maven-plugin dependency-version: 0.9.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- spectrum/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spectrum/pom.xml b/spectrum/pom.xml index 87fa70466..cad716f5b 100644 --- a/spectrum/pom.xml +++ b/spectrum/pom.xml @@ -363,7 +363,7 @@ org.sonatype.central central-publishing-maven-plugin - 0.8.0 + 0.9.0 true central