Skip to content

Commit

Permalink
Automatic code cleanup.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 606265105
Change-Id: If4ca56ac5a32c6c4326d3f03cf9a2cf3e6827aff
  • Loading branch information
cpovirk authored and copybara-github committed Feb 12, 2024
1 parent 89222e2 commit c3db33e
Show file tree
Hide file tree
Showing 25 changed files with 148 additions and 200 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.truth.Truth8;
import java.io.IOException;
import java.net.URI;
import java.nio.file.FileSystem;
Expand Down Expand Up @@ -66,7 +65,7 @@ public void noOutputTest() throws IOException {

@Test
public void singleJarInputFile() throws IOException {
Truth8.assertThat(
assertThat(
runDexer(NO_POSITIONS, NO_LOCALS, MULTIDEX, EXAMPLE_JAR_FILE_1).stream()
.map(Path::getFileName)
.map(Path::toString))
Expand All @@ -75,7 +74,7 @@ public void singleJarInputFile() throws IOException {

@Test
public void multipleJarInputFiles() throws IOException {
Truth8.assertThat(
assertThat(
runDexer(NO_POSITIONS, NO_LOCALS, MULTIDEX, EXAMPLE_JAR_FILE_1, EXAMPLE_JAR_FILE_2)
.stream()
.map(Path::getFileName)
Expand All @@ -87,14 +86,14 @@ public void multipleJarInputFiles() throws IOException {
public void outputZipFile() throws IOException {
List<Path> out =
runDexerWithOutput("foo.dex.zip", NO_POSITIONS, NO_LOCALS, MULTIDEX, EXAMPLE_JAR_FILE_1);
Truth8.assertThat(out.stream().map(Path::getFileName).map(Path::toString))
assertThat(out.stream().map(Path::getFileName).map(Path::toString))
.containsExactly("foo.dex.zip");
assertThat(archiveFiles(out.get(0))).containsExactly("classes.dex");
}

@Test
public void useMultipleThreads() throws IOException {
Truth8.assertThat(
assertThat(
runDexer(NUM_THREADS_5, NO_POSITIONS, NO_LOCALS, EXAMPLE_JAR_FILE_1).stream()
.map(Path::getFileName)
.map(Path::toString))
Expand All @@ -103,7 +102,7 @@ public void useMultipleThreads() throws IOException {

@Test
public void withPositions() throws IOException {
Truth8.assertThat(
assertThat(
runDexer(NO_LOCALS, MULTIDEX, EXAMPLE_JAR_FILE_1).stream()
.map(Path::getFileName)
.map(Path::toString))
Expand All @@ -112,7 +111,7 @@ public void withPositions() throws IOException {

@Test
public void withLocals() throws IOException {
Truth8.assertThat(
assertThat(
runDexer(NO_POSITIONS, MULTIDEX, EXAMPLE_JAR_FILE_1).stream()
.map(Path::getFileName)
.map(Path::toString))
Expand All @@ -121,7 +120,7 @@ public void withLocals() throws IOException {

@Test
public void withoutMultidex() throws IOException {
Truth8.assertThat(
assertThat(
runDexer(NO_POSITIONS, NO_LOCALS, EXAMPLE_JAR_FILE_1).stream()
.map(Path::getFileName)
.map(Path::toString))
Expand All @@ -130,7 +129,7 @@ public void withoutMultidex() throws IOException {

@Test
public void writeToNamedDexFile() throws IOException {
Truth8.assertThat(
assertThat(
runDexerWithOutput("named-output.dex", EXAMPLE_JAR_FILE_1).stream()
.map(Path::getFileName)
.map(Path::toString))
Expand All @@ -140,8 +139,7 @@ public void writeToNamedDexFile() throws IOException {
@Test
public void keepClassesSingleDexTest() throws IOException {
List<Path> out = runDexerWithOutput("out.zip", "--keep-classes", EXAMPLE_JAR_FILE_1);
Truth8.assertThat(out.stream().map(Path::getFileName).map(Path::toString))
.containsExactly("out.zip");
assertThat(out.stream().map(Path::getFileName).map(Path::toString)).containsExactly("out.zip");
assertThat(archiveFiles(out.get(0)))
.containsExactly(
"classes.dex",
Expand All @@ -152,8 +150,7 @@ public void keepClassesSingleDexTest() throws IOException {
public void keepClassesMultiDexTest() throws IOException {
List<Path> out =
runDexerWithOutput("out.zip", "--keep-classes", "--multi-dex", EXAMPLE_JAR_FILE_1);
Truth8.assertThat(out.stream().map(Path::getFileName).map(Path::toString))
.containsExactly("out.zip");
assertThat(out.stream().map(Path::getFileName).map(Path::toString)).containsExactly("out.zip");
assertThat(archiveFiles(out.get(0)))
.containsExactly(
"classes.dex",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.ListMultimap;
import com.google.common.truth.Truth8;
import com.google.devtools.build.docgen.BuildDocCollector.DocumentationOrigin;
import com.google.devtools.build.skydoc.rendering.proto.StardocOutputProtos.AttributeInfo;
import com.google.devtools.build.skydoc.rendering.proto.StardocOutputProtos.AttributeType;
Expand Down Expand Up @@ -145,7 +144,7 @@ public void collectModuleInfoDocs_basicFunctionality() throws Exception {
.containsAtLeastElementsIn(PredefinedAttributes.COMMON_ATTRIBUTES.values());
assertThat(attributes)
.containsAtLeastElementsIn(PredefinedAttributes.BINARY_ATTRIBUTES.values());
Truth8.assertThat(
assertThat(
attributes.stream()
.map(RuleDocumentationAttribute::getAttributeName)
.filter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.truth.Truth8;
import com.google.devtools.build.lib.analysis.config.BuildOptions;
import com.google.devtools.build.lib.analysis.config.BuildOptionsView;
import com.google.devtools.build.lib.analysis.config.FragmentOptions;
Expand Down Expand Up @@ -128,8 +127,7 @@ public void lateBoundAttributeInExecConfiguration() throws Exception {
SkyframeExecutorTestUtils.getExistingConfiguredTargets(
skyframeExecutor, Label.parseCanonical("//foo:latebound_dep")));
assertThat(deps).hasSize(1);
Truth8.assertThat(
deps.stream().filter(d -> getConfiguration(d).isExecConfiguration()).findFirst())
assertThat(deps.stream().filter(d -> getConfiguration(d).isExecConfiguration()).findFirst())
.isPresent();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.eventbus.EventBus;
import com.google.common.truth.Truth8;
import com.google.devtools.build.lib.actions.AbstractAction;
import com.google.devtools.build.lib.actions.Action;
import com.google.devtools.build.lib.actions.ActionExecutionContext;
Expand Down Expand Up @@ -274,7 +273,7 @@ public void testBuilderWithJarExecutableAndParameterFile2() throws Exception {
spawn.getInputFiles().toList().stream()
.filter(i -> i instanceof VirtualActionInput)
.findFirst();
Truth8.assertThat(input).isPresent();
assertThat(input).isPresent();
VirtualActionInput paramFile = (VirtualActionInput) input.get();
assertThat(paramFile.getBytes().toString(ISO_8859_1).trim()).isEqualTo("-X");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertThrows;

import com.google.common.truth.Truth8;
import com.google.devtools.build.lib.authandtls.AuthAndTLSOptions.CredentialHelperOption;
import com.google.devtools.build.lib.authandtls.AuthAndTLSOptions.CredentialHelperOptionConverter;
import com.google.devtools.common.options.OptionsParsingException;
Expand All @@ -34,51 +33,51 @@ public class CredentialHelperOptionConverterTest {
public void exactScope() throws Exception {
CredentialHelperOption helper1 =
CredentialHelperOptionConverter.INSTANCE.convert("example.com=foo");
Truth8.assertThat(helper1.getScope()).hasValue("example.com");
assertThat(helper1.getScope()).hasValue("example.com");
assertThat(helper1.getPath()).isEqualTo("foo");
}

@Test
public void wildcardScope() throws Exception {
CredentialHelperOption helper1 =
CredentialHelperOptionConverter.INSTANCE.convert("*.example.com=foo");
Truth8.assertThat(helper1.getScope()).hasValue("*.example.com");
assertThat(helper1.getScope()).hasValue("*.example.com");
assertThat(helper1.getPath()).isEqualTo("foo");
}

@Test
public void punycodeScope() throws Exception {
CredentialHelperOption helper1 =
CredentialHelperOptionConverter.INSTANCE.convert("münchen.de=foo");
Truth8.assertThat(helper1.getScope()).hasValue("xn--mnchen-3ya.de");
assertThat(helper1.getScope()).hasValue("xn--mnchen-3ya.de");
assertThat(helper1.getPath()).isEqualTo("foo");

CredentialHelperOption helper2 =
CredentialHelperOptionConverter.INSTANCE.convert("*.köln.de=foo");
Truth8.assertThat(helper2.getScope()).hasValue("*.xn--kln-sna.de");
assertThat(helper2.getScope()).hasValue("*.xn--kln-sna.de");
assertThat(helper2.getPath()).isEqualTo("foo");
}

@Test
public void absolutePath() throws Exception {
CredentialHelperOption helper1 =
CredentialHelperOptionConverter.INSTANCE.convert("/absolute/path");
Truth8.assertThat(helper1.getScope()).isEmpty();
assertThat(helper1.getScope()).isEmpty();
assertThat(helper1.getPath()).isEqualTo("/absolute/path");
}

@Test
public void rootRelativePath() throws Exception {
CredentialHelperOption helper1 =
CredentialHelperOptionConverter.INSTANCE.convert("%workspace%/path");
Truth8.assertThat(helper1.getScope()).isEmpty();
assertThat(helper1.getScope()).isEmpty();
assertThat(helper1.getPath()).isEqualTo("%workspace%/path");
}

@Test
public void pathLookup() throws Exception {
CredentialHelperOption helper1 = CredentialHelperOptionConverter.INSTANCE.convert("foo");
Truth8.assertThat(helper1.getScope()).isEmpty();
assertThat(helper1.getScope()).isEmpty();
assertThat(helper1.getPath()).isEqualTo("foo");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.common.eventbus.EventBus;
import com.google.common.truth.Truth8;
import com.google.devtools.build.lib.authandtls.credentialhelper.CredentialHelperEnvironment;
import com.google.devtools.build.lib.authandtls.credentialhelper.CredentialHelperProvider;
import com.google.devtools.build.lib.events.Reporter;
Expand Down Expand Up @@ -52,7 +51,7 @@ public void testNetrc_emptyEnv_shouldIgnore() throws Exception {
ImmutableMap<String, String> clientEnv = ImmutableMap.of();
FileSystem fileSystem = new InMemoryFileSystem(DigestHashFunction.SHA256);

Truth8.assertThat(GoogleAuthUtils.newCredentialsFromNetrc(clientEnv, fileSystem)).isEmpty();
assertThat(GoogleAuthUtils.newCredentialsFromNetrc(clientEnv, fileSystem)).isEmpty();
}

@Test
Expand All @@ -61,7 +60,7 @@ public void testNetrc_netrcNotExist_shouldIgnore() throws Exception {
ImmutableMap<String, String> clientEnv = ImmutableMap.of("HOME", home);
FileSystem fileSystem = new InMemoryFileSystem(DigestHashFunction.SHA256);

Truth8.assertThat(GoogleAuthUtils.newCredentialsFromNetrc(clientEnv, fileSystem)).isEmpty();
assertThat(GoogleAuthUtils.newCredentialsFromNetrc(clientEnv, fileSystem)).isEmpty();
}

@Test
Expand All @@ -75,7 +74,7 @@ public void testNetrc_netrcExist_shouldUse() throws Exception {
Optional<Credentials> credentials =
GoogleAuthUtils.newCredentialsFromNetrc(clientEnv, fileSystem);

Truth8.assertThat(credentials).isPresent();
assertThat(credentials).isPresent();
assertRequestMetadata(
credentials.get().getRequestMetadata(URI.create("https://foo.example.org")),
"foouser",
Expand All @@ -95,7 +94,7 @@ public void testNetrc_netrcFromNetrcEnvExist_shouldUse() throws Exception {
Optional<Credentials> credentials =
GoogleAuthUtils.newCredentialsFromNetrc(clientEnv, fileSystem);

Truth8.assertThat(credentials).isPresent();
assertThat(credentials).isPresent();
assertRequestMetadata(
credentials.get().getRequestMetadata(URI.create("https://foo.example.org")),
"baruser",
Expand All @@ -111,7 +110,7 @@ public void testNetrc_netrcFromNetrcEnvNotExist_shouldIgnore() throws Exception
Scratch scratch = new Scratch(fileSystem);
scratch.file(home + "/.netrc", "machine foo.example.org login foouser password foopass");

Truth8.assertThat(GoogleAuthUtils.newCredentialsFromNetrc(clientEnv, fileSystem)).isEmpty();
assertThat(GoogleAuthUtils.newCredentialsFromNetrc(clientEnv, fileSystem)).isEmpty();
}

@Test
Expand Down Expand Up @@ -145,10 +144,9 @@ public void testCredentialHelperProvider() throws Exception {
CredentialHelperProvider credentialHelperProvider1 =
newCredentialHelperProvider(
credentialHelperEnvironment, commandLinePathFactory, ImmutableList.of());
Truth8.assertThat(
credentialHelperProvider1.findCredentialHelper(URI.create("https://example.com")))
assertThat(credentialHelperProvider1.findCredentialHelper(URI.create("https://example.com")))
.isEmpty();
Truth8.assertThat(
assertThat(
credentialHelperProvider1.findCredentialHelper(URI.create("https://foo.example.com")))
.isEmpty();

Expand Down Expand Up @@ -203,7 +201,7 @@ public void testCredentialHelperProvider() throws Exception {
.get()
.getPath())
.isEqualTo(exampleComHelper);
Truth8.assertThat(
assertThat(
credentialHelperProvider4.findCredentialHelper(URI.create("https://foo.example.com")))
.isEmpty();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import static com.google.common.truth.Truth.assertThat;

import com.google.common.base.Preconditions;
import com.google.common.truth.Truth8;
import com.google.devtools.build.lib.vfs.DigestHashFunction;
import com.google.devtools.build.lib.vfs.FileSystem;
import com.google.devtools.build.lib.vfs.Path;
Expand Down Expand Up @@ -66,22 +65,15 @@ private void setUpHelper(Path path) throws Exception {
public void noHelpersConfigured() {
CredentialHelperProvider provider = CredentialHelperProvider.builder().build();

Truth8.assertThat(provider.findCredentialHelper(URI.create("http://example.com/foo")))
.isEmpty();
Truth8.assertThat(provider.findCredentialHelper(URI.create("https://example.com/foo")))
.isEmpty();
Truth8.assertThat(provider.findCredentialHelper(URI.create("grpc://example.com/foo")))
.isEmpty();
Truth8.assertThat(provider.findCredentialHelper(URI.create("grpcs://example.com/foo")))
.isEmpty();
Truth8.assertThat(provider.findCredentialHelper(URI.create("custom://example.com/foo")))
.isEmpty();
assertThat(provider.findCredentialHelper(URI.create("http://example.com/foo"))).isEmpty();
assertThat(provider.findCredentialHelper(URI.create("https://example.com/foo"))).isEmpty();
assertThat(provider.findCredentialHelper(URI.create("grpc://example.com/foo"))).isEmpty();
assertThat(provider.findCredentialHelper(URI.create("grpcs://example.com/foo"))).isEmpty();
assertThat(provider.findCredentialHelper(URI.create("custom://example.com/foo"))).isEmpty();

Truth8.assertThat(
provider.findCredentialHelper(URI.create("https://subdomain.example.com/bar")))
.isEmpty();
Truth8.assertThat(provider.findCredentialHelper(URI.create("https://other-domain.com")))
assertThat(provider.findCredentialHelper(URI.create("https://subdomain.example.com/bar")))
.isEmpty();
assertThat(provider.findCredentialHelper(URI.create("https://other-domain.com"))).isEmpty();
}

@Test
Expand All @@ -90,8 +82,7 @@ public void uriWithoutHostComponent() throws Exception {
CredentialHelperProvider provider =
CredentialHelperProvider.builder().add("example.com", helper).build();

Truth8.assertThat(provider.findCredentialHelper(URI.create("unix:///path/to/socket")))
.isEmpty();
assertThat(provider.findCredentialHelper(URI.create("unix:///path/to/socket"))).isEmpty();
}

@Test
Expand Down Expand Up @@ -302,17 +293,16 @@ public void preferMostSpecificWildcardMatch() throws Exception {

@Test
public void parentDomain() {
Truth8.assertThat(CredentialHelperProvider.parentDomain("com")).isEmpty();
assertThat(CredentialHelperProvider.parentDomain("com")).isEmpty();

Truth8.assertThat(CredentialHelperProvider.parentDomain("foo.example.com"))
.hasValue("example.com");
Truth8.assertThat(CredentialHelperProvider.parentDomain("example.com")).hasValue("com");
assertThat(CredentialHelperProvider.parentDomain("foo.example.com")).hasValue("example.com");
assertThat(CredentialHelperProvider.parentDomain("example.com")).hasValue("com");

// Punycode URIs (münchen.de).
Truth8.assertThat(CredentialHelperProvider.parentDomain("foo.xn--mnchen-3ya.de"))
assertThat(CredentialHelperProvider.parentDomain("foo.xn--mnchen-3ya.de"))
.hasValue("xn--mnchen-3ya.de");
Truth8.assertThat(CredentialHelperProvider.parentDomain("bar.foo.xn--mnchen-3ya.de"))
assertThat(CredentialHelperProvider.parentDomain("bar.foo.xn--mnchen-3ya.de"))
.hasValue("foo.xn--mnchen-3ya.de");
Truth8.assertThat(CredentialHelperProvider.parentDomain("xn--mnchen-3ya.de")).hasValue("de");
assertThat(CredentialHelperProvider.parentDomain("xn--mnchen-3ya.de")).hasValue("de");
}
}
Loading

0 comments on commit c3db33e

Please sign in to comment.