diff --git a/javatests/google/registry/tools/CommandTestCase.java b/javatests/google/registry/tools/CommandTestCase.java index 6dac241dc..8036682a0 100644 --- a/javatests/google/registry/tools/CommandTestCase.java +++ b/javatests/google/registry/tools/CommandTestCase.java @@ -147,6 +147,15 @@ public abstract class CommandTestCase { return ofy().load().type(PollMessage.class).count(); } + /** + * Asserts whether standard out matches an expected string, allowing for differences in + * ImmutableObject hash codes (i.e. "(@1234567)"). + */ + protected void assertStdoutForImmutableObjectIs(String expected) throws Exception { + assertThat(stripImmutableObjectHashCodes(getStdoutAsString()).trim()) + .isEqualTo(stripImmutableObjectHashCodes(expected).trim()); + } + protected void assertStdoutIs(String expected) throws Exception { assertThat(getStdoutAsString()).isEqualTo(expected); } @@ -177,6 +186,10 @@ public abstract class CommandTestCase { return Splitter.on('\n').omitEmptyStrings().trimResults().splitToList(getStdoutAsString()); } + protected String stripImmutableObjectHashCodes(String string) { + return string.replaceAll("\\(@\\d+\\)", "(@)"); + } + @SuppressWarnings("unchecked") protected C newCommandInstance() { try {