Skip to content

Commit

Permalink
Migrate most usages of Truth8.assertThat to equivalent usages of `T…
Browse files Browse the repository at this point in the history
…ruth.assertThat`, and qualify others.

By "qualify," I mean that, instead of static importing `Truth8.assertThat`, we write "`Truth8.assertThat(...)`" at the call site.

This is normally the opposite of what we recommend. However, it's a necessary step in our migration: We are copying all the `Truth8` methods to `Truth`, and we can't do that if any files static import both `Truth.assertThat` and `Truth8.assertThat` (because it produces a compile error about ambiguous overloads). To unblock that, we're moving callers away from the static import.

We will update static analysis to stop suggesting the import.

A later step will migrate these callers to the new `Truth.assertThat` methods, which we will static import.

The `Truth8` methods will be hidden in the future. All callers will use `Truth`.

PiperOrigin-RevId: 603073706
  • Loading branch information
cpovirk authored and Guice Team committed Jan 31, 2024
1 parent 5a4e23a commit 4f94f00
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ maven_install(
"com.google.dagger:dagger:2.22.1",
"com.google.dagger:dagger-producers:2.22.1",
"com.google.errorprone:error_prone_annotations:2.18.0",
"com.google.guava:guava:32.0.0-jre",
"com.google.guava:guava:33.0.0-jre",
"commons-logging:commons-logging:1.2",
"jakarta.inject:jakarta.inject-api:2.0.1",
"jakarta.persistence:jakarta.persistence-api:3.0.0",
Expand All @@ -54,19 +54,19 @@ maven_install(
maven.artifact(
"com.google.guava",
"guava-testlib",
"32.0.0-jre",
"33.0.0-jre",
testonly = True,
),
maven.artifact(
"com.google.truth",
"truth",
"1.1.3",
"1.3.0",
testonly = True,
),
maven.artifact(
"com.google.truth.extensions",
"truth-java8-extension",
"1.1.3",
"1.3.0",
testonly = True,
),
maven.artifact(
Expand Down
6 changes: 3 additions & 3 deletions core/test/com/google/inject/util/EnhancedTest.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.google.inject.util;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static org.junit.Assume.assumeTrue;

import com.google.common.truth.Truth8;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
Expand Down Expand Up @@ -46,8 +46,8 @@ public void unenhancedClass() {
assertThat(bar.bar()).isEqualTo("bar");

// The actual tests.
assertThat(Enhanced.unenhancedClass(foo.getClass())).isEqualTo(Optional.of(Foo.class));
assertThat(Enhanced.unenhancedClass(bar.getClass())).isEmpty();
Truth8.assertThat(Enhanced.unenhancedClass(foo.getClass())).isEqualTo(Optional.of(Foo.class));
Truth8.assertThat(Enhanced.unenhancedClass(bar.getClass())).isEmpty();
}

private static class InterceptingModule extends AbstractModule {
Expand Down
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ See the Apache License Version 2.0 for the specific language governing permissio
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>32.0.0-jre</version>
<version>33.0.0-jre</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava-testlib</artifactId>
<version>32.0.0-jre</version>
<version>33.0.0-jre</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
Expand All @@ -163,13 +163,13 @@ See the Apache License Version 2.0 for the specific language governing permissio
<dependency>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<version>1.1.3</version>
<version>1.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.truth.extensions</groupId>
<artifactId>truth-java8-extension</artifactId>
<version>1.1.3</version>
<version>1.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -485,4 +485,4 @@ See the Apache License Version 2.0 for the specific language governing permissio
</plugin>
</plugins>
</build>
</project>
</project>

0 comments on commit 4f94f00

Please sign in to comment.