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:
cpovirk 2019-05-09 06:47:46 -07:00 committed by jianglai
parent 38e2175699
commit 5bb93e9e4a
9 changed files with 107 additions and 119 deletions

View file

@ -32,17 +32,20 @@ import google.registry.xml.XmlException;
/** Utility methods for asserting things about {@link EppException} instances. */
public class EppExceptionSubject extends Subject<EppExceptionSubject, EppException> {
private final EppException actual;
public EppExceptionSubject(FailureMetadata failureMetadata, EppException subject) {
super(failureMetadata, subject);
this.actual = subject;
}
public And<EppExceptionSubject> hasMessage(String expected) {
assertThat(actual()).hasMessageThat().isEqualTo(expected);
assertThat(actual).hasMessageThat().isEqualTo(expected);
return new And<>(this);
}
public And<EppExceptionSubject> hasMessageThatContains(String expected) {
assertThat(actual()).hasMessageThat().contains(expected);
assertThat(actual).hasMessageThat().contains(expected);
return new And<>(this);
}
@ -50,10 +53,11 @@ public class EppExceptionSubject extends Subject<EppExceptionSubject, EppExcepti
// Attempt to marshal the exception to EPP. If it doesn't work, this will throw.
try {
marshal(
EppOutput.create(new EppResponse.Builder()
.setTrid(Trid.create(null, "server-trid"))
.setResult(actual().getResult())
.build()),
EppOutput.create(
new EppResponse.Builder()
.setTrid(Trid.create(null, "server-trid"))
.setResult(actual.getResult())
.build()),
ValidationMode.STRICT);
} catch (XmlException e) {
fail("fails to marshal to XML: " + e.getMessage());