use of org.apache.commons.jexl3.parser.JexlNode in project datawave by NationalSecurityAgency.
the class JexlASTHelperTest method transitiveEqualsParseWithEscapedRegexTest.
// This test is here to ensure that we can freely convert between a jexl tree and
// a query string, without impact to the string literal for the regex node.
// This also shows that an unescaped backslash (the one before '.blah') will be preserved between conversions.
// WEB QUERY: CITY == 'ci\\\\\\ty\.blah'
// StringLiteral.image: "ci\\\ty\.blah"
@Test
public void transitiveEqualsParseWithEscapedRegexTest() throws Exception {
String query = "CITY == 'ci\\\\\\\\\\\\ty\\.blah'";
JexlNode node = JexlASTHelper.parseJexlQuery(query);
String interpretedQuery = JexlStringBuildingVisitor.buildQuery(node);
JexlNode newNode = JexlASTHelper.parseJexlQuery(interpretedQuery);
String reinterpretedQuery = JexlStringBuildingVisitor.buildQuery(newNode);
// note: while this is different from the original query, it produces the same string literal
Assert.assertEquals("CITY == 'ci\\\\\\\\\\\\ty\\\\.blah'", interpretedQuery);
Assert.assertEquals(reinterpretedQuery, interpretedQuery);
Assert.assertEquals("ci\\\\\\ty\\.blah", node.jjtGetChild(0).jjtGetChild(1).jjtGetChild(0).image);
Assert.assertEquals(node.jjtGetChild(0).jjtGetChild(1).jjtGetChild(0).image, newNode.jjtGetChild(0).jjtGetChild(1).jjtGetChild(0).image);
}
use of org.apache.commons.jexl3.parser.JexlNode in project datawave by NationalSecurityAgency.
the class GeoFunctionsDescriptorTest method testGeoToGeoWaveFunction.
@Test
public void testGeoToGeoWaveFunction() throws Exception {
String query = "geo:within_bounding_box(GEO_FIELD, \"-12.74,16.30\", \"-3.31,26.16\")";
JexlNode node = JexlASTHelper.parseJexlQuery(query);
GeoFunctionsDescriptor.GeoJexlArgumentDescriptor argDesc = (GeoFunctionsDescriptor.GeoJexlArgumentDescriptor) new GeoFunctionsDescriptor().getArgumentDescriptor((ASTFunctionNode) node.jjtGetChild(0).jjtGetChild(0));
JexlNode queryNode = argDesc.toGeoWaveFunction(Sets.newHashSet("GEO_FIELD"));
Assert.assertEquals("geowave:intersects(GEO_FIELD, 'POLYGON ((16.3 -12.74, 26.16 -12.74, 26.16 -3.31, 16.3 -3.31, 16.3 -12.74))')", JexlStringBuildingVisitor.buildQuery(queryNode));
}
use of org.apache.commons.jexl3.parser.JexlNode in project datawave by NationalSecurityAgency.
the class GeoFunctionsDescriptorTest method antiMeridianTest1.
@Test
public void antiMeridianTest1() throws Exception {
String query = "geo:within_bounding_box(GEO_FIELD, '40_170', '50_-170')";
JexlNode node = JexlASTHelper.parseJexlQuery(query);
JexlArgumentDescriptor argDesc = new GeoFunctionsDescriptor().getArgumentDescriptor((ASTFunctionNode) node.jjtGetChild(0).jjtGetChild(0));
JexlNode queryNode = argDesc.getIndexQuery(null, null, null, null);
Assert.assertEquals("(((_Bounded_ = true) && (GEO_FIELD >= '40.0_170.0' && GEO_FIELD <= '50.0_180')) && ((_Bounded_ = true) && (GEO_FIELD >= '40.0_-180' && GEO_FIELD <= '50.0_-170.0')))", JexlStringBuildingVisitor.buildQuery(queryNode));
}
use of org.apache.commons.jexl3.parser.JexlNode in project datawave by NationalSecurityAgency.
the class GeoFunctionsDescriptorTest method testMultiFieldGeoFunction.
@Test
public void testMultiFieldGeoFunction() throws Exception {
String query = "geo:within_circle(FIELD_1 || FIELD_2, '0_0', '10')";
JexlNode node = JexlASTHelper.parseJexlQuery(query);
JexlArgumentDescriptor argDesc = new GeoFunctionsDescriptor().getArgumentDescriptor((ASTFunctionNode) node.jjtGetChild(0).jjtGetChild(0));
JexlNode queryNode = argDesc.getIndexQuery(null, null, null, null);
Assert.assertEquals("(((_Bounded_ = true) && (FIELD_1 >= '-10.0|-10.0' && FIELD_1 <= '10.0|10.0')) || ((_Bounded_ = true) && (FIELD_2 >= '-10.0|-10.0' && FIELD_2 <= '10.0|10.0')))", JexlStringBuildingVisitor.buildQuery(queryNode));
}
use of org.apache.commons.jexl3.parser.JexlNode in project datawave by NationalSecurityAgency.
the class JexlASTHelperTest method parse1InteriorBackslashEquals.
@Test
public void parse1InteriorBackslashEquals() throws Exception {
String query = "CITY == 'ci\\\\ty'";
JexlNode node = JexlASTHelper.parseJexlQuery(query);
String interpretedQuery = JexlStringBuildingVisitor.buildQuery(node);
Assert.assertEquals(query, interpretedQuery);
}
Aggregations