Skip to content

Commit

Permalink
Externally remove deprecated AtomicLongMapSubject, DefaultSubject
Browse files Browse the repository at this point in the history
…, `StandardSubjectBuilder.fail(...)` overload that accepts arguments, and `Optional*Subject.hasValueThat()`

Fixes google#204

Relnotes:
  - Removed the overload of `StandardSubjectBuilder.fail(...)` that accepts a message. Instead of `assert_().fail(...)`, use `assertWithMessage(...).fail()`. Similarly, instead of `expect.fail(...)`, use `expect.withMessage(...).fail()`, and so forth.
  - Removed `DefaultSubject`. Use plain `Subject`.
  - Removed `Optional*Subject.hasValueThat()`. Instead of `assertThat(optional).hasValueThat()....`, use `assertThat(optional.getAs*())....`.
  - Removed `AtomicLongMapSubject`. In most cases, you can [assert on the `asMap()` view instead](google#579).

[]

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=254994279
  • Loading branch information
cpovirk committed Jun 25, 2019
1 parent 777af33 commit 6c9107c
Show file tree
Hide file tree
Showing 18 changed files with 32 additions and 637 deletions.
139 changes: 0 additions & 139 deletions core/src/main/java/com/google/common/truth/AtomicLongMapSubject.java

This file was deleted.

34 changes: 0 additions & 34 deletions core/src/main/java/com/google/common/truth/DefaultSubject.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.google.common.collect.Multimap;
import com.google.common.collect.Multiset;
import com.google.common.collect.Table;
import com.google.common.util.concurrent.AtomicLongMap;
import java.math.BigDecimal;
import java.util.Map;
import org.checkerframework.checker.nullness.compatqual.NullableDecl;
Expand Down Expand Up @@ -171,12 +170,6 @@ public final TableSubject that(@NullableDecl Table<?, ?, ?> actual) {
return new TableSubject(metadata(), actual);
}

/** @deprecated Perform assertions on the {@link AtomicLongMap#asMap()} view. */
@Deprecated
public final AtomicLongMapSubject that(@NullableDecl AtomicLongMap<?> actual) {
return new AtomicLongMapSubject(metadata(), actual);
}

/**
* Returns a new instance that will output the given message before the main failure message. If
* this method is called multiple times, the messages will appear in the order that they were
Expand Down Expand Up @@ -228,18 +221,6 @@ public final void fail() {
metadata().fail(ImmutableList.<Fact>of());
}

/**
* Reports a failure with the given message.
*
* @deprecated Instead of {@code assert_().fail(...)}, use {@code assertWithMessage(...).fail()}.
* Similarly, instead of {@code expect.fail(...)}, use {@code expect.withMessage(...).fail()},
* and so forth.
*/
@Deprecated
public final void fail(String format, Object /*@NullableDeclType*/... args) {
withMessage(format, args).fail();
}

private FailureMetadata metadata() {
checkStatePreconditions();
return metadataDoNotReferenceDirectly;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ public final ThrowableSubject hasCauseThat() {
// TODO(diamondm) in keeping with other subjects' behavior this should still NPE if the subject
// *itself* is null, since there's no context to lose. See also b/37645583
if (actual == null) {
check("getCause()").fail("Causal chain is not deep enough - add a .isNotNull() check?");
check("getCause()")
.withMessage("Causal chain is not deep enough - add a .isNotNull() check?")
.fail();
return ignoreCheck()
.that(
new Throwable() {
Expand Down
8 changes: 0 additions & 8 deletions core/src/main/java/com/google/common/truth/Truth.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.google.common.collect.Multimap;
import com.google.common.collect.Multiset;
import com.google.common.collect.Table;
import com.google.common.util.concurrent.AtomicLongMap;
import java.math.BigDecimal;
import java.util.Map;
import org.checkerframework.checker.nullness.compatqual.NullableDecl;
Expand Down Expand Up @@ -242,13 +241,6 @@ public static TableSubject assertThat(@NullableDecl Table<?, ?, ?> actual) {
return assert_().that(actual);
}

/** @deprecated Perform assertions on the {@link AtomicLongMap#asMap()} view. */
@Deprecated
public static AtomicLongMapSubject assertThat(
@NullableDecl AtomicLongMap<?> actual) {
return assert_().that(actual);
}

/**
* An {@code AssertionError} that (a) always supports a cause, even under old versions of Android
* and (b) omits "java.lang.AssertionError:" from the beginning of its toString() representation.
Expand Down
Loading

0 comments on commit 6c9107c

Please sign in to comment.