Skip to content

Commit 2be0061

Browse files
committed
Update docs to reflect that the Java 8 assertions have "moved" to the main Truth class.
This includes deprecating the old class. This continues work on #746. RELNOTES=Deprecated `Truth8`. All its functionality is now supported through the main `Truth` API. PiperOrigin-RevId: 604762265
1 parent 2e8e488 commit 2be0061

9 files changed

Lines changed: 44 additions & 15 deletions

File tree

core/src/main/java/com/google/common/truth/IntStreamSubject.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ protected String actualCustomStringRepresentation() {
6161
return String.valueOf(actualList);
6262
}
6363

64+
/**
65+
* Obsolete factory instance. This factory was previously necessary for assertions like {@code
66+
* assertWithMessage(...).about(intStreams()).that(stream)....}. Now, you can perform assertions
67+
* like that without the {@code about(...)} call.
68+
*/
6469
public static Factory<IntStreamSubject, IntStream> intStreams() {
6570
return IntStreamSubject::new;
6671
}

core/src/main/java/com/google/common/truth/LongStreamSubject.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ protected String actualCustomStringRepresentation() {
6161
return String.valueOf(actualList);
6262
}
6363

64+
/**
65+
* Obsolete factory instance. This factory was previously necessary for assertions like {@code
66+
* assertWithMessage(...).about(longStreams()).that(stream)....}. Now, you can perform assertions
67+
* like that without the {@code about(...)} call.
68+
*/
6469
public static Factory<LongStreamSubject, LongStream> longStreams() {
6570
return LongStreamSubject::new;
6671
}

core/src/main/java/com/google/common/truth/OptionalDoubleSubject.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ public void hasValue(double expected) {
8181
}
8282
}
8383

84+
/**
85+
* Obsolete factory instance. This factory was previously necessary for assertions like {@code
86+
* assertWithMessage(...).about(optionalDoubles()).that(optional)....}. Now, you can perform
87+
* assertions like that without the {@code about(...)} call.
88+
*/
8489
public static Subject.Factory<OptionalDoubleSubject, OptionalDouble> optionalDoubles() {
8590
return (metadata, subject) -> new OptionalDoubleSubject(metadata, subject, "optionalDouble");
8691
}

core/src/main/java/com/google/common/truth/OptionalIntSubject.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ public void hasValue(int expected) {
7474
}
7575
}
7676

77+
/**
78+
* Obsolete factory instance. This factory was previously necessary for assertions like {@code
79+
* assertWithMessage(...).about(optionalInts()).that(optional)....}. Now, you can perform
80+
* assertions like that without the {@code about(...)} call.
81+
*/
7782
public static Subject.Factory<OptionalIntSubject, OptionalInt> optionalInts() {
7883
return (metadata, subject) -> new OptionalIntSubject(metadata, subject, "optionalInt");
7984
}

core/src/main/java/com/google/common/truth/OptionalLongSubject.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ public void hasValue(long expected) {
7474
}
7575
}
7676

77+
/**
78+
* Obsolete factory instance. This factory was previously necessary for assertions like {@code
79+
* assertWithMessage(...).about(optionalLongs()).that(optional)....}. Now, you can perform
80+
* assertions like that without the {@code about(...)} call.
81+
*/
7782
public static Subject.Factory<OptionalLongSubject, OptionalLong> optionalLongs() {
7883
return (metadata, subject) -> new OptionalLongSubject(metadata, subject, "optionalLong");
7984
}

core/src/main/java/com/google/common/truth/OptionalSubject.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ public void hasValue(@Nullable Object expected) {
8484
}
8585
}
8686

87+
/**
88+
* Obsolete factory instance. This factory was previously necessary for assertions like {@code
89+
* assertWithMessage(...).about(paths()).that(path)....}. Now, you can perform assertions like
90+
* that without the {@code about(...)} call.
91+
*/
8792
public static Subject.Factory<OptionalSubject, Optional<?>> optionals() {
8893
return (metadata, subject) -> new OptionalSubject(metadata, subject, "optional");
8994
}

core/src/main/java/com/google/common/truth/PathSubject.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ public final class PathSubject extends Subject {
3232
super(failureMetadata, actual);
3333
}
3434

35+
/**
36+
* Obsolete factory instance. This factory was previously necessary for assertions like {@code
37+
* assertWithMessage(...).about(intStreams()).that(stream)....}. Now, you can perform assertions
38+
* like that without the {@code about(...)} call.
39+
*/
3540
public static Subject.Factory<PathSubject, Path> paths() {
3641
return PathSubject::new;
3742
}

core/src/main/java/com/google/common/truth/StreamSubject.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ protected String actualCustomStringRepresentation() {
8888
return String.valueOf(asList);
8989
}
9090

91+
/**
92+
* Obsolete factory instance. This factory was previously necessary for assertions like {@code
93+
* assertWithMessage(...).about(streams()).that(stream)....}. Now, you can perform assertions like
94+
* that without the {@code about(...)} call.
95+
*/
9196
public static Subject.Factory<StreamSubject, Stream<?>> streams() {
9297
return StreamSubject::new;
9398
}

core/src/main/java/com/google/common/truth/Truth8.java

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,12 @@
3030
import org.checkerframework.checker.nullness.qual.Nullable;
3131

3232
/**
33-
* The primary entry point for assertions about Java 8 types.
33+
* The obsolete entry point for assertions about Java 8 types.
3434
*
35-
* <p>To use {@link Truth#assertWithMessage} with a Java 8 type, use {@code
36-
* assertWithMessage(...).about(}{@link OptionalSubject#optionals optionals()}{@code ).that(...)}
37-
* (or similarly for the other types).
38-
*
39-
* <p>Likewise, to use different failure strategies like {@link Expect}, use {@code
40-
* expect.about(}{@link OptionalSubject#optionals optionals()}{@code ).that(...)}.
41-
*
42-
* <p>For more information about combining different messages, failure strategies, and subjects, see
43-
* <a href="https://truth.dev/faq#full-chain">How do I specify a custom message/failure
44-
* behavior/{@code Subject} type?</a> in the Truth FAQ.
35+
* @deprecated Instead of this class's methods, use the identical methods declared in the main
36+
* {@link Truth} class.
4537
*/
38+
@Deprecated
4639
// The methods here are no more dangerous that wherever the user got the (e.g.) Stream.
4740
@SuppressWarnings("Java7ApiChecker")
4841
public final class Truth8 {
@@ -75,10 +68,6 @@ public static LongStreamSubject assertThat(@Nullable LongStream target) {
7568
return assertAbout(LongStreamSubject.longStreams()).that(target);
7669
}
7770

78-
// TODO(b/64757353): Add support for DoubleStream?
79-
80-
// Not actually a Java 8 feature, but for now this is the best option since core Truth still has
81-
// to support Java environments without java.nio.file such as Android and J2CL.
8271
@GwtIncompatible
8372
@J2ObjCIncompatible
8473
@J2ktIncompatible

0 commit comments

Comments
 (0)