Migrate Correspondence subclasses to instead call Correspondence.from()

This makes the code shorter, and the subclassing approach is deprecated.

Open-source note: Correspondence.from was added to Truth 0.43. (So was Correspondence.transforming, which I'm using occasionally instead.) Correspondence.formattingDiffsUsing was added in Truth 0.44.

END_PUBLIC

More information:
  []Tested:
    TAP --sample ran all affected tests and none failed
    []

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=249913322
This commit is contained in:
cpovirk 2019-05-24 15:54:19 -07:00 committed by jianglai
parent 7cc5c16ab9
commit b34a828b71

View file

@ -41,17 +41,7 @@ public class LogsSubject extends Subject<LogsSubject, TestLogHandler> {
}
private static final Correspondence<String, String> CONTAINS_CORRESPONDENCE =
new Correspondence<String, String>() {
@Override
public boolean compare(String actual, String expected) {
return actual.contains(expected);
}
@Override
public String toString() {
return "contains";
}
};
Correspondence.from((actual, expected) -> actual.contains(expected), "contains");
private List<String> getMessagesAtLevel(Level level) {
ImmutableList.Builder<String> builder = new ImmutableList.Builder<>();