mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 08:27:14 +02:00
Use new Truth failWithActual() method
Migrate Truth subjects from the old fail(String, Object) to the new failWithActual(String, Object), tweaking verbs for the new grammar. Before: fail("has foo", expected); After: failWithActual("expected to have foo", expected); Open-source note: The fail*() methods used by this CL were added in Truth 0.41. More information: [] Tested: TAP --sample for global presubmit queue [] ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=244418884
This commit is contained in:
parent
24bb78bd16
commit
a46227b201
5 changed files with 25 additions and 20 deletions
|
@ -80,7 +80,7 @@ abstract class AbstractEppResourceSubject
|
||||||
|
|
||||||
public And<S> hasNoHistoryEntries() {
|
public And<S> hasNoHistoryEntries() {
|
||||||
if (!getHistoryEntries().isEmpty()) {
|
if (!getHistoryEntries().isEmpty()) {
|
||||||
fail("has no history entries");
|
failWithActual(simpleFact("expected to have no history entries"));
|
||||||
}
|
}
|
||||||
return andChainer();
|
return andChainer();
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
package google.registry.testing;
|
package google.registry.testing;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
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 static com.google.common.truth.Truth.assertAbout;
|
||||||
|
|
||||||
import com.google.common.truth.FailureMetadata;
|
import com.google.common.truth.FailureMetadata;
|
||||||
|
@ -39,14 +40,14 @@ public final class ContactResourceSubject
|
||||||
|
|
||||||
public And<ContactResourceSubject> hasNullLocalizedPostalInfo() {
|
public And<ContactResourceSubject> hasNullLocalizedPostalInfo() {
|
||||||
if (actual().getLocalizedPostalInfo() != null) {
|
if (actual().getLocalizedPostalInfo() != null) {
|
||||||
fail("has null localized postal info");
|
failWithActual(simpleFact("expected to have null localized postal info"));
|
||||||
}
|
}
|
||||||
return andChainer();
|
return andChainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<ContactResourceSubject> hasNonNullLocalizedPostalInfo() {
|
public And<ContactResourceSubject> hasNonNullLocalizedPostalInfo() {
|
||||||
if (actual().getLocalizedPostalInfo() == null) {
|
if (actual().getLocalizedPostalInfo() == null) {
|
||||||
fail("has non-null localized postal info");
|
failWithActual(simpleFact("expected to have non-null localized postal info"));
|
||||||
}
|
}
|
||||||
return andChainer();
|
return andChainer();
|
||||||
}
|
}
|
||||||
|
@ -61,7 +62,7 @@ public final class ContactResourceSubject
|
||||||
|
|
||||||
public And<ContactResourceSubject> hasNullInternationalizedPostalInfo() {
|
public And<ContactResourceSubject> hasNullInternationalizedPostalInfo() {
|
||||||
if (actual().getInternationalizedPostalInfo() != null) {
|
if (actual().getInternationalizedPostalInfo() != null) {
|
||||||
fail("has null internationalized postal info");
|
failWithActual(simpleFact("expected to have null internationalized postal info"));
|
||||||
}
|
}
|
||||||
return andChainer();
|
return andChainer();
|
||||||
}
|
}
|
||||||
|
@ -69,49 +70,49 @@ public final class ContactResourceSubject
|
||||||
|
|
||||||
public And<ContactResourceSubject> hasNonNullInternationalizedPostalInfo() {
|
public And<ContactResourceSubject> hasNonNullInternationalizedPostalInfo() {
|
||||||
if (actual().getInternationalizedPostalInfo() == null) {
|
if (actual().getInternationalizedPostalInfo() == null) {
|
||||||
fail("has non-null internationalized postal info");
|
failWithActual(simpleFact("expected to have non-null internationalized postal info"));
|
||||||
}
|
}
|
||||||
return andChainer();
|
return andChainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<ContactResourceSubject> hasNullEmailAddress() {
|
public And<ContactResourceSubject> hasNullEmailAddress() {
|
||||||
if (actual().getEmailAddress() != null) {
|
if (actual().getEmailAddress() != null) {
|
||||||
fail("has null email address");
|
failWithActual(simpleFact("expected to have null email address"));
|
||||||
}
|
}
|
||||||
return andChainer();
|
return andChainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<ContactResourceSubject> hasNonNullEmailAddress() {
|
public And<ContactResourceSubject> hasNonNullEmailAddress() {
|
||||||
if (actual().getEmailAddress() == null) {
|
if (actual().getEmailAddress() == null) {
|
||||||
fail("has non-null email address");
|
failWithActual(simpleFact("expected to have non-null email address"));
|
||||||
}
|
}
|
||||||
return andChainer();
|
return andChainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<ContactResourceSubject> hasNullVoiceNumber() {
|
public And<ContactResourceSubject> hasNullVoiceNumber() {
|
||||||
if (actual().getVoiceNumber() != null) {
|
if (actual().getVoiceNumber() != null) {
|
||||||
fail("has null voice number");
|
failWithActual(simpleFact("expected to have null voice number"));
|
||||||
}
|
}
|
||||||
return andChainer();
|
return andChainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<ContactResourceSubject> hasNonNullVoiceNumber() {
|
public And<ContactResourceSubject> hasNonNullVoiceNumber() {
|
||||||
if (actual().getVoiceNumber() == null) {
|
if (actual().getVoiceNumber() == null) {
|
||||||
fail("has non-null voice number");
|
failWithActual(simpleFact("expected to have non-null voice number"));
|
||||||
}
|
}
|
||||||
return andChainer();
|
return andChainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<ContactResourceSubject> hasNullFaxNumber() {
|
public And<ContactResourceSubject> hasNullFaxNumber() {
|
||||||
if (actual().getFaxNumber() != null) {
|
if (actual().getFaxNumber() != null) {
|
||||||
fail("has null fax number");
|
failWithActual(simpleFact("expected to have null fax number"));
|
||||||
}
|
}
|
||||||
return andChainer();
|
return andChainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<ContactResourceSubject> hasNonNullFaxNumber() {
|
public And<ContactResourceSubject> hasNonNullFaxNumber() {
|
||||||
if (actual().getFaxNumber() == null) {
|
if (actual().getFaxNumber() == null) {
|
||||||
fail("has non-null fax number");
|
failWithActual(simpleFact("expected to have non-null fax number"));
|
||||||
}
|
}
|
||||||
return andChainer();
|
return andChainer();
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
package google.registry.testing;
|
package google.registry.testing;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
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 static com.google.common.truth.Truth.assertAbout;
|
||||||
|
|
||||||
import com.google.common.truth.FailureMetadata;
|
import com.google.common.truth.FailureMetadata;
|
||||||
|
@ -54,14 +55,14 @@ public final class DomainBaseSubject
|
||||||
|
|
||||||
public And<DomainBaseSubject> hasDeletePollMessage() {
|
public And<DomainBaseSubject> hasDeletePollMessage() {
|
||||||
if (actual().getDeletePollMessage() == null) {
|
if (actual().getDeletePollMessage() == null) {
|
||||||
fail("has a delete poll message");
|
failWithActual(simpleFact("expected to have a delete poll message"));
|
||||||
}
|
}
|
||||||
return andChainer();
|
return andChainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<DomainBaseSubject> hasNoDeletePollMessage() {
|
public And<DomainBaseSubject> hasNoDeletePollMessage() {
|
||||||
if (actual().getDeletePollMessage() != null) {
|
if (actual().getDeletePollMessage() != null) {
|
||||||
fail("has no delete poll message");
|
failWithActual(simpleFact("expected to have no delete poll message"));
|
||||||
}
|
}
|
||||||
return andChainer();
|
return andChainer();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
package google.registry.testing;
|
package google.registry.testing;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Fact.simpleFact;
|
||||||
import static com.google.common.truth.Truth.assertAbout;
|
import static com.google.common.truth.Truth.assertAbout;
|
||||||
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
||||||
|
|
||||||
|
@ -50,7 +51,7 @@ public class EppMetricSubject extends Subject<EppMetricSubject, EppMetric> {
|
||||||
|
|
||||||
public And<EppMetricSubject> hasNoStatus() {
|
public And<EppMetricSubject> hasNoStatus() {
|
||||||
if (actual().getStatus().isPresent()) {
|
if (actual().getStatus().isPresent()) {
|
||||||
fail("has no status");
|
failWithActual(simpleFact("expected to have no status"));
|
||||||
}
|
}
|
||||||
return new And<>(this);
|
return new And<>(this);
|
||||||
}
|
}
|
||||||
|
@ -61,7 +62,7 @@ public class EppMetricSubject extends Subject<EppMetricSubject, EppMetric> {
|
||||||
|
|
||||||
public And<EppMetricSubject> hasNoTld() {
|
public And<EppMetricSubject> hasNoTld() {
|
||||||
if (actual().getTld().isPresent()) {
|
if (actual().getTld().isPresent()) {
|
||||||
fail("has no tld");
|
failWithActual(simpleFact("expected to have no tld"));
|
||||||
}
|
}
|
||||||
return new And<>(this);
|
return new And<>(this);
|
||||||
}
|
}
|
||||||
|
@ -69,9 +70,9 @@ public class EppMetricSubject extends Subject<EppMetricSubject, EppMetric> {
|
||||||
private <E> And<EppMetricSubject> hasValue(E expected, Optional<E> actual, String verb) {
|
private <E> And<EppMetricSubject> hasValue(E expected, Optional<E> actual, String verb) {
|
||||||
checkArgumentNotNull(expected, "Expected value cannot be null");
|
checkArgumentNotNull(expected, "Expected value cannot be null");
|
||||||
if (actual == null) {
|
if (actual == null) {
|
||||||
fail("is non-null", expected);
|
failWithActual("expected to be non-null", expected);
|
||||||
} else if (!actual.isPresent()) {
|
} else if (!actual.isPresent()) {
|
||||||
fail("has value", expected);
|
failWithActual("expected to have value", expected);
|
||||||
} else if (!Objects.equals(expected, actual.get())) {
|
} else if (!Objects.equals(expected, actual.get())) {
|
||||||
failWithBadResults(verb, expected, verb, actual);
|
failWithBadResults(verb, expected, verb, actual);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
package google.registry.testing;
|
package google.registry.testing;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Fact.simpleFact;
|
||||||
import static com.google.common.truth.Truth.assertAbout;
|
import static com.google.common.truth.Truth.assertAbout;
|
||||||
|
|
||||||
import com.google.common.truth.FailureMetadata;
|
import com.google.common.truth.FailureMetadata;
|
||||||
|
@ -67,7 +68,7 @@ public class HistoryEntrySubject extends Subject<HistoryEntrySubject, HistoryEnt
|
||||||
|
|
||||||
public And<HistoryEntrySubject> hasPeriod() {
|
public And<HistoryEntrySubject> hasPeriod() {
|
||||||
if (actual().getPeriod() == null) {
|
if (actual().getPeriod() == null) {
|
||||||
fail("has a period");
|
failWithActual(simpleFact("expected to have a period"));
|
||||||
}
|
}
|
||||||
return new And<>(this);
|
return new And<>(this);
|
||||||
}
|
}
|
||||||
|
@ -80,7 +81,7 @@ public class HistoryEntrySubject extends Subject<HistoryEntrySubject, HistoryEnt
|
||||||
|
|
||||||
public And<HistoryEntrySubject> hasNoXml() {
|
public And<HistoryEntrySubject> hasNoXml() {
|
||||||
if (actual().getXmlBytes() != null) {
|
if (actual().getXmlBytes() != null) {
|
||||||
fail("has no xml");
|
failWithActual(simpleFact("expected to have no xml"));
|
||||||
}
|
}
|
||||||
return new And<>(this);
|
return new And<>(this);
|
||||||
}
|
}
|
||||||
|
@ -92,7 +93,8 @@ public class HistoryEntrySubject extends Subject<HistoryEntrySubject, HistoryEnt
|
||||||
public And<HistoryEntrySubject> hasMetadataRequestedByRegistrar(
|
public And<HistoryEntrySubject> hasMetadataRequestedByRegistrar(
|
||||||
boolean requestedByRegistrar) {
|
boolean requestedByRegistrar) {
|
||||||
if (actual().getRequestedByRegistrar() != 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);
|
return new And<>(this);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue