From 5f9ba620b4d05ca002a30f97a5bf3e82ff62df13 Mon Sep 17 00:00:00 2001 From: Valery Yatsynovich Date: Thu, 28 Mar 2024 01:44:57 +0400 Subject: [PATCH] refactor: Remove usages of Guava's `@VisibleForTesting` (#2138) --- .../filters/AppiumUserAgentFilter.java | 4 +-- .../local/AppiumDriverLocalService.java | 4 +-- .../internal/AppiumUserAgentFilterTest.java | 26 +++++++------------ 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/src/main/java/io/appium/java_client/internal/filters/AppiumUserAgentFilter.java b/src/main/java/io/appium/java_client/internal/filters/AppiumUserAgentFilter.java index 50e9449e0..7c68cfad1 100644 --- a/src/main/java/io/appium/java_client/internal/filters/AppiumUserAgentFilter.java +++ b/src/main/java/io/appium/java_client/internal/filters/AppiumUserAgentFilter.java @@ -16,7 +16,6 @@ package io.appium.java_client.internal.filters; -import com.google.common.annotations.VisibleForTesting; import com.google.common.net.HttpHeaders; import io.appium.java_client.internal.Config; import org.openqa.selenium.remote.http.AddSeleniumUserAgent; @@ -55,8 +54,7 @@ private static String buildUserAgentHeaderValue(@Nonnull String previousUA) { * @return whether the given User Agent includes Appium UA * like by this filter. */ - @VisibleForTesting - public static boolean containsAppiumName(@Nullable String userAgent) { + private static boolean containsAppiumName(@Nullable String userAgent) { return userAgent != null && userAgent.toLowerCase().contains(USER_AGENT_PREFIX.toLowerCase()); } diff --git a/src/main/java/io/appium/java_client/service/local/AppiumDriverLocalService.java b/src/main/java/io/appium/java_client/service/local/AppiumDriverLocalService.java index 666f2ba06..8026300ad 100644 --- a/src/main/java/io/appium/java_client/service/local/AppiumDriverLocalService.java +++ b/src/main/java/io/appium/java_client/service/local/AppiumDriverLocalService.java @@ -16,7 +16,6 @@ package io.appium.java_client.service.local; -import com.google.common.annotations.VisibleForTesting; import lombok.Getter; import lombok.SneakyThrows; import org.openqa.selenium.os.ExternalProcess; @@ -403,8 +402,7 @@ public void addSlf4jLogMessageConsumer(BiConsumer userAgentParams() { - return Stream.of( - Arguments.of("selenium/4.5.0 (java mac)", false), - Arguments.of("appium/8.2.0 (selenium/4.5.0 (java mac))", true), - Arguments.of("APPIUM/8.2.0 (selenium/4.5.0 (java mac))", true), - Arguments.of("something (Appium/8.2.0 (selenium/4.5.0 (java mac)))", true), - Arguments.of("something (appium/8.2.0 (selenium/4.5.0 (java mac)))", true) - ); - } - @ParameterizedTest - @MethodSource("userAgentParams") - void validUserAgentIfContainsAppiumName(String userAgent, boolean expected) { - assertEquals(AppiumUserAgentFilter.containsAppiumName(userAgent), expected); + @ValueSource(strings = { + "appium/8.2.0 (selenium/4.5.0 (java mac))", + "APPIUM/8.2.0 (selenium/4.5.0 (java mac))", + "something (Appium/8.2.0 (selenium/4.5.0 (java mac)))", + "something (appium/8.2.0 (selenium/4.5.0 (java mac)))" + }) + void validUserAgentIfContainsAppiumName(String userAgent) { + assertEquals(AppiumUserAgentFilter.buildUserAgent(userAgent), userAgent); } @Test