diff options
author | Johannes Rudolph <johannes_rudolph@gmx.de> | 2012-05-31 14:49:15 +0200 |
---|---|---|
committer | Johannes Rudolph <johannes_rudolph@gmx.de> | 2012-05-31 14:49:15 +0200 |
commit | e06661e549316c3c61c71a7668853d8d71933ee8 (patch) | |
tree | f6a245e3e622c13203f1653b6807c4232dbb106a /src/test/scala/cc | |
parent | 76cb7ff8fc34b3ff723cac87ca544fb6030b31a7 (diff) | |
download | spray-json-e06661e549316c3c61c71a7668853d8d71933ee8.tar.gz spray-json-e06661e549316c3c61c71a7668853d8d71933ee8.tar.bz2 spray-json-e06661e549316c3c61c71a7668853d8d71933ee8.zip |
limited support of JsonPath predicates
Diffstat (limited to 'src/test/scala/cc')
-rw-r--r-- | src/test/scala/cc/spray/json/JsonPathSpecs.scala (renamed from src/test/scala/cc/spray/json/JsonPathParserSpecs.scala) | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/test/scala/cc/spray/json/JsonPathParserSpecs.scala b/src/test/scala/cc/spray/json/JsonPathSpecs.scala index d7c8bf5..2ea495e 100644 --- a/src/test/scala/cc/spray/json/JsonPathParserSpecs.scala +++ b/src/test/scala/cc/spray/json/JsonPathSpecs.scala @@ -2,7 +2,7 @@ package cc.spray.json import org.specs2.mutable.Specification -class JsonPathParserSpecs extends Specification { +class JsonPathSpecs extends Specification { import JsonPath._ "JsonPath parser" should { @@ -13,7 +13,7 @@ class JsonPathParserSpecs extends Specification { parse("$.test.test2") must be_==(Selection(Selection(Root, ByField("test")), ByField("test2"))) } "wildcard selection" in { - parse("$.a.*.c") must be_==(Selection(Selection(Selection(Root, ByField("a")), AllElements), ByField("c"))) + parse("$.a[*].c") must be_==(Selection(Selection(Selection(Root, ByField("a")), AllElements), ByField("c"))) } "element selection" in { "of root" in { @@ -22,6 +22,17 @@ class JsonPathParserSpecs extends Specification { "of field" in { parse("$['abc']") must be_==(Selection(Root, ByField("abc"))) } + "by predicate" in { + "eq" in { + parse("$[?(@.id == 'test')]") must be_==(Selection(Root, ByPredicate(Eq(PathExpr(Selection(Root, ByField("id"))), Constant("test"))))) + } + "lt" in { + parse("$[?(@.id < 12)]") must be_==(Selection(Root, ByPredicate(Lt(PathExpr(Selection(Root, ByField("id"))), Constant(12))))) + } + "exists" in { + parse("$[?(@.id)]") must be_==(Selection(Root, ByPredicate(Exists(Selection(Root, ByField("id")))))) + } + } } } |