Browse Source

Added some more tests

pull/1/merge
Johan Haleby 14 years ago
parent
commit
ebc3bedc44
  1. 7
      json-path-assert/src/test/java/com/jayway/jsonassert/JsonAssertTest.java
  2. 1
      json-path-assert/src/test/resources/lotto.json
  3. 3
      json-path/src/test/java/com/jayway/jsonpath/JsonPathTest.java

7
json-path-assert/src/test/java/com/jayway/jsonassert/JsonAssertTest.java

@ -1,9 +1,11 @@
package com.jayway.jsonassert;
import org.hamcrest.Matchers;
import org.json.simple.parser.JSONParser;
import org.junit.Test;
import java.io.InputStream;
import java.io.InputStreamReader;
import static com.jayway.jsonassert.JsonAssert.*;
import static org.hamcrest.Matchers.*;
@ -142,6 +144,11 @@ public class JsonAssertTest {
with(JSON).assertThat("$.store.book[*].fooBar", emptyCollection());
}
@Test
public void path_including_wildcard_path_followed_by_another_path_concatenates_results_to_list() throws Exception {
with(getResourceAsStream("lotto.json")).assertThat("lotto.winners[*].winnerId", hasItems(23L, 54L));
}
private InputStream getResourceAsStream(String resourceName) {
return getClass().getClassLoader().getResourceAsStream(resourceName);

1
json-path-assert/src/test/resources/lotto.json

@ -0,0 +1 @@
{"lotto":{"lottoId":5,"winning-numbers":[2,45,34,23,7,5,3],"winners":[{"winnerId":23,"numbers":[2,45,34,23,3,5]},{"winnerId":54,"numbers":[52,3,12,11,18,22]}]}}

3
json-path/src/test/java/com/jayway/jsonpath/JsonPathTest.java

@ -1,7 +1,10 @@
package com.jayway.jsonpath;
import org.json.simple.parser.JSONParser;
import org.junit.Test;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import java.util.Map;

Loading…
Cancel
Save