use of org.hamcrest.StringDescription in project immutables by immutables.
the class ObjectChecker method fail.
static void fail(@Nullable Object actualValue, Matcher<?> matcher) {
Description description = new StringDescription().appendText("\nExpected: ").appendDescriptionOf(matcher).appendText("\n but: ");
matcher.describeMismatch(actualValue, description);
AssertionError assertionError = new AssertionError(description.toString());
assertionError.setStackTrace(ObjectChecker.trimStackTrace(assertionError.getStackTrace()));
throw assertionError;
}
use of org.hamcrest.StringDescription in project JsonPath by jayway.
the class IsJsonFileTest method shouldDescribeMismatchOfInvalidJson.
@Test
public void shouldDescribeMismatchOfInvalidJson() {
Matcher<File> matcher = isJsonFile(withPathEvaluatedTo(true));
Description description = new StringDescription();
matcher.describeMismatch(INVALID_JSON, description);
assertThat(description.toString(), containsString("invalid.json"));
assertThat(description.toString(), containsString("invalid-json"));
}
use of org.hamcrest.StringDescription in project JsonPath by jayway.
the class IsJsonFileTest method shouldBeDescriptive.
@Test
public void shouldBeDescriptive() {
Matcher<File> matcher = isJsonFile(withPathEvaluatedTo(true));
Description description = new StringDescription();
matcher.describeTo(description);
assertThat(description.toString(), startsWith("is json"));
assertThat(description.toString(), containsString(MATCH_TRUE_TEXT));
}
use of org.hamcrest.StringDescription in project JsonPath by jayway.
the class IsJsonStringTest method shouldDescribeMismatchOfInvalidJson.
@Test
public void shouldDescribeMismatchOfInvalidJson() {
Matcher<String> matcher = isJsonString(withPathEvaluatedTo(true));
Description description = new StringDescription();
matcher.describeMismatch("invalid-json", description);
assertThat(description.toString(), containsString("\"invalid-json\""));
}
use of org.hamcrest.StringDescription in project JsonPath by jayway.
the class IsJsonStringTest method shouldBeDescriptive.
@Test
public void shouldBeDescriptive() {
Matcher<String> matcher = isJsonString(withPathEvaluatedTo(true));
Description description = new StringDescription();
matcher.describeTo(description);
assertThat(description.toString(), startsWith("is json"));
assertThat(description.toString(), containsString(MATCH_TRUE_TEXT));
}
Aggregations