From a2d70fe0a310573d89943d61770384f23cb3bd21 Mon Sep 17 00:00:00 2001 From: Yuya Ebihara Date: Fri, 8 Nov 2024 12:42:44 +0900 Subject: [PATCH] Fix warning in TestCredentialsOptionsConfigurer Also, rename credentials method to loadCredentials. --- .../bigquery/TestCredentialsOptionsConfigurer.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plugin/trino-bigquery/src/test/java/io/trino/plugin/bigquery/TestCredentialsOptionsConfigurer.java b/plugin/trino-bigquery/src/test/java/io/trino/plugin/bigquery/TestCredentialsOptionsConfigurer.java index 86757ad2ce4f0..271997e7d8385 100644 --- a/plugin/trino-bigquery/src/test/java/io/trino/plugin/bigquery/TestCredentialsOptionsConfigurer.java +++ b/plugin/trino-bigquery/src/test/java/io/trino/plugin/bigquery/TestCredentialsOptionsConfigurer.java @@ -15,6 +15,7 @@ import com.google.auth.Credentials; import com.google.auth.oauth2.GoogleCredentials; +import com.google.common.io.Resources; import org.junit.jupiter.api.Test; import java.io.IOException; @@ -36,7 +37,7 @@ public void testConfigurationOnly() public void testCredentialsOnly() throws Exception { - String projectId = resolveProjectId(Optional.empty(), credentials()); + String projectId = resolveProjectId(Optional.empty(), loadCredentials()); assertThat(projectId).isEqualTo("presto-bq-credentials-test"); } @@ -44,13 +45,13 @@ public void testCredentialsOnly() public void testBothConfigurationAndCredentials() throws Exception { - String projectId = resolveProjectId(Optional.of("pid"), credentials()); + String projectId = resolveProjectId(Optional.of("pid"), loadCredentials()); assertThat(projectId).isEqualTo("pid"); } - private Optional credentials() + private static Optional loadCredentials() throws IOException { - return Optional.of(GoogleCredentials.fromStream(getClass().getResourceAsStream("/test-account.json"))); + return Optional.of(GoogleCredentials.fromStream(Resources.getResource("test-account.json").openStream())); } }