|
|
@ -1,5 +1,6 @@ |
|
|
|
package com.jayway.jsonassert; |
|
|
|
package com.jayway.jsonassert; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.hamcrest.Matchers; |
|
|
|
import org.junit.Test; |
|
|
|
import org.junit.Test; |
|
|
|
|
|
|
|
|
|
|
|
import static com.jayway.jsonassert.JsonAssert.*; |
|
|
|
import static com.jayway.jsonassert.JsonAssert.*; |
|
|
@ -63,7 +64,7 @@ public class JsonAssertTest { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void list_content_can_be_asserted_with_nested_matcher() throws Exception { |
|
|
|
public void list_content_can_be_asserted_with_nested_matcher() throws Exception { |
|
|
|
with(JSON).assertThat("$..book[*]", hasItems( hasEntry("author", "Nigel Rees"), hasEntry("author", "Evelyn Waugh")) ); |
|
|
|
with(JSON).assertThat("$..book[*]", hasItems(hasEntry("author", "Nigel Rees"), hasEntry("author", "Evelyn Waugh"))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
@ -91,4 +92,14 @@ public class JsonAssertTest { |
|
|
|
.assertThat("$.store.book[0].title", equalTo("Sayings of the Century")); |
|
|
|
.assertThat("$.store.book[0].title", equalTo("Sayings of the Century")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
public void no_hit_returns_null() throws Exception { |
|
|
|
|
|
|
|
with(JSON).assertThat("$.store.book[1000].title", Matchers.<Object>nullValue()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
public void invalid_path() throws Exception { |
|
|
|
|
|
|
|
with(JSON).assertThat("$.store.book[*].fooBar", emptyCollection()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|