mirror of
https://github.com/google/nomulus.git
synced 2025-05-19 10:49:35 +02:00
Instead of calling Subject.actual(), store the actual value in a field, and read that.
actual() is being removed. More information: [] Tested: TAP --sample ran all affected tests and none failed [] ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=247415370
This commit is contained in:
parent
38e2175699
commit
5bb93e9e4a
9 changed files with 107 additions and 119 deletions
|
@ -28,14 +28,17 @@ public abstract class AbstractDomainBaseSubject
|
||||||
<T extends DomainBase, S extends AbstractDomainBaseSubject<T, S>>
|
<T extends DomainBase, S extends AbstractDomainBaseSubject<T, S>>
|
||||||
extends AbstractEppResourceSubject<T, S> {
|
extends AbstractEppResourceSubject<T, S> {
|
||||||
|
|
||||||
|
private final T actual;
|
||||||
|
|
||||||
public AbstractDomainBaseSubject(FailureMetadata failureMetadata, T subject) {
|
public AbstractDomainBaseSubject(FailureMetadata failureMetadata, T subject) {
|
||||||
super(failureMetadata, subject);
|
super(failureMetadata, subject);
|
||||||
|
this.actual = subject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<S> hasFullyQualifiedDomainName(String fullyQualifiedDomainName) {
|
public And<S> hasFullyQualifiedDomainName(String fullyQualifiedDomainName) {
|
||||||
return hasValue(
|
return hasValue(
|
||||||
fullyQualifiedDomainName,
|
fullyQualifiedDomainName,
|
||||||
actual().getFullyQualifiedDomainName(),
|
actual.getFullyQualifiedDomainName(),
|
||||||
"has fullyQualifiedDomainName");
|
"has fullyQualifiedDomainName");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,26 +47,23 @@ public abstract class AbstractDomainBaseSubject
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<S> hasExactlyDsData(Set<DelegationSignerData> dsData) {
|
public And<S> hasExactlyDsData(Set<DelegationSignerData> dsData) {
|
||||||
return hasValue(dsData, actual().getDsData(), "has dsData");
|
return hasValue(dsData, actual.getDsData(), "has dsData");
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<S> hasNumDsData(int num) {
|
public And<S> hasNumDsData(int num) {
|
||||||
return hasValue(num, actual().getDsData().size(), "has num dsData");
|
return hasValue(num, actual.getDsData().size(), "has num dsData");
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<S> hasLaunchNotice(LaunchNotice launchNotice) {
|
public And<S> hasLaunchNotice(LaunchNotice launchNotice) {
|
||||||
return hasValue(launchNotice, actual().getLaunchNotice(), "has launchNotice");
|
return hasValue(launchNotice, actual.getLaunchNotice(), "has launchNotice");
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<S> hasAuthInfoPwd(String pw) {
|
public And<S> hasAuthInfoPwd(String pw) {
|
||||||
AuthInfo authInfo = actual().getAuthInfo();
|
AuthInfo authInfo = actual.getAuthInfo();
|
||||||
return hasValue(pw, authInfo == null ? null : authInfo.getPw().getValue(), "has auth info pw");
|
return hasValue(pw, authInfo == null ? null : authInfo.getPw().getValue(), "has auth info pw");
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<S> hasCurrentSponsorClientId(String clientId) {
|
public And<S> hasCurrentSponsorClientId(String clientId) {
|
||||||
return hasValue(
|
return hasValue(clientId, actual.getCurrentSponsorClientId(), "has currentSponsorClientId");
|
||||||
clientId,
|
|
||||||
actual().getCurrentSponsorClientId(),
|
|
||||||
"has currentSponsorClientId");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,12 +40,15 @@ import org.joda.time.DateTime;
|
||||||
abstract class AbstractEppResourceSubject
|
abstract class AbstractEppResourceSubject
|
||||||
<T extends EppResource, S extends AbstractEppResourceSubject<T, S>> extends Subject<S, T> {
|
<T extends EppResource, S extends AbstractEppResourceSubject<T, S>> extends Subject<S, T> {
|
||||||
|
|
||||||
|
private final T actual;
|
||||||
|
|
||||||
public AbstractEppResourceSubject(FailureMetadata failureMetadata, T subject) {
|
public AbstractEppResourceSubject(FailureMetadata failureMetadata, T subject) {
|
||||||
super(failureMetadata, checkNotNull(subject));
|
super(failureMetadata, checkNotNull(subject));
|
||||||
|
this.actual = subject;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<HistoryEntry> getHistoryEntries() {
|
private List<HistoryEntry> getHistoryEntries() {
|
||||||
return DatastoreHelper.getHistoryEntries(actual());
|
return DatastoreHelper.getHistoryEntries(actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -56,17 +59,16 @@ abstract class AbstractEppResourceSubject
|
||||||
@Override
|
@Override
|
||||||
protected String actualCustomStringRepresentation() {
|
protected String actualCustomStringRepresentation() {
|
||||||
return String.format(
|
return String.format(
|
||||||
"%s with foreign key '%s'",
|
"%s with foreign key '%s'", actual.getClass().getSimpleName(), actual.getForeignKey());
|
||||||
actual().getClass().getSimpleName(),
|
|
||||||
actual().getForeignKey());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void isEqualTo(@Nullable Object other) {
|
public void isEqualTo(@Nullable Object other) {
|
||||||
// If the objects differ and we can show an interesting ImmutableObject diff, do so.
|
// If the objects differ and we can show an interesting ImmutableObject diff, do so.
|
||||||
if (actual() != null && other instanceof ImmutableObject && !actual().equals(other)) {
|
if (actual != null && other instanceof ImmutableObject && !actual.equals(other)) {
|
||||||
String diffText = prettyPrintEntityDeepDiff(
|
String diffText =
|
||||||
((ImmutableObject) other).toDiffableFieldMap(), actual().toDiffableFieldMap());
|
prettyPrintEntityDeepDiff(
|
||||||
|
((ImmutableObject) other).toDiffableFieldMap(), actual.toDiffableFieldMap());
|
||||||
fail(String.format("is equal to %s\n\nIt differs as follows:\n%s", other, diffText));
|
fail(String.format("is equal to %s\n\nIt differs as follows:\n%s", other, diffText));
|
||||||
}
|
}
|
||||||
// Otherwise, fall back to regular behavior.
|
// Otherwise, fall back to regular behavior.
|
||||||
|
@ -74,7 +76,7 @@ abstract class AbstractEppResourceSubject
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<S> hasRepoId(long roid) {
|
public And<S> hasRepoId(long roid) {
|
||||||
return hasValue(roid, actual().getRepoId(), "has repoId");
|
return hasValue(roid, actual.getRepoId(), "has repoId");
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<S> hasNoHistoryEntries() {
|
public And<S> hasNoHistoryEntries() {
|
||||||
|
@ -92,7 +94,7 @@ abstract class AbstractEppResourceSubject
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<S> hasNumHistoryEntriesOfType(HistoryEntry.Type type, int num) {
|
public And<S> hasNumHistoryEntriesOfType(HistoryEntry.Type type, int num) {
|
||||||
List<HistoryEntry> entries = getHistoryEntriesOfType(actual(), type);
|
List<HistoryEntry> entries = getHistoryEntriesOfType(actual, type);
|
||||||
if (entries.size() != num) {
|
if (entries.size() != num) {
|
||||||
failWithBadResults(
|
failWithBadResults(
|
||||||
String.format("has this number of history entries of type %s", type.toString()),
|
String.format("has this number of history entries of type %s", type.toString()),
|
||||||
|
@ -136,7 +138,7 @@ abstract class AbstractEppResourceSubject
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<S> hasStatusValue(StatusValue statusValue) {
|
public And<S> hasStatusValue(StatusValue statusValue) {
|
||||||
if (!actual().getStatusValues().contains(statusValue)) {
|
if (!actual.getStatusValues().contains(statusValue)) {
|
||||||
failWithoutActual(
|
failWithoutActual(
|
||||||
simpleFact(
|
simpleFact(
|
||||||
lenientFormat("%s should have had status value %s", actualAsString(), statusValue)));
|
lenientFormat("%s should have had status value %s", actualAsString(), statusValue)));
|
||||||
|
@ -145,7 +147,7 @@ abstract class AbstractEppResourceSubject
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<S> doesNotHaveStatusValue(StatusValue statusValue) {
|
public And<S> doesNotHaveStatusValue(StatusValue statusValue) {
|
||||||
if (actual().getStatusValues().contains(statusValue)) {
|
if (actual.getStatusValues().contains(statusValue)) {
|
||||||
failWithoutActual(
|
failWithoutActual(
|
||||||
simpleFact(
|
simpleFact(
|
||||||
lenientFormat(
|
lenientFormat(
|
||||||
|
@ -155,31 +157,24 @@ abstract class AbstractEppResourceSubject
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<S> hasExactlyStatusValues(StatusValue... statusValues) {
|
public And<S> hasExactlyStatusValues(StatusValue... statusValues) {
|
||||||
if (!ImmutableSet.copyOf(actual().getStatusValues())
|
if (!ImmutableSet.copyOf(actual.getStatusValues()).equals(ImmutableSet.copyOf(statusValues))) {
|
||||||
.equals(ImmutableSet.copyOf(statusValues))) {
|
|
||||||
check("getStatusValues()")
|
check("getStatusValues()")
|
||||||
.that(actual().getStatusValues())
|
.that(actual.getStatusValues())
|
||||||
.containsExactly((Object[]) statusValues);
|
.containsExactly((Object[]) statusValues);
|
||||||
}
|
}
|
||||||
return andChainer();
|
return andChainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<S> hasDeletionTime(DateTime deletionTime) {
|
public And<S> hasDeletionTime(DateTime deletionTime) {
|
||||||
return hasValue(
|
return hasValue(deletionTime, actual.getDeletionTime(), "has deletionTime");
|
||||||
deletionTime,
|
|
||||||
actual().getDeletionTime(),
|
|
||||||
"has deletionTime");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<S> hasLastEppUpdateTime(DateTime lastUpdateTime) {
|
public And<S> hasLastEppUpdateTime(DateTime lastUpdateTime) {
|
||||||
return hasValue(
|
return hasValue(lastUpdateTime, actual.getLastEppUpdateTime(), "has lastEppUpdateTime");
|
||||||
lastUpdateTime,
|
|
||||||
actual().getLastEppUpdateTime(),
|
|
||||||
"has lastEppUpdateTime");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<S> hasLastEppUpdateTimeAtLeast(DateTime before) {
|
public And<S> hasLastEppUpdateTimeAtLeast(DateTime before) {
|
||||||
DateTime lastEppUpdateTime = actual().getLastEppUpdateTime();
|
DateTime lastEppUpdateTime = actual.getLastEppUpdateTime();
|
||||||
if (lastEppUpdateTime == null || before.isAfter(lastEppUpdateTime)) {
|
if (lastEppUpdateTime == null || before.isAfter(lastEppUpdateTime)) {
|
||||||
failWithBadResults("has lastEppUpdateTime at least", before, lastEppUpdateTime);
|
failWithBadResults("has lastEppUpdateTime at least", before, lastEppUpdateTime);
|
||||||
}
|
}
|
||||||
|
@ -187,29 +182,26 @@ abstract class AbstractEppResourceSubject
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<S> hasLastEppUpdateClientId(String clientId) {
|
public And<S> hasLastEppUpdateClientId(String clientId) {
|
||||||
return hasValue(
|
return hasValue(clientId, actual.getLastEppUpdateClientId(), "has lastEppUpdateClientId");
|
||||||
clientId,
|
|
||||||
actual().getLastEppUpdateClientId(),
|
|
||||||
"has lastEppUpdateClientId");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public And<S> hasPersistedCurrentSponsorClientId(String clientId) {
|
public And<S> hasPersistedCurrentSponsorClientId(String clientId) {
|
||||||
return hasValue(
|
return hasValue(
|
||||||
clientId,
|
clientId,
|
||||||
actual().getPersistedCurrentSponsorClientId(),
|
actual.getPersistedCurrentSponsorClientId(),
|
||||||
"has persisted currentSponsorClientId");
|
"has persisted currentSponsorClientId");
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<S> isActiveAt(DateTime time) {
|
public And<S> isActiveAt(DateTime time) {
|
||||||
if (!isActive(actual(), time)) {
|
if (!isActive(actual, time)) {
|
||||||
fail("is active at " + time);
|
fail("is active at " + time);
|
||||||
}
|
}
|
||||||
return andChainer();
|
return andChainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<S> isNotActiveAt(DateTime time) {
|
public And<S> isNotActiveAt(DateTime time) {
|
||||||
if (isActive(actual(), time)) {
|
if (isActive(actual, time)) {
|
||||||
fail("is not active at " + time);
|
fail("is not active at " + time);
|
||||||
}
|
}
|
||||||
return andChainer();
|
return andChainer();
|
||||||
|
|
|
@ -30,23 +30,26 @@ import org.joda.time.DateTime;
|
||||||
public final class ContactResourceSubject
|
public final class ContactResourceSubject
|
||||||
extends AbstractEppResourceSubject<ContactResource, ContactResourceSubject> {
|
extends AbstractEppResourceSubject<ContactResource, ContactResourceSubject> {
|
||||||
|
|
||||||
|
private final ContactResource actual;
|
||||||
|
|
||||||
public ContactResourceSubject(FailureMetadata failureMetadata, ContactResource subject) {
|
public ContactResourceSubject(FailureMetadata failureMetadata, ContactResource subject) {
|
||||||
super(failureMetadata, checkNotNull(subject));
|
super(failureMetadata, checkNotNull(subject));
|
||||||
|
this.actual = subject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<ContactResourceSubject> hasLocalizedPostalInfo(PostalInfo postalInfo) {
|
public And<ContactResourceSubject> hasLocalizedPostalInfo(PostalInfo postalInfo) {
|
||||||
return hasValue(postalInfo, actual().getLocalizedPostalInfo(), "has localizedPostalInfo");
|
return hasValue(postalInfo, actual.getLocalizedPostalInfo(), "has localizedPostalInfo");
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<ContactResourceSubject> hasNullLocalizedPostalInfo() {
|
public And<ContactResourceSubject> hasNullLocalizedPostalInfo() {
|
||||||
if (actual().getLocalizedPostalInfo() != null) {
|
if (actual.getLocalizedPostalInfo() != null) {
|
||||||
failWithActual(simpleFact("expected to have 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) {
|
||||||
failWithActual(simpleFact("expected to have non-null localized postal info"));
|
failWithActual(simpleFact("expected to have non-null localized postal info"));
|
||||||
}
|
}
|
||||||
return andChainer();
|
return andChainer();
|
||||||
|
@ -55,13 +58,11 @@ public final class ContactResourceSubject
|
||||||
public And<ContactResourceSubject> hasInternationalizedPostalInfo(
|
public And<ContactResourceSubject> hasInternationalizedPostalInfo(
|
||||||
PostalInfo postalInfo) {
|
PostalInfo postalInfo) {
|
||||||
return hasValue(
|
return hasValue(
|
||||||
postalInfo,
|
postalInfo, actual.getInternationalizedPostalInfo(), "has internationalizedPostalInfo");
|
||||||
actual().getInternationalizedPostalInfo(),
|
|
||||||
"has internationalizedPostalInfo");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<ContactResourceSubject> hasNullInternationalizedPostalInfo() {
|
public And<ContactResourceSubject> hasNullInternationalizedPostalInfo() {
|
||||||
if (actual().getInternationalizedPostalInfo() != null) {
|
if (actual.getInternationalizedPostalInfo() != null) {
|
||||||
failWithActual(simpleFact("expected to have null internationalized postal info"));
|
failWithActual(simpleFact("expected to have null internationalized postal info"));
|
||||||
}
|
}
|
||||||
return andChainer();
|
return andChainer();
|
||||||
|
@ -69,78 +70,69 @@ public final class ContactResourceSubject
|
||||||
|
|
||||||
|
|
||||||
public And<ContactResourceSubject> hasNonNullInternationalizedPostalInfo() {
|
public And<ContactResourceSubject> hasNonNullInternationalizedPostalInfo() {
|
||||||
if (actual().getInternationalizedPostalInfo() == null) {
|
if (actual.getInternationalizedPostalInfo() == null) {
|
||||||
failWithActual(simpleFact("expected to have 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) {
|
||||||
failWithActual(simpleFact("expected to have 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) {
|
||||||
failWithActual(simpleFact("expected to have 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) {
|
||||||
failWithActual(simpleFact("expected to have 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) {
|
||||||
failWithActual(simpleFact("expected to have 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) {
|
||||||
failWithActual(simpleFact("expected to have 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) {
|
||||||
failWithActual(simpleFact("expected to have non-null fax number"));
|
failWithActual(simpleFact("expected to have non-null fax number"));
|
||||||
}
|
}
|
||||||
return andChainer();
|
return andChainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<ContactResourceSubject> hasAuthInfoPwd(String pw) {
|
public And<ContactResourceSubject> hasAuthInfoPwd(String pw) {
|
||||||
AuthInfo authInfo = actual().getAuthInfo();
|
AuthInfo authInfo = actual.getAuthInfo();
|
||||||
return hasValue(pw, authInfo == null ? null : authInfo.getPw().getValue(), "has auth info pw");
|
return hasValue(pw, authInfo == null ? null : authInfo.getPw().getValue(), "has auth info pw");
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<ContactResourceSubject> hasLastTransferTime(DateTime lastTransferTime) {
|
public And<ContactResourceSubject> hasLastTransferTime(DateTime lastTransferTime) {
|
||||||
return hasValue(
|
return hasValue(lastTransferTime, actual.getLastTransferTime(), "has lastTransferTime");
|
||||||
lastTransferTime,
|
|
||||||
actual().getLastTransferTime(),
|
|
||||||
"has lastTransferTime");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<ContactResourceSubject> hasLastTransferTimeNotEqualTo(DateTime lastTransferTime) {
|
public And<ContactResourceSubject> hasLastTransferTimeNotEqualTo(DateTime lastTransferTime) {
|
||||||
return doesNotHaveValue(
|
return doesNotHaveValue(lastTransferTime, actual.getLastTransferTime(), "lastTransferTime");
|
||||||
lastTransferTime,
|
|
||||||
actual().getLastTransferTime(),
|
|
||||||
"lastTransferTime");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<ContactResourceSubject> hasCurrentSponsorClientId(String clientId) {
|
public And<ContactResourceSubject> hasCurrentSponsorClientId(String clientId) {
|
||||||
return hasValue(
|
return hasValue(clientId, actual.getCurrentSponsorClientId(), "has currentSponsorClientId");
|
||||||
clientId,
|
|
||||||
actual().getCurrentSponsorClientId(),
|
|
||||||
"has currentSponsorClientId");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SimpleSubjectBuilder<ContactResourceSubject, ContactResource>
|
public static SimpleSubjectBuilder<ContactResourceSubject, ContactResource>
|
||||||
|
|
|
@ -30,49 +30,44 @@ public final class DomainBaseSubject
|
||||||
extends AbstractDomainBaseSubject<DomainBase, DomainBaseSubject> {
|
extends AbstractDomainBaseSubject<DomainBase, DomainBaseSubject> {
|
||||||
|
|
||||||
public And<DomainBaseSubject> hasRegistrationExpirationTime(DateTime expiration) {
|
public And<DomainBaseSubject> hasRegistrationExpirationTime(DateTime expiration) {
|
||||||
if (!Objects.equals(actual().getRegistrationExpirationTime(), expiration)) {
|
if (!Objects.equals(actual.getRegistrationExpirationTime(), expiration)) {
|
||||||
failWithBadResults(
|
failWithBadResults(
|
||||||
"has registrationExpirationTime",
|
"has registrationExpirationTime", expiration, actual.getRegistrationExpirationTime());
|
||||||
expiration,
|
|
||||||
actual().getRegistrationExpirationTime());
|
|
||||||
}
|
}
|
||||||
return andChainer();
|
return andChainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<DomainBaseSubject> hasLastTransferTime(DateTime lastTransferTime) {
|
public And<DomainBaseSubject> hasLastTransferTime(DateTime lastTransferTime) {
|
||||||
return hasValue(
|
return hasValue(lastTransferTime, actual.getLastTransferTime(), "has lastTransferTime");
|
||||||
lastTransferTime,
|
|
||||||
actual().getLastTransferTime(),
|
|
||||||
"has lastTransferTime");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<DomainBaseSubject> hasLastTransferTimeNotEqualTo(DateTime lastTransferTime) {
|
public And<DomainBaseSubject> hasLastTransferTimeNotEqualTo(DateTime lastTransferTime) {
|
||||||
return doesNotHaveValue(
|
return doesNotHaveValue(lastTransferTime, actual.getLastTransferTime(), "lastTransferTime");
|
||||||
lastTransferTime,
|
|
||||||
actual().getLastTransferTime(),
|
|
||||||
"lastTransferTime");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<DomainBaseSubject> hasDeletePollMessage() {
|
public And<DomainBaseSubject> hasDeletePollMessage() {
|
||||||
if (actual().getDeletePollMessage() == null) {
|
if (actual.getDeletePollMessage() == null) {
|
||||||
failWithActual(simpleFact("expected to have 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) {
|
||||||
failWithActual(simpleFact("expected to have no delete poll message"));
|
failWithActual(simpleFact("expected to have no delete poll message"));
|
||||||
}
|
}
|
||||||
return andChainer();
|
return andChainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<DomainBaseSubject> hasSmdId(String smdId) {
|
public And<DomainBaseSubject> hasSmdId(String smdId) {
|
||||||
return hasValue(smdId, actual().getSmdId(), "has smdId");
|
return hasValue(smdId, actual.getSmdId(), "has smdId");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final DomainBase actual;
|
||||||
|
|
||||||
public DomainBaseSubject(FailureMetadata failureMetadata, DomainBase subject) {
|
public DomainBaseSubject(FailureMetadata failureMetadata, DomainBase subject) {
|
||||||
super(failureMetadata, checkNotNull(subject));
|
super(failureMetadata, checkNotNull(subject));
|
||||||
|
this.actual = subject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SimpleSubjectBuilder<DomainBaseSubject, DomainBase> assertAboutDomains() {
|
public static SimpleSubjectBuilder<DomainBaseSubject, DomainBase> assertAboutDomains() {
|
||||||
|
|
|
@ -32,17 +32,20 @@ import google.registry.xml.XmlException;
|
||||||
/** Utility methods for asserting things about {@link EppException} instances. */
|
/** Utility methods for asserting things about {@link EppException} instances. */
|
||||||
public class EppExceptionSubject extends Subject<EppExceptionSubject, EppException> {
|
public class EppExceptionSubject extends Subject<EppExceptionSubject, EppException> {
|
||||||
|
|
||||||
|
private final EppException actual;
|
||||||
|
|
||||||
public EppExceptionSubject(FailureMetadata failureMetadata, EppException subject) {
|
public EppExceptionSubject(FailureMetadata failureMetadata, EppException subject) {
|
||||||
super(failureMetadata, subject);
|
super(failureMetadata, subject);
|
||||||
|
this.actual = subject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<EppExceptionSubject> hasMessage(String expected) {
|
public And<EppExceptionSubject> hasMessage(String expected) {
|
||||||
assertThat(actual()).hasMessageThat().isEqualTo(expected);
|
assertThat(actual).hasMessageThat().isEqualTo(expected);
|
||||||
return new And<>(this);
|
return new And<>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<EppExceptionSubject> hasMessageThatContains(String expected) {
|
public And<EppExceptionSubject> hasMessageThatContains(String expected) {
|
||||||
assertThat(actual()).hasMessageThat().contains(expected);
|
assertThat(actual).hasMessageThat().contains(expected);
|
||||||
return new And<>(this);
|
return new And<>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,9 +53,10 @@ public class EppExceptionSubject extends Subject<EppExceptionSubject, EppExcepti
|
||||||
// Attempt to marshal the exception to EPP. If it doesn't work, this will throw.
|
// Attempt to marshal the exception to EPP. If it doesn't work, this will throw.
|
||||||
try {
|
try {
|
||||||
marshal(
|
marshal(
|
||||||
EppOutput.create(new EppResponse.Builder()
|
EppOutput.create(
|
||||||
|
new EppResponse.Builder()
|
||||||
.setTrid(Trid.create(null, "server-trid"))
|
.setTrid(Trid.create(null, "server-trid"))
|
||||||
.setResult(actual().getResult())
|
.setResult(actual.getResult())
|
||||||
.build()),
|
.build()),
|
||||||
ValidationMode.STRICT);
|
ValidationMode.STRICT);
|
||||||
} catch (XmlException e) {
|
} catch (XmlException e) {
|
||||||
|
|
|
@ -29,8 +29,11 @@ import java.util.Optional;
|
||||||
/** Utility methods for asserting things about {@link EppMetric} instances. */
|
/** Utility methods for asserting things about {@link EppMetric} instances. */
|
||||||
public class EppMetricSubject extends Subject<EppMetricSubject, EppMetric> {
|
public class EppMetricSubject extends Subject<EppMetricSubject, EppMetric> {
|
||||||
|
|
||||||
|
private final EppMetric actual;
|
||||||
|
|
||||||
public EppMetricSubject(FailureMetadata failureMetadata, EppMetric subject) {
|
public EppMetricSubject(FailureMetadata failureMetadata, EppMetric subject) {
|
||||||
super(failureMetadata, subject);
|
super(failureMetadata, subject);
|
||||||
|
this.actual = subject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EppMetricSubject assertThat(EppMetric subject) {
|
public static EppMetricSubject assertThat(EppMetric subject) {
|
||||||
|
@ -38,30 +41,30 @@ public class EppMetricSubject extends Subject<EppMetricSubject, EppMetric> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<EppMetricSubject> hasClientId(String clientId) {
|
public And<EppMetricSubject> hasClientId(String clientId) {
|
||||||
return hasValue(clientId, actual().getClientId(), "has clientId");
|
return hasValue(clientId, actual.getClientId(), "has clientId");
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<EppMetricSubject> hasCommandName(String commandName) {
|
public And<EppMetricSubject> hasCommandName(String commandName) {
|
||||||
return hasValue(commandName, actual().getCommandName(), "has commandName");
|
return hasValue(commandName, actual.getCommandName(), "has commandName");
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<EppMetricSubject> hasStatus(Code status) {
|
public And<EppMetricSubject> hasStatus(Code status) {
|
||||||
return hasValue(status, actual().getStatus(), "has status");
|
return hasValue(status, actual.getStatus(), "has status");
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<EppMetricSubject> hasNoStatus() {
|
public And<EppMetricSubject> hasNoStatus() {
|
||||||
if (actual().getStatus().isPresent()) {
|
if (actual.getStatus().isPresent()) {
|
||||||
failWithActual(simpleFact("expected to have no status"));
|
failWithActual(simpleFact("expected to have no status"));
|
||||||
}
|
}
|
||||||
return new And<>(this);
|
return new And<>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<EppMetricSubject> hasTld(String tld) {
|
public And<EppMetricSubject> hasTld(String tld) {
|
||||||
return hasValue(tld, actual().getTld(), "has tld");
|
return hasValue(tld, actual.getTld(), "has tld");
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<EppMetricSubject> hasNoTld() {
|
public And<EppMetricSubject> hasNoTld() {
|
||||||
if (actual().getTld().isPresent()) {
|
if (actual.getTld().isPresent()) {
|
||||||
failWithActual(simpleFact("expected to have no tld"));
|
failWithActual(simpleFact("expected to have no tld"));
|
||||||
}
|
}
|
||||||
return new And<>(this);
|
return new And<>(this);
|
||||||
|
|
|
@ -30,15 +30,17 @@ import org.joda.time.DateTime;
|
||||||
/** Utility methods for asserting things about {@link HistoryEntry} instances. */
|
/** Utility methods for asserting things about {@link HistoryEntry} instances. */
|
||||||
public class HistoryEntrySubject extends Subject<HistoryEntrySubject, HistoryEntry> {
|
public class HistoryEntrySubject extends Subject<HistoryEntrySubject, HistoryEntry> {
|
||||||
|
|
||||||
|
private final HistoryEntry actual;
|
||||||
private String customDisplaySubject;
|
private String customDisplaySubject;
|
||||||
|
|
||||||
public HistoryEntrySubject(FailureMetadata failureMetadata, HistoryEntry subject) {
|
public HistoryEntrySubject(FailureMetadata failureMetadata, HistoryEntry subject) {
|
||||||
super(failureMetadata, subject);
|
super(failureMetadata, subject);
|
||||||
|
this.actual = subject;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String actualCustomStringRepresentation() {
|
protected String actualCustomStringRepresentation() {
|
||||||
return Optional.ofNullable(customDisplaySubject).orElse(String.valueOf(actual()));
|
return Optional.ofNullable(customDisplaySubject).orElse(String.valueOf(actual));
|
||||||
}
|
}
|
||||||
|
|
||||||
public HistoryEntrySubject withCustomDisplaySubject(String customDisplaySubject) {
|
public HistoryEntrySubject withCustomDisplaySubject(String customDisplaySubject) {
|
||||||
|
@ -47,52 +49,54 @@ public class HistoryEntrySubject extends Subject<HistoryEntrySubject, HistoryEnt
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<HistoryEntrySubject> hasType(HistoryEntry.Type type) {
|
public And<HistoryEntrySubject> hasType(HistoryEntry.Type type) {
|
||||||
return hasValue(type, actual().getType(), "has type");
|
return hasValue(type, actual.getType(), "has type");
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<HistoryEntrySubject> hasClientId(String clientId) {
|
public And<HistoryEntrySubject> hasClientId(String clientId) {
|
||||||
return hasValue(clientId, actual().getClientId(), "has client ID");
|
return hasValue(clientId, actual.getClientId(), "has client ID");
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<HistoryEntrySubject> hasOtherClientId(String otherClientId) {
|
public And<HistoryEntrySubject> hasOtherClientId(String otherClientId) {
|
||||||
return hasValue(otherClientId, actual().getOtherClientId(), "has other client ID");
|
return hasValue(otherClientId, actual.getOtherClientId(), "has other client ID");
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<HistoryEntrySubject> hasModificationTime(DateTime modificationTime) {
|
public And<HistoryEntrySubject> hasModificationTime(DateTime modificationTime) {
|
||||||
return hasValue(modificationTime, actual().getModificationTime(), "has modification time");
|
return hasValue(modificationTime, actual.getModificationTime(), "has modification time");
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<HistoryEntrySubject> bySuperuser(boolean superuser) {
|
public And<HistoryEntrySubject> bySuperuser(boolean superuser) {
|
||||||
return hasValue(superuser, actual().getBySuperuser(), "has modification time");
|
return hasValue(superuser, actual.getBySuperuser(), "has modification time");
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<HistoryEntrySubject> hasPeriod() {
|
public And<HistoryEntrySubject> hasPeriod() {
|
||||||
if (actual().getPeriod() == null) {
|
if (actual.getPeriod() == null) {
|
||||||
failWithActual(simpleFact("expected to have a period"));
|
failWithActual(simpleFact("expected to have a period"));
|
||||||
}
|
}
|
||||||
return new And<>(this);
|
return new And<>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<HistoryEntrySubject> hasPeriodYears(int years) {
|
public And<HistoryEntrySubject> hasPeriodYears(int years) {
|
||||||
return hasPeriod().and()
|
return hasPeriod()
|
||||||
.hasValue(Period.Unit.YEARS, actual().getPeriod().getUnit(), "has period in").and()
|
.and()
|
||||||
.hasValue(years, actual().getPeriod().getValue(), "has period length");
|
.hasValue(Period.Unit.YEARS, actual.getPeriod().getUnit(), "has period in")
|
||||||
|
.and()
|
||||||
|
.hasValue(years, actual.getPeriod().getValue(), "has period length");
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<HistoryEntrySubject> hasNoXml() {
|
public And<HistoryEntrySubject> hasNoXml() {
|
||||||
if (actual().getXmlBytes() != null) {
|
if (actual.getXmlBytes() != null) {
|
||||||
failWithActual(simpleFact("expected to have no xml"));
|
failWithActual(simpleFact("expected to have no xml"));
|
||||||
}
|
}
|
||||||
return new And<>(this);
|
return new And<>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<HistoryEntrySubject> hasMetadataReason(String reason) {
|
public And<HistoryEntrySubject> hasMetadataReason(String reason) {
|
||||||
return hasValue(reason, actual().getReason(), "has metadata reason");
|
return hasValue(reason, actual.getReason(), "has metadata reason");
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<HistoryEntrySubject> hasMetadataRequestedByRegistrar(
|
public And<HistoryEntrySubject> hasMetadataRequestedByRegistrar(
|
||||||
boolean requestedByRegistrar) {
|
boolean requestedByRegistrar) {
|
||||||
if (actual().getRequestedByRegistrar() != requestedByRegistrar) {
|
if (actual.getRequestedByRegistrar() != requestedByRegistrar) {
|
||||||
failWithActual(
|
failWithActual(
|
||||||
"expected to have metadata requestedByRegistrar with value", requestedByRegistrar);
|
"expected to have metadata requestedByRegistrar with value", requestedByRegistrar);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,11 @@ import org.joda.time.DateTime;
|
||||||
public final class HostResourceSubject
|
public final class HostResourceSubject
|
||||||
extends AbstractEppResourceSubject<HostResource, HostResourceSubject> {
|
extends AbstractEppResourceSubject<HostResource, HostResourceSubject> {
|
||||||
|
|
||||||
|
private final HostResource actual;
|
||||||
|
|
||||||
public HostResourceSubject(FailureMetadata failureMetadata, HostResource subject) {
|
public HostResourceSubject(FailureMetadata failureMetadata, HostResource subject) {
|
||||||
super(failureMetadata, checkNotNull(subject));
|
super(failureMetadata, checkNotNull(subject));
|
||||||
|
this.actual = subject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SimpleSubjectBuilder<HostResourceSubject, HostResource> assertAboutHosts() {
|
public static SimpleSubjectBuilder<HostResourceSubject, HostResource> assertAboutHosts() {
|
||||||
|
@ -38,30 +41,22 @@ public final class HostResourceSubject
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<HostResourceSubject> hasLastTransferTime(DateTime lastTransferTime) {
|
public And<HostResourceSubject> hasLastTransferTime(DateTime lastTransferTime) {
|
||||||
return hasValue(
|
return hasValue(lastTransferTime, actual.getLastTransferTime(), "has lastTransferTime");
|
||||||
lastTransferTime,
|
|
||||||
actual().getLastTransferTime(),
|
|
||||||
"has lastTransferTime");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<HostResourceSubject> hasLastTransferTimeNotEqualTo(DateTime lastTransferTime) {
|
public And<HostResourceSubject> hasLastTransferTimeNotEqualTo(DateTime lastTransferTime) {
|
||||||
return doesNotHaveValue(
|
return doesNotHaveValue(lastTransferTime, actual.getLastTransferTime(), "lastTransferTime");
|
||||||
lastTransferTime,
|
|
||||||
actual().getLastTransferTime(),
|
|
||||||
"lastTransferTime");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<HostResourceSubject> hasLastSuperordinateChange(DateTime lastSuperordinateChange) {
|
public And<HostResourceSubject> hasLastSuperordinateChange(DateTime lastSuperordinateChange) {
|
||||||
return hasValue(
|
return hasValue(
|
||||||
lastSuperordinateChange,
|
lastSuperordinateChange,
|
||||||
actual().getLastSuperordinateChange(),
|
actual.getLastSuperordinateChange(),
|
||||||
"has lastSuperordinateChange");
|
"has lastSuperordinateChange");
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<HostResourceSubject> hasSuperordinateDomain(Key<DomainBase> superordinateDomain) {
|
public And<HostResourceSubject> hasSuperordinateDomain(Key<DomainBase> superordinateDomain) {
|
||||||
return hasValue(
|
return hasValue(
|
||||||
superordinateDomain,
|
superordinateDomain, actual.getSuperordinateDomain(), "has superordinateDomain");
|
||||||
actual().getSuperordinateDomain(),
|
|
||||||
"has superordinateDomain");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,8 +33,11 @@ import java.util.logging.LogRecord;
|
||||||
/** Utility methods for asserting things about logging {@link Handler} instances. */
|
/** Utility methods for asserting things about logging {@link Handler} instances. */
|
||||||
public class LogsSubject extends Subject<LogsSubject, TestLogHandler> {
|
public class LogsSubject extends Subject<LogsSubject, TestLogHandler> {
|
||||||
|
|
||||||
|
private final TestLogHandler actual;
|
||||||
|
|
||||||
public LogsSubject(FailureMetadata failureMetadata, TestLogHandler subject) {
|
public LogsSubject(FailureMetadata failureMetadata, TestLogHandler subject) {
|
||||||
super(failureMetadata, subject);
|
super(failureMetadata, subject);
|
||||||
|
this.actual = subject;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Correspondence<String, String> CONTAINS_CORRESPONDENCE =
|
private static final Correspondence<String, String> CONTAINS_CORRESPONDENCE =
|
||||||
|
@ -52,7 +55,7 @@ public class LogsSubject extends Subject<LogsSubject, TestLogHandler> {
|
||||||
|
|
||||||
private List<String> getMessagesAtLevel(Level level) {
|
private List<String> getMessagesAtLevel(Level level) {
|
||||||
ImmutableList.Builder<String> builder = new ImmutableList.Builder<>();
|
ImmutableList.Builder<String> builder = new ImmutableList.Builder<>();
|
||||||
for (LogRecord log : actual().getStoredLogRecords()) {
|
for (LogRecord log : actual.getStoredLogRecords()) {
|
||||||
if (log.getLevel().equals(level)) {
|
if (log.getLevel().equals(level)) {
|
||||||
builder.add(log.getMessage());
|
builder.add(log.getMessage());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue