Browse Source

Added tests for query for null field and query for property on array

pull/27/head
Jack Singleton 12 years ago
parent
commit
c05c4364bc
  1. 22
      json-path/src/test/java/com/jayway/jsonpath/JsonModelTest.java

22
json-path/src/test/java/com/jayway/jsonpath/JsonModelTest.java

@ -9,9 +9,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import static java.util.Arrays.asList; import static java.util.Arrays.asList;
import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.*;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
/** /**
* Created by IntelliJ IDEA. * Created by IntelliJ IDEA.
@ -106,6 +104,24 @@ public class JsonModelTest {
JsonModel.model(DOCUMENT).get("store.invalid"); JsonModel.model(DOCUMENT).get("store.invalid");
} }
@Test
public void query_for_null_property_returns_null() {
String documentWithNull =
"{ \"store\": {\n" +
" \"book\": { \n" +
" \"color\": null\n" +
" }\n" +
" }\n" +
"}";
Object color = JsonModel.model(documentWithNull).get("store.book.color");
assertNull(color);
}
@Test(expected = InvalidPathException.class)
public void query_for_property_on_array_throws() throws Exception {
JsonModel.model(DOCUMENT).get("store.book.color");
}
} }

Loading…
Cancel
Save