diff --git a/javatests/google/registry/testing/AbstractEppResourceSubject.java b/javatests/google/registry/testing/AbstractEppResourceSubject.java index 059364c8b..4d57b4ea0 100644 --- a/javatests/google/registry/testing/AbstractEppResourceSubject.java +++ b/javatests/google/registry/testing/AbstractEppResourceSubject.java @@ -80,7 +80,7 @@ abstract class AbstractEppResourceSubject public And hasNoHistoryEntries() { if (!getHistoryEntries().isEmpty()) { - fail("has no history entries"); + failWithActual(simpleFact("expected to have no history entries")); } return andChainer(); } diff --git a/javatests/google/registry/testing/ContactResourceSubject.java b/javatests/google/registry/testing/ContactResourceSubject.java index adb37d2af..d37a253c7 100644 --- a/javatests/google/registry/testing/ContactResourceSubject.java +++ b/javatests/google/registry/testing/ContactResourceSubject.java @@ -15,6 +15,7 @@ package google.registry.testing; import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.truth.Fact.simpleFact; import static com.google.common.truth.Truth.assertAbout; import com.google.common.truth.FailureMetadata; @@ -39,14 +40,14 @@ public final class ContactResourceSubject public And hasNullLocalizedPostalInfo() { if (actual().getLocalizedPostalInfo() != null) { - fail("has null localized postal info"); + failWithActual(simpleFact("expected to have null localized postal info")); } return andChainer(); } public And hasNonNullLocalizedPostalInfo() { if (actual().getLocalizedPostalInfo() == null) { - fail("has non-null localized postal info"); + failWithActual(simpleFact("expected to have non-null localized postal info")); } return andChainer(); } @@ -61,7 +62,7 @@ public final class ContactResourceSubject public And hasNullInternationalizedPostalInfo() { if (actual().getInternationalizedPostalInfo() != null) { - fail("has null internationalized postal info"); + failWithActual(simpleFact("expected to have null internationalized postal info")); } return andChainer(); } @@ -69,49 +70,49 @@ public final class ContactResourceSubject public And hasNonNullInternationalizedPostalInfo() { if (actual().getInternationalizedPostalInfo() == null) { - fail("has non-null internationalized postal info"); + failWithActual(simpleFact("expected to have non-null internationalized postal info")); } return andChainer(); } public And hasNullEmailAddress() { if (actual().getEmailAddress() != null) { - fail("has null email address"); + failWithActual(simpleFact("expected to have null email address")); } return andChainer(); } public And hasNonNullEmailAddress() { if (actual().getEmailAddress() == null) { - fail("has non-null email address"); + failWithActual(simpleFact("expected to have non-null email address")); } return andChainer(); } public And hasNullVoiceNumber() { if (actual().getVoiceNumber() != null) { - fail("has null voice number"); + failWithActual(simpleFact("expected to have null voice number")); } return andChainer(); } public And hasNonNullVoiceNumber() { if (actual().getVoiceNumber() == null) { - fail("has non-null voice number"); + failWithActual(simpleFact("expected to have non-null voice number")); } return andChainer(); } public And hasNullFaxNumber() { if (actual().getFaxNumber() != null) { - fail("has null fax number"); + failWithActual(simpleFact("expected to have null fax number")); } return andChainer(); } public And hasNonNullFaxNumber() { if (actual().getFaxNumber() == null) { - fail("has non-null fax number"); + failWithActual(simpleFact("expected to have non-null fax number")); } return andChainer(); } diff --git a/javatests/google/registry/testing/DomainBaseSubject.java b/javatests/google/registry/testing/DomainBaseSubject.java index 28f234aa4..36972ad4b 100644 --- a/javatests/google/registry/testing/DomainBaseSubject.java +++ b/javatests/google/registry/testing/DomainBaseSubject.java @@ -15,6 +15,7 @@ package google.registry.testing; import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.truth.Fact.simpleFact; import static com.google.common.truth.Truth.assertAbout; import com.google.common.truth.FailureMetadata; @@ -54,14 +55,14 @@ public final class DomainBaseSubject public And hasDeletePollMessage() { if (actual().getDeletePollMessage() == null) { - fail("has a delete poll message"); + failWithActual(simpleFact("expected to have a delete poll message")); } return andChainer(); } public And hasNoDeletePollMessage() { if (actual().getDeletePollMessage() != null) { - fail("has no delete poll message"); + failWithActual(simpleFact("expected to have no delete poll message")); } return andChainer(); } diff --git a/javatests/google/registry/testing/EppMetricSubject.java b/javatests/google/registry/testing/EppMetricSubject.java index c8187d2f8..57f88ffc0 100644 --- a/javatests/google/registry/testing/EppMetricSubject.java +++ b/javatests/google/registry/testing/EppMetricSubject.java @@ -14,6 +14,7 @@ package google.registry.testing; +import static com.google.common.truth.Fact.simpleFact; import static com.google.common.truth.Truth.assertAbout; import static google.registry.util.PreconditionsUtils.checkArgumentNotNull; @@ -50,7 +51,7 @@ public class EppMetricSubject extends Subject { public And hasNoStatus() { if (actual().getStatus().isPresent()) { - fail("has no status"); + failWithActual(simpleFact("expected to have no status")); } return new And<>(this); } @@ -61,7 +62,7 @@ public class EppMetricSubject extends Subject { public And hasNoTld() { if (actual().getTld().isPresent()) { - fail("has no tld"); + failWithActual(simpleFact("expected to have no tld")); } return new And<>(this); } @@ -69,9 +70,9 @@ public class EppMetricSubject extends Subject { private And hasValue(E expected, Optional actual, String verb) { checkArgumentNotNull(expected, "Expected value cannot be null"); if (actual == null) { - fail("is non-null", expected); + failWithActual("expected to be non-null", expected); } else if (!actual.isPresent()) { - fail("has value", expected); + failWithActual("expected to have value", expected); } else if (!Objects.equals(expected, actual.get())) { failWithBadResults(verb, expected, verb, actual); } diff --git a/javatests/google/registry/testing/HistoryEntrySubject.java b/javatests/google/registry/testing/HistoryEntrySubject.java index 06880b0d0..0ceec76e3 100644 --- a/javatests/google/registry/testing/HistoryEntrySubject.java +++ b/javatests/google/registry/testing/HistoryEntrySubject.java @@ -14,6 +14,7 @@ package google.registry.testing; +import static com.google.common.truth.Fact.simpleFact; import static com.google.common.truth.Truth.assertAbout; import com.google.common.truth.FailureMetadata; @@ -67,7 +68,7 @@ public class HistoryEntrySubject extends Subject hasPeriod() { if (actual().getPeriod() == null) { - fail("has a period"); + failWithActual(simpleFact("expected to have a period")); } return new And<>(this); } @@ -80,7 +81,7 @@ public class HistoryEntrySubject extends Subject hasNoXml() { if (actual().getXmlBytes() != null) { - fail("has no xml"); + failWithActual(simpleFact("expected to have no xml")); } return new And<>(this); } @@ -92,7 +93,8 @@ public class HistoryEntrySubject extends Subject hasMetadataRequestedByRegistrar( boolean requestedByRegistrar) { if (actual().getRequestedByRegistrar() != requestedByRegistrar) { - fail("has metadata requestedByRegistrar with value", requestedByRegistrar); + failWithActual( + "expected to have metadata requestedByRegistrar with value", requestedByRegistrar); } return new And<>(this); }