|
|
@ -208,8 +208,9 @@ public class Criteria implements Predicate { |
|
|
|
MATCHES { |
|
|
|
MATCHES { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
boolean eval(Object expected, final Object actual, final PredicateContext ctx) { |
|
|
|
boolean eval(Object expected, final Object actual, final PredicateContext ctx) { |
|
|
|
|
|
|
|
PredicateContextImpl pci = (PredicateContextImpl) ctx; |
|
|
|
Predicate exp = (Predicate) expected; |
|
|
|
Predicate exp = (Predicate) expected; |
|
|
|
return exp.apply(new PredicateContextImpl(actual, ctx.root(), ctx.configuration())); |
|
|
|
return exp.apply(new PredicateContextImpl(actual, ctx.root(), ctx.configuration(), pci.documentPathCache())); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
NOT_EMPTY { |
|
|
|
NOT_EMPTY { |
|
|
@ -286,7 +287,7 @@ public class Criteria implements Predicate { |
|
|
|
if (CriteriaType.EXISTS == criteriaType) { |
|
|
|
if (CriteriaType.EXISTS == criteriaType) { |
|
|
|
boolean exists = ((Boolean) expected); |
|
|
|
boolean exists = ((Boolean) expected); |
|
|
|
try { |
|
|
|
try { |
|
|
|
Configuration c = Configuration.builder().jsonProvider(ctx.configuration().jsonProvider()).options().build(); |
|
|
|
Configuration c = Configuration.builder().jsonProvider(ctx.configuration().jsonProvider()).options(Option.REQUIRE_PROPERTIES).build(); |
|
|
|
path.evaluate(ctx.item(), ctx.root(), c).getValue(); |
|
|
|
path.evaluate(ctx.item(), ctx.root(), c).getValue(); |
|
|
|
return exists; |
|
|
|
return exists; |
|
|
|
} catch (PathNotFoundException e) { |
|
|
|
} catch (PathNotFoundException e) { |
|
|
@ -299,8 +300,15 @@ public class Criteria implements Predicate { |
|
|
|
Object expectedVal = expected; |
|
|
|
Object expectedVal = expected; |
|
|
|
if(expected instanceof Path){ |
|
|
|
if(expected instanceof Path){ |
|
|
|
Path expectedPath = (Path) expected; |
|
|
|
Path expectedPath = (Path) expected; |
|
|
|
Object doc = expectedPath.isRootPath()?ctx.root():ctx.item(); |
|
|
|
|
|
|
|
expectedVal = expectedPath.evaluate(doc, ctx.root(), ctx.configuration()).getValue(); |
|
|
|
if(ctx instanceof PredicateContextImpl){ |
|
|
|
|
|
|
|
//This will use cache for document ($) queries
|
|
|
|
|
|
|
|
PredicateContextImpl ctxi = (PredicateContextImpl) ctx; |
|
|
|
|
|
|
|
expectedVal = ctxi.evaluate(expectedPath); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
Object doc = expectedPath.isRootPath()?ctx.root():ctx.item(); |
|
|
|
|
|
|
|
expectedVal = expectedPath.evaluate(doc, ctx.root(), ctx.configuration()).getValue(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return criteriaType.eval(expectedVal, actual, ctx); |
|
|
|
return criteriaType.eval(expectedVal, actual, ctx); |
|
|
|