use of org.hamcrest.StringDescription in project JsonPath by jayway.
the class IsJsonTest method shouldDescribeMismatchOfValidJson.
@Test
public void shouldDescribeMismatchOfValidJson() {
Matcher<Object> matcher = isJson(withPathEvaluatedTo(true));
Description description = new StringDescription();
matcher.describeMismatch(BOOKS_JSON_STRING, description);
assertThat(description.toString(), containsString(TestingMatchers.MISMATCHED_TEXT));
}
use of org.hamcrest.StringDescription in project JsonPath by jayway.
the class IsJsonTest method shouldBeDescriptive.
@Test
public void shouldBeDescriptive() {
Matcher<Object> matcher = isJson(withPathEvaluatedTo(true));
Description description = new StringDescription();
matcher.describeTo(description);
assertThat(description.toString(), startsWith("is json"));
assertThat(description.toString(), containsString(TestingMatchers.MATCH_TRUE_TEXT));
}
use of org.hamcrest.StringDescription in project JsonPath by jayway.
the class WithJsonPathTest method shouldBeDescriptive.
@Test
public void shouldBeDescriptive() {
Matcher<? super ReadContext> matcher = withJsonPath("path", equalTo(2));
Description description = new StringDescription();
matcher.describeTo(description);
assertThat(description.toString(), containsString("path"));
assertThat(description.toString(), containsString("<2>"));
}
use of org.hamcrest.StringDescription in project JsonPath by jayway.
the class WithJsonPathTest method shouldDescribeMismatchOfEvaluation.
@Test
public void shouldDescribeMismatchOfEvaluation() {
Matcher<? super ReadContext> matcher = withJsonPath("expensive", equalTo(3));
Description description = new StringDescription();
matcher.describeMismatch(BOOKS_JSON, description);
assertThat(description.toString(), containsString("expensive"));
assertThat(description.toString(), containsString("<10>"));
}
use of org.hamcrest.StringDescription in project JsonPath by jayway.
the class WithJsonPathTest method shouldDescribeMismatchOfPathNotFound.
@Test
public void shouldDescribeMismatchOfPathNotFound() {
Matcher<? super ReadContext> matcher = withJsonPath("not-here", equalTo(3));
Description description = new StringDescription();
matcher.describeMismatch(BOOKS_JSON, description);
assertThat(description.toString(), containsString("not-here"));
assertThat(description.toString(), containsString("was not found"));
}
Aggregations