Migrate Truth Subjects from no-arg check() to use description

The overload that accepts a description generally produces better failure messages:
- The first line of the message it produces is something like: "value of: myProto.getResponse()" (where "getResponse()" is taken from the provided description)
- The last line of the message it produces is something like: "myProto was: response: query was throttled" (the full value of myProto)
- And the existing text goes in between.

Additional motivation: We are deleting the no-arg overload externally (and probably internally thereafter).
Tested:
    TAP --sample ran all affected tests and none failed
    []

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=246582329
This commit is contained in:
cpovirk 2019-05-03 15:15:13 -07:00 committed by jianglai
parent e9d220e6f3
commit 021405eb17

View file

@ -61,16 +61,12 @@ public class LogsSubject extends Subject<LogsSubject, TestLogHandler> {
} }
public void hasNoLogsAtLevel(Level level) { public void hasNoLogsAtLevel(Level level) {
check() check("atLevel(%s)", level).that(getMessagesAtLevel(level)).isEmpty();
.withMessage("Logs at level %s", level)
.that(getMessagesAtLevel(level))
.isEmpty();
} }
public Which<StringSubject> hasLogAtLevelWithMessage(Level level, String message) { public Which<StringSubject> hasLogAtLevelWithMessage(Level level, String message) {
List<String> messagesAtLevel = getMessagesAtLevel(level); List<String> messagesAtLevel = getMessagesAtLevel(level);
check() check("atLevel(%s)", level)
.withMessage("Logs at level %s", level)
.that(messagesAtLevel) .that(messagesAtLevel)
.comparingElementsUsing(CONTAINS_CORRESPONDENCE) .comparingElementsUsing(CONTAINS_CORRESPONDENCE)
.contains(message); .contains(message);