Skip to content

Commit

Permalink
Fix warning in TestCredentialsOptionsConfigurer
Browse files Browse the repository at this point in the history
Also, rename credentials method to loadCredentials.
  • Loading branch information
ebyhr authored and wendigo committed Nov 8, 2024
1 parent a7da8d8 commit cd72e44
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -36,21 +37,21 @@ 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");
}

@Test
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> credentials()
private static Optional<Credentials> loadCredentials()
throws IOException
{
return Optional.of(GoogleCredentials.fromStream(getClass().getResourceAsStream("/test-account.json")));
return Optional.of(GoogleCredentials.fromStream(Resources.getResource("test-account.json").openStream()));
}
}

0 comments on commit cd72e44

Please sign in to comment.