mirror of
https://github.com/google/nomulus.git
synced 2025-07-20 17:56:08 +02:00
Move Imm.Obj. hash code stripping into utility fx
Spotted this functionality in one of mcilwain's test classes that could be useful to other CommandTestCases when comparing ImmutableObject output. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=128686426
This commit is contained in:
parent
5332ac4e4a
commit
68b58c210d
1 changed files with 13 additions and 0 deletions
|
@ -147,6 +147,15 @@ public abstract class CommandTestCase<C extends Command> {
|
||||||
return ofy().load().type(PollMessage.class).count();
|
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 {
|
protected void assertStdoutIs(String expected) throws Exception {
|
||||||
assertThat(getStdoutAsString()).isEqualTo(expected);
|
assertThat(getStdoutAsString()).isEqualTo(expected);
|
||||||
}
|
}
|
||||||
|
@ -177,6 +186,10 @@ public abstract class CommandTestCase<C extends Command> {
|
||||||
return Splitter.on('\n').omitEmptyStrings().trimResults().splitToList(getStdoutAsString());
|
return Splitter.on('\n').omitEmptyStrings().trimResults().splitToList(getStdoutAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String stripImmutableObjectHashCodes(String string) {
|
||||||
|
return string.replaceAll("\\(@\\d+\\)", "(@)");
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
protected C newCommandInstance() {
|
protected C newCommandInstance() {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue