forked from NationalSecurityAgency/datawave
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enforce term limits during EdgeQueries (NationalSecurityAgency#2274)
* Enforce term limits during EdgeQueries * Update error message * Fix EdgeQuery maxQueryTerms setting
- Loading branch information
1 parent
45623c7
commit c5287da
Showing
3 changed files
with
53 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...ry-core/src/test/java/datawave/query/jexl/visitors/EdgeTableRangeBuildingVisitorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package datawave.query.jexl.visitors; | ||
|
||
import static java.util.Collections.emptyList; | ||
|
||
import static org.junit.Assert.assertThrows; | ||
|
||
import org.apache.commons.jexl3.JexlFeatures; | ||
import org.apache.commons.jexl3.parser.ASTJexlScript; | ||
import org.apache.commons.jexl3.parser.Parser; | ||
import org.apache.commons.jexl3.parser.StringProvider; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import datawave.query.tables.edge.EdgeQueryLogic; | ||
|
||
public class EdgeTableRangeBuildingVisitorTest { | ||
|
||
private int termLimit = 3; | ||
private Parser parser; | ||
|
||
private EdgeTableRangeBuildingVisitor visitor; | ||
|
||
@Before | ||
public void setup() { | ||
parser = new Parser(new StringProvider(";")); | ||
|
||
visitor = new EdgeTableRangeBuildingVisitor(false, emptyList(), termLimit, emptyList()); | ||
} | ||
|
||
@Test | ||
public void shouldEnforceTermLimit() { | ||
ASTJexlScript parsedQuery = parseQuery("TYPE == 'like it' OR TYPE == 'love it' OR TYPE == 'gotta have it' OR TYPE == 'hand it over or else'"); | ||
|
||
assertThrows(IllegalArgumentException.class, () -> parsedQuery.jjtAccept(visitor, null)); | ||
} | ||
|
||
private ASTJexlScript parseQuery(String query) { | ||
return parser.parse(null, new JexlFeatures(), EdgeQueryLogic.fixQueryString(query), null); | ||
} | ||
} |