use of datawave.query.util.MockMetadataHelper in project datawave by NationalSecurityAgency.
the class FunctionIndexQueryExpansionVisitorTest method expandContentAdjacentFunctionIntoSingleField.
@Test
public void expandContentAdjacentFunctionIntoSingleField() throws ParseException {
Set<String> fields = Sets.newHashSet("FOO", "BAR");
Set<String> tfFields = Sets.newHashSet("FOO");
// Configure the mock metadata helper.
MockMetadataHelper mockMetadataHelper = new MockMetadataHelper();
mockMetadataHelper.setIndexedFields(fields);
mockMetadataHelper.addTermFrequencyFields(tfFields);
this.metadataHelper = mockMetadataHelper;
// Execute the test.
String original = "content:adjacent(termOffsetMap, 'abc', 'def')";
String expected = "(content:adjacent(FOO, termOffsetMap, 'abc', 'def') && FOO == 'def' && FOO == 'abc')";
runTest(original, expected);
original = "content:adjacent(FOO, termOffsetMap, 'abc', 'def')";
expected = "(content:adjacent(FOO, termOffsetMap, 'abc', 'def') && FOO == 'def' && FOO == 'abc')";
runTest(original, expected);
}
use of datawave.query.util.MockMetadataHelper in project datawave by NationalSecurityAgency.
the class FunctionIndexQueryExpansionVisitorTest method expandContentPhraseFunctionIntoSingleField.
@Test
public void expandContentPhraseFunctionIntoSingleField() throws ParseException {
Set<String> fields = Sets.newHashSet("FOO");
// Configure the mock metadata helper.
MockMetadataHelper mockMetadataHelper = new MockMetadataHelper();
mockMetadataHelper.setIndexedFields(fields);
mockMetadataHelper.addTermFrequencyFields(fields);
this.metadataHelper = mockMetadataHelper;
// Execute the test.
String original = "content:phrase(termOffsetMap, 'abc', 'def')";
String expected = "(content:phrase(FOO, termOffsetMap, 'abc', 'def') && FOO == 'def' && FOO == 'abc')";
runTest(original, expected);
original = "content:phrase(FOO, termOffsetMap, 'abc', 'def')";
expected = "(content:phrase(FOO, termOffsetMap, 'abc', 'def') && FOO == 'def' && FOO == 'abc')";
runTest(original, expected);
}
use of datawave.query.util.MockMetadataHelper 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.MockMetadataHelper in project datawave by NationalSecurityAgency.
the class ExecutableExpansionVisitorTest2 method beforeEach.
@Before
public void beforeEach() {
config = new ShardQueryConfiguration();
config.setIndexedFields(indexedFields);
metadataHelper = new MockMetadataHelper();
metadataHelper.setIndexedFields(indexedFields);
}
use of datawave.query.util.MockMetadataHelper in project datawave by NationalSecurityAgency.
the class ExpandCompositeTermsTest method runTestQuery.
void runTestQuery(String query, String expected, Set<String> indexedFields, ShardQueryConfiguration conf) throws ParseException {
ASTJexlScript original = JexlASTHelper.parseJexlQuery(query);
MockMetadataHelper helper = new MockMetadataHelper();
helper.setIndexedFields(indexedFields);
ASTJexlScript expand = FunctionIndexQueryExpansionVisitor.expandFunctions(conf, helper, DateIndexHelper.getInstance(), original);
expand = ExpandCompositeTerms.expandTerms(conf, expand);
// Verify the script is as expected, and has a valid lineage.
JexlNodeAssert.assertThat(expand).isEqualTo(expected).hasValidLineage();
// Verify the original script was not modified, and still has a valid lineage.
JexlNodeAssert.assertThat(original).isEqualTo(query).hasValidLineage();
}
Aggregations