Browse Source

Tests covering issue #166

pull/169/head
Kalle Stenflo 9 years ago
parent
commit
569e544a10
  1. 30
      json-path/src/test/java/com/jayway/jsonpath/DeepScanTest.java

30
json-path/src/test/java/com/jayway/jsonpath/DeepScanTest.java

@ -304,4 +304,34 @@ public class DeepScanTest extends BaseTest {
assertThat(result).hasSize(1);
}
@Test
public void deepScanPathDefault() {
executeScanPath();
}
@Test
public void deepScanPathRequireProperties() {
executeScanPath(Option.REQUIRE_PROPERTIES);
}
private void executeScanPath(Option... options) {
String json = "{'index': 'index', 'data': {'array': [{ 'object1': { 'name': 'robert'} }]}}";
Map<String, Object> expected = new HashMap<String, Object>() {{
put("object1", new HashMap<String, String>() {{
put("name", "robert");
}});
}};
Configuration configuration = Configuration
.builder()
.options(options)
.build();
List<Map<String, Object>> result = JsonPath
.using(configuration)
.parse(json)
.read("$..array[0]");
assertThat(result.get(0)).isEqualTo(expected);
}
}

Loading…
Cancel
Save