use of datawave.query.util.MockDateIndexHelper in project datawave by NationalSecurityAgency.
the class FunctionIndexQueryExpansionVisitorTest method setUp.
@Before
public void setUp() throws Exception {
config = new ShardQueryConfiguration();
metadataHelper = new MockMetadataHelper();
dateIndexHelper = new MockDateIndexHelper();
}
use of datawave.query.util.MockDateIndexHelper in project datawave by NationalSecurityAgency.
the class ContentFunctionsTest method testJexlFunctionArgumentDescriptors.
private void testJexlFunctionArgumentDescriptors(String query, String expected, Set<String> contentFields) throws ParseException {
MockMetadataHelper metadataHelper = new MockMetadataHelper();
metadataHelper.addTermFrequencyFields(Arrays.asList("BODY", "META"));
metadataHelper.setIndexedFields(Sets.newHashSet("BODY", "META"));
if (contentFields != null) {
metadataHelper.addContentFields(contentFields);
}
MockDateIndexHelper dateIndexHelper = new MockDateIndexHelper();
ASTJexlScript script = JexlASTHelper.parseJexlQuery(query);
JexlNode ref = script.jjtGetChild(0);
Assert.assertEquals("First child of ASTJexlScript is not an ASTReference", ASTReference.class, ref.getClass());
JexlNode child = ref.jjtGetChild(0);
Assert.assertEquals("First child of ASTJexlScript is not an AStFunctionNode", ASTFunctionNode.class, child.getClass());
ASTFunctionNode function = (ASTFunctionNode) child;
JexlArgumentDescriptor desc = new ContentFunctionsDescriptor().getArgumentDescriptor(function);
JexlNode indexQuery = desc.getIndexQuery(null, metadataHelper, dateIndexHelper, null);
ASTJexlScript expectedScript = JexlASTHelper.parseJexlQuery(expected);
JexlNode scriptChild = expectedScript.jjtGetChild(0);
Assert.assertTrue("Expected " + JexlStringBuildingVisitor.buildQuery(scriptChild) + " but was " + JexlStringBuildingVisitor.buildQuery(indexQuery), JexlASTHelper.equals(scriptChild, indexQuery));
}
Aggregations