Skip to content

Commit

Permalink
Deprecate remaining legacy fail* methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpovirk committed Jun 12, 2018
1 parent 785f14a commit 1f9b2d6
Showing 1 changed file with 43 additions and 5 deletions.
48 changes: 43 additions & 5 deletions core/src/main/java/com/google/common/truth/Subject.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ public class Subject<S extends Subject<S, T>, T> {
*
* <h3>For people extending Truth</h3>
*
* <p>When you write a custom subject, see <a href="https://google.github.io/truth/extension">our doc on
* extensions</a>. It explains where {@code Subject.Factory} fits into the process.
* <p>When you write a custom subject, see <a href="https://google.github.io/truth/extension">our
* doc on extensions</a>. It explains where {@code Subject.Factory} fits into the process.
*/
public interface Factory<SubjectT extends Subject<SubjectT, ActualT>, ActualT> {
/** Creates a new {@link Subject}. */
Expand Down Expand Up @@ -803,7 +803,13 @@ final void failWithActual(Iterable<Fact> facts) {
* Reports a failure constructing a message from a simple verb.
*
* @param check the check being asserted
* @deprecated Prefer to construct {@link Fact}-style methods, typically by using {@link
* #failWithActual(Fact, Fact...) failWithActual}{@code (}{@link Fact#simpleFact
* simpleFact(...)}{@code )}. However, if you want to preserve your exact failure message as a
* migration aid, you can inline this method (and then inline the resulting method call, as
* well).
*/
@Deprecated
protected final void fail(String check) {
fail(check, new Object[0]);
}
Expand All @@ -813,7 +819,12 @@ protected final void fail(String check) {
*
* @param verb the check being asserted
* @param other the value against which the subject is compared
* @deprecated Prefer to construct {@link Fact}-style methods, typically by using {@link
* #failWithActual(String, Object)}. However, if you want to preserve your exact failure
* message as a migration aid, you can inline this method (and then inline the resulting
* method call, as well).
*/
@Deprecated
protected final void fail(String verb, Object other) {
fail(verb, new Object[] {other});
}
Expand All @@ -823,7 +834,11 @@ protected final void fail(String verb, Object other) {
*
* @param verb the check being asserted
* @param messageParts the expectations against which the subject is compared
* @deprecated Prefer to construct {@link Fact}-style methods, typically by using {@link
* #failWithActual(Fact, Fact...)}. However, if you want to preserve your exact failure
* message as a migration aid, you can inline this method.
*/
@Deprecated
protected final void fail(String verb, Object... messageParts) {
StringBuilder message = new StringBuilder("Not true that ");
message.append(actualAsString()).append(" ").append(verb);
Expand Down Expand Up @@ -918,7 +933,11 @@ private void failEqualityCheckNoComparisonFailure(ComparisonResult difference, F
* @param expected the expectations against which the subject is compared
* @param failVerb the failure of the check being asserted
* @param actual the actual value the subject was compared against
* @deprecated Prefer to construct {@link Fact}-style methods, typically by using {@link
* #failWithActual(Fact, Fact...)}. However, if you want to preserve your exact failure
* message as a migration aid, you can inline this method.
*/
@Deprecated
protected final void failWithBadResults(
String verb, Object expected, String failVerb, Object actual) {
String message =
Expand All @@ -939,7 +958,11 @@ protected final void failWithBadResults(
* @param verb the check being asserted
* @param expected the expected value of the check
* @param actual the custom representation of the subject to be reported in the failure.
* @deprecated Prefer to construct {@link Fact}-style methods, typically by using {@link
* #failWithoutActual(Fact, Fact...)}. However, if you want to preserve your exact failure
* message as a migration aid, you can inline this method.
*/
@Deprecated
protected final void failWithCustomSubject(String verb, Object expected, Object actual) {
String message =
lenientFormat(
Expand All @@ -948,7 +971,12 @@ protected final void failWithCustomSubject(String verb, Object expected, Object
failWithoutActual(simpleFact(message));
}

/** @deprecated Use {@link #failWithoutActual(String)} */
/**
* @deprecated Prefer to construct {@link Fact}-style methods, typically by using {@link
* #failWithoutActual(Fact, Fact...) failWithoutActual}{@code (}{@link Fact#simpleFact
* simpleFact(...)}{@code )}. However, if you want to preserve your exact failure message as a
* migration aid, you can inline this method.
*/
@Deprecated
protected final void failWithoutSubject(String check) {
String strSubject = this.customName == null ? "the subject" : "\"" + customName + "\"";
Expand Down Expand Up @@ -988,7 +1016,13 @@ final void failWithoutActual(Iterable<Fact> facts) {
* Assembles a failure message without a given subject and passes it to the FailureStrategy
*
* @param check the check being asserted
* @deprecated Prefer to construct {@link Fact}-style methods, typically by using {@link
* #failWithoutActual(Fact, Fact...) failWithoutActual}{@code (}{@link Fact#simpleFact
* simpleFact(...)}{@code )}. However, if you want to preserve your exact failure message as a
* migration aid, you can inline this method (and then inline the resulting method call, as
* well).
*/
@Deprecated
protected final void failWithoutActual(String check) {
failWithoutSubject(check);
}
Expand All @@ -999,8 +1033,12 @@ protected final void failWithoutActual(String check) {
*
* @param message a template with {@code %s} placeholders
* @param parameters the object parameters which will be applied to the message template.
* @deprecated Prefer to construct {@link Fact}-style methods, typically by using {@link
* #failWithActual(Fact, Fact...)}. However, if you want to preserve your exact failure
* message as a migration aid, you can inline this method.
*/
// TODO(cgruber) final
@Deprecated
protected void failWithRawMessage(String message, Object... parameters) {
failWithoutActual(simpleFact(lenientFormat(message, parameters)));
}
Expand Down Expand Up @@ -1042,8 +1080,8 @@ protected final void failComparing(String message, CharSequence expected, CharSe
* Passes through a failure message verbatim, along with a cause and the expected and actual
* values that the {@link FailureStrategy} may use to construct a {@code ComparisonFailure}.
*
* @deprecated See {@linkplain #failComparing(String, CharSequence, CharSequence)} the other
* overload of this method for instructions on how to get Truth to throw a {@code
* @deprecated See {@linkplain #failComparing(String, CharSequence, CharSequence) the other
* overload of this method} for instructions on how to get Truth to throw a {@code
* ComparisonFailure}. To make Truth also attach the {@code Throwable cause} to the assertion
* failure, see the instructions on {@link #failWithRawMessageAndCause}.
*/
Expand Down

0 comments on commit 1f9b2d6

Please sign in to comment.