use of org.hamcrest.StringDescription in project JsonPath by jayway.
the class IsJsonFileTest method shouldDescribeMismatchOfValidJson.
@Test
public void shouldDescribeMismatchOfValidJson() {
Matcher<File> matcher = isJsonFile(withPathEvaluatedTo(true));
Description description = new StringDescription();
matcher.describeMismatch(BOOKS_JSON, description);
assertThat(description.toString(), containsString(MISMATCHED_TEXT));
}
use of org.hamcrest.StringDescription in project JsonPath by jayway.
the class IsJsonStringTest method shouldDescribeMismatchOfValidJson.
@Test
public void shouldDescribeMismatchOfValidJson() {
Matcher<String> matcher = isJsonString(withPathEvaluatedTo(true));
Description description = new StringDescription();
matcher.describeMismatch(BOOKS_JSON, description);
assertThat(description.toString(), containsString(MISMATCHED_TEXT));
}
use of org.hamcrest.StringDescription in project JsonPath by jayway.
the class IsJsonTest method shouldDescribeMismatchOfInvalidJson.
@Test
public void shouldDescribeMismatchOfInvalidJson() {
Matcher<Object> matcher = isJson(withPathEvaluatedTo(true));
Description description = new StringDescription();
matcher.describeMismatch("invalid-json", description);
assertThat(description.toString(), containsString("\"invalid-json\""));
}
use of org.hamcrest.StringDescription in project junit4 by junit-team.
the class StackTracesTest method assertHasTrimmedTrace.
private static void assertHasTrimmedTrace(Failure failure, StringMatcher... matchers) {
String trimmedTrace = failure.getTrimmedTrace();
String[] lines = trimmedTrace.split(EOL);
int index = 0;
for (; index < lines.length && index < matchers.length; index++) {
String line = lines[index];
StringMatcher matcher = matchers[index];
assertThat(line, matcher);
}
if (index < lines.length) {
String extraLine = lines[index];
fail("Extra line in trimmed trace: " + extraLine);
} else if (index < matchers.length) {
StringDescription description = new StringDescription();
matchers[index].describeTo(description);
fail("Missing line in trimmed trace: " + description.toString());
}
}
use of org.hamcrest.StringDescription in project neo4j by neo4j.
the class AssertableLogProvider method assertContainsMessageMatching.
public void assertContainsMessageMatching(Matcher<String> messageMatcher) {
synchronized (logCalls) {
for (LogCall logCall : logCalls) {
if (messageMatcher.matches(logCall.message)) {
return;
}
}
StringDescription description = new StringDescription();
description.appendDescriptionOf(messageMatcher);
fail(format("Expected at least one log statement with message as %s, but none found. Actual log calls were:\n%s", description.toString(), serialize(logCalls.iterator())));
}
}
Aggregations