Skip to content

Commit

Permalink
Deprecate Optional*Subject.hasValueThat() and the overload of `Stan…
Browse files Browse the repository at this point in the history
…dardSubjectBuilder.fail(...)` that accepts a message.

Relnotes:
  Deprecated 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.
  Deprecated `Optional*Subject.hasValueThat()`. Instead of `assertThat(optional).hasValueThat()....`, use `assertThat(optional.getAs*())....`.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=254050317
  • Loading branch information
cpovirk committed Jun 19, 2019
1 parent 8f33bf6 commit 227b559
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,19 @@ public final <CustomSubjectBuilderT extends CustomSubjectBuilder> CustomSubjectB
return factory.createSubjectBuilder(metadata());
}

/** Triggers the failure strategy with an empty failure message */
/** Triggers the failure strategy with an empty failure message. */
public final void fail() {
doFail("");
}

/** Triggers the failure strategy with the given failure message */
/**
* Triggers the failure strategy with the given failure 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(@NullableDecl String format, Object /*@NullableDeclType*/... args) {
doFail(lenientFormat(format, args));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ public void hasValue(double expected) {
/**
* Prepares for a check regarding the value contained within the {@link OptionalDouble}. Fails
* immediately if the subject is empty.
*/
*
* @deprecated Instead of {@code assertThat(optional).hasValueThat()....}, use {@code
* assertThat(optional.getAsDouble())....}.
*/
@Deprecated
public DoubleSubject hasValueThat() {
if (actual == null || !actual.isPresent()) {
isPresent(); // fails
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ public void hasValue(int expected) {
/**
* Prepares for a check regarding the value contained within the {@link OptionalInt}. Fails
* immediately if the subject is empty.
*/
*
* @deprecated Instead of {@code assertThat(optional).hasValueThat()....}, use {@code
* assertThat(optional.getAsInt())....}.
*/
@Deprecated
public IntegerSubject hasValueThat() {
if (actual == null || !actual.isPresent()) {
isPresent(); // fails
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ public void hasValue(long expected) {
/**
* Prepares for a check regarding the value contained within the {@link OptionalLong}. Fails
* immediately if the subject is empty.
*/
*
* @deprecated Instead of {@code assertThat(optional).hasValueThat()....}, use {@code
* assertThat(optional.getAsLong())....}.
*/
@Deprecated
public LongSubject hasValueThat() {
if (actual == null || !actual.isPresent()) {
isPresent(); // fails
Expand Down

0 comments on commit 227b559

Please sign in to comment.