use of datawave.query.jexl.DatawaveJexlContext in project datawave by NationalSecurityAgency.
the class JexlEvaluationTest method testCompare.
private void testCompare(String query, boolean expected) {
// populate doc
Key docKey = new Key("shard", "datatype\0uid");
Document d = new Document();
d.put("FOO", new Content("bar", docKey, true));
d.put("FIELD_A", new Content("apple", docKey, true));
d.put("FIELD_A", new Content("banana", docKey, true));
d.put("FIELD_B", new Content("xylophone", docKey, true));
d.put("FIELD_B", new Content("zephyr", docKey, true));
d.put("FIELD_C", new Content("zebra", docKey, true));
d.put("FIELD_C", new Content("zephyr", docKey, true));
// populate context from doc
DatawaveJexlContext context = new DatawaveJexlContext();
d.visit(Arrays.asList("FOO", "FIELD_A", "FIELD_B", "FIELD_C"), context);
Tuple3<Key, Document, DatawaveJexlContext> tuple = new Tuple3<>(docKey, d, context);
JexlEvaluation evaluation = new JexlEvaluation(query, new HitListArithmetic());
boolean result = evaluation.apply(tuple);
assertEquals(expected, result);
}
Aggregations