Search in sources :

Example 16 with StringDescription

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

Example 17 with StringDescription

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"));
}
Also used : Description(org.hamcrest.Description) StringDescription(org.hamcrest.StringDescription) StringDescription(org.hamcrest.StringDescription) File(java.io.File) JsonPathMatchers.isJsonFile(com.jayway.jsonpath.matchers.JsonPathMatchers.isJsonFile) ResourceHelpers.resourceAsFile(com.jayway.jsonpath.matchers.helpers.ResourceHelpers.resourceAsFile) Test(org.junit.Test)

Example 18 with StringDescription

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));
}
Also used : Description(org.hamcrest.Description) StringDescription(org.hamcrest.StringDescription) StringDescription(org.hamcrest.StringDescription) File(java.io.File) JsonPathMatchers.isJsonFile(com.jayway.jsonpath.matchers.JsonPathMatchers.isJsonFile) ResourceHelpers.resourceAsFile(com.jayway.jsonpath.matchers.helpers.ResourceHelpers.resourceAsFile) Test(org.junit.Test)

Example 19 with StringDescription

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\""));
}
Also used : Description(org.hamcrest.Description) StringDescription(org.hamcrest.StringDescription) StringDescription(org.hamcrest.StringDescription) JsonPathMatchers.isJsonString(com.jayway.jsonpath.matchers.JsonPathMatchers.isJsonString) Test(org.junit.Test)

Example 20 with StringDescription

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));
}
Also used : Description(org.hamcrest.Description) StringDescription(org.hamcrest.StringDescription) StringDescription(org.hamcrest.StringDescription) JsonPathMatchers.isJsonString(com.jayway.jsonpath.matchers.JsonPathMatchers.isJsonString) 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