Search in sources :

Example 21 with StringDescription

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));
}
Also used : Description(org.hamcrest.Description) StringDescription(org.hamcrest.StringDescription) StringDescription(org.hamcrest.StringDescription) Test(org.junit.Test)

Example 22 with StringDescription

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));
}
Also used : Description(org.hamcrest.Description) StringDescription(org.hamcrest.StringDescription) StringDescription(org.hamcrest.StringDescription) Test(org.junit.Test)

Example 23 with StringDescription

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>"));
}
Also used : Description(org.hamcrest.Description) StringDescription(org.hamcrest.StringDescription) StringDescription(org.hamcrest.StringDescription) Test(org.junit.Test)

Example 24 with StringDescription

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>"));
}
Also used : Description(org.hamcrest.Description) StringDescription(org.hamcrest.StringDescription) StringDescription(org.hamcrest.StringDescription) Test(org.junit.Test)

Example 25 with StringDescription

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"));
}
Also used : Description(org.hamcrest.Description) StringDescription(org.hamcrest.StringDescription) StringDescription(org.hamcrest.StringDescription) Test(org.junit.Test)

Aggregations

StringDescription (org.hamcrest.StringDescription)32 Description (org.hamcrest.Description)22 Test (org.junit.Test)15 JsonPathMatchers.isJsonFile (com.jayway.jsonpath.matchers.JsonPathMatchers.isJsonFile)3 JsonPathMatchers.isJsonString (com.jayway.jsonpath.matchers.JsonPathMatchers.isJsonString)3 ResourceHelpers.resourceAsFile (com.jayway.jsonpath.matchers.helpers.ResourceHelpers.resourceAsFile)3 File (java.io.File)3 View (android.view.View)2 AdapterView (android.widget.AdapterView)2 Adapter (android.widget.Adapter)1 TextView (android.widget.TextView)1 ViewAssertion (com.google.android.apps.common.testing.ui.espresso.ViewAssertion)1 ScrollToAction (com.google.android.apps.common.testing.ui.espresso.action.ScrollToAction)1 Optional (com.google.common.base.Optional)1 AssertionFailedError (junit.framework.AssertionFailedError)1 AnnotatedElementDeclaration (org.freud.analysed.javasource.AnnotatedElementDeclaration)1 Annotation (org.freud.analysed.javasource.Annotation)1 FreudExtendedMatcher (org.freud.java.matcher.FreudExtendedMatcher)1