T - the type of the JSON document. This is typically JSONObject, JSONArray or String.public final class SameJSONAs<T>
extends org.hamcrest.TypeSafeDiagnosingMatcher<T>
| Constructor and Description |
|---|
SameJSONAs(T expected,
JSONModalComparator<T> comparator) |
| Modifier and Type | Method and Description |
|---|---|
SameJSONAs<T> |
allowingAnyArrayOrdering()
Creates a matcher that allows any element ordering within JSON arrays.
|
SameJSONAs<T> |
allowingExtraUnexpectedFields()
Creates a matcher that allows fields not present in the expected JSON document.
|
void |
describeTo(org.hamcrest.Description description) |
protected boolean |
matchesSafely(T actual,
org.hamcrest.Description mismatchDescription) |
static SameJSONAs<org.json.JSONArray> |
sameJSONArrayAs(org.json.JSONArray expected)
Creates a matcher that compares
JSONArrays. |
static SameJSONAs<? super org.json.JSONArray> |
sameJSONArrayAs(org.json.JSONArray expected,
JSONModalComparator<org.json.JSONArray> comparator) |
static SameJSONAs<? super String> |
sameJSONAs(String expected)
Creates a matcher that compares JSONObjects or JSONArrays.
|
static SameJSONAs<? super String> |
sameJSONAs(String expected,
JSONModalComparator<String> comparator) |
static SameJSONAs<org.json.JSONObject> |
sameJSONObjectAs(org.json.JSONObject expected)
Creates a matcher that compares
JSONObjects. |
static SameJSONAs<org.json.JSONObject> |
sameJSONObjectAs(org.json.JSONObject expected,
JSONModalComparator<org.json.JSONObject> comparator) |
public SameJSONAs(T expected, JSONModalComparator<T> comparator)
public void describeTo(org.hamcrest.Description description)
protected boolean matchesSafely(T actual, org.hamcrest.Description mismatchDescription)
matchesSafely in class org.hamcrest.TypeSafeDiagnosingMatcher<T>public SameJSONAs<T> allowingAnyArrayOrdering()
{"fib":[0,1,1,2,3]} will match {"fib":[3,1,0,2,1]}.public SameJSONAs<T> allowingExtraUnexpectedFields()
{
"name" : "John Smith",
"address" : {
"street" : "29 Acacia Road"
}
}
then the following document will match:
{
"name" : "John Smith",
"age" : 34,
"address" : {
"street" : "29 Acacia Road",
"city" : "Huddersfield"
}
}
All array elements must exist in both documents, so the expected document
[
{ "name" : "John Smith" }
]
will not match the actual document
[
{ "name" : "John Smith" },
{ "name" : "Bob Jones" }
]public static SameJSONAs<org.json.JSONObject> sameJSONObjectAs(org.json.JSONObject expected)
JSONObjects.expected - the expected JSONObject instanceMatcher instancepublic static SameJSONAs<org.json.JSONObject> sameJSONObjectAs(org.json.JSONObject expected, JSONModalComparator<org.json.JSONObject> comparator)
public static SameJSONAs<org.json.JSONArray> sameJSONArrayAs(org.json.JSONArray expected)
JSONArrays.expected - the expected JSONArray instanceMatcher instancepublic static SameJSONAs<? super org.json.JSONArray> sameJSONArrayAs(org.json.JSONArray expected, JSONModalComparator<org.json.JSONArray> comparator)
public static SameJSONAs<? super String> sameJSONAs(String expected)
expected - the expected JSON documentMatcher instancepublic static SameJSONAs<? super String> sameJSONAs(String expected, JSONModalComparator<String> comparator)
Copyright © 2012. All Rights Reserved.