Skip to content

Commit

Permalink
refactor: Remove usages of Guava's @VisibleForTesting (#2138)
Browse files Browse the repository at this point in the history
  • Loading branch information
valfirst authored Mar 27, 2024
1 parent 48f0d4f commit 5f9ba62
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -403,8 +402,7 @@ public void addSlf4jLogMessageConsumer(BiConsumer<String, Slf4jLogMessageContext
});
}

@VisibleForTesting
static Slf4jLogMessageContext parseSlf4jContextFromLogMessage(String logMessage) {
private static Slf4jLogMessageContext parseSlf4jContextFromLogMessage(String logMessage) {
Matcher m = LOGGER_CONTEXT_PATTERN.matcher(logMessage);
String loggerName = APPIUM_SERVICE_SLF4J_LOGGER_PREFIX;
Level level = INFO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
import io.appium.java_client.internal.filters.AppiumUserAgentFilter;
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 java.util.stream.Stream;
import org.junit.jupiter.params.provider.ValueSource;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand All @@ -17,20 +14,15 @@ void validateUserAgent() {
assertTrue(AppiumUserAgentFilter.USER_AGENT.startsWith("appium/"));
}

public static Stream<Arguments> 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
Expand Down

0 comments on commit 5f9ba62

Please sign in to comment.