use of datawave.webservice.query.QueryImpl in project datawave by NationalSecurityAgency.
the class DefaultEdgeEventQueryLogicTest method testEnrichNoEnrich.
@Test
public void testEnrichNoEnrich() throws Exception {
Query query = new QueryImpl();
query.setQuery("SOURCE == 'sourceValue' AND SINK == 'targetValue' AND TYPE == 'TEST4' AND RELATION == 'REL1-REL2' AND ATTRIBUTE1 == 'SOURCE1-SOURCE2'");
String transformed = logic.getEventQuery(query);
// System.out.println("transformed = " + transformed);
assertEquals("(SOURCEFIELD1 == 'sourceValue' AND TARGETFIELD1 == 'targetValue' AND ENRICHFIELD1 == 'enrichValue1') OR (SOURCEFIELD2 == 'sourceValue' AND TARGETFIELD2 == 'targetValue')", transformed);
}
use of datawave.webservice.query.QueryImpl in project datawave by NationalSecurityAgency.
the class DefaultEdgeEventQueryLogicTest method testMultiNoEnrich.
@Test
public void testMultiNoEnrich() throws Exception {
Query query = new QueryImpl();
query.setQuery("SOURCE == 'sourceValue' AND SINK == 'targetValue' AND TYPE == 'TEST5' AND RELATION == 'REL1-REL2' AND ATTRIBUTE1 == 'SOURCE1-SOURCE2'");
String transformed = logic.getEventQuery(query);
assertEquals("(SOURCEFIELD1 == 'sourceValue' AND TARGETFIELD1 == 'targetValue') OR (SOURCEFIELD2 == 'sourceValue' AND TARGETFIELD2 == 'targetValue')", transformed);
}
use of datawave.webservice.query.QueryImpl in project datawave by NationalSecurityAgency.
the class AbstractFunctionalQuery method runTestQuery.
/**
* Executes the query and performs validation of the results.
*
* @param expected
* expected results from the query
* @param queryStr
* execution query string
* @param startDate
* start date for query (inclusive)
* @param endDate
* end date for query (exclusive)
* @param options
* optional parameters to query
* @param checkers
* optional list of assert checker methods
* @param authSet
* optional set of authorizations to use. If null or empty, will use default auths.
*/
protected void runTestQuery(Collection<String> expected, String queryStr, Date startDate, Date endDate, Map<String, String> options, List<DocumentChecker> checkers, Set<Authorizations> authSet) throws Exception {
if (log.isDebugEnabled()) {
log.debug(" query[" + queryStr + "] start(" + YMD_DateFormat.format(startDate) + ") end(" + YMD_DateFormat.format(endDate) + ")");
}
if (authSet == null || authSet.isEmpty()) {
authSet = this.authSet;
}
QueryImpl q = new QueryImpl();
q.setBeginDate(startDate);
q.setEndDate(endDate);
q.setQuery(queryStr);
q.setParameters(options);
q.setId(UUID.randomUUID());
q.setPagesize(Integer.MAX_VALUE);
q.setQueryAuthorizations(auths.toString());
if (useRunningQuery) {
QueryMetricFactory queryMetricFactory = (metricFactory == null) ? new QueryMetricFactoryImpl() : metricFactory;
new RunningQuery(connector, AccumuloConnectionFactory.Priority.NORMAL, this.logic, q, "", principal, queryMetricFactory);
} else {
GenericQueryConfiguration config = this.logic.initialize(connector, q, authSet);
this.logic.setupQuery(config);
if (log.isDebugEnabled()) {
log.debug("Plan: " + config.getQueryString());
}
}
testHarness.assertLogicResults(this.logic, expected, checkers);
}
use of datawave.webservice.query.QueryImpl in project datawave by NationalSecurityAgency.
the class EdgeQueryFunctionalTest method testComplexQueryWithPatterns.
@Test
public void testComplexQueryWithPatterns() throws Exception {
QueryImpl q = configQuery("(SOURCE =~ 'E.*' || SOURCE == 'PLUTO' || SOURCE =~ 'M.*' || SOURCE == 'CERES' || SOURCE == 'ASTEROID_BELT') && RELATION == 'FROM-TO' && TYPE =~ 'Adjacent.*'", auths);
EdgeQueryLogic logic = runLogic(q, auths);
List<String> expected = new ArrayList<>();
expected.add("earth%00;mars AdjacentPlanets/FROM-TO:20150713/COSMOS_DATA-COSMOS_DATA [A]");
expected.add("earth%00;moon AdjacentCelestialBodies/FROM-TO:20150713/COSMOS_DATA-COSMOS_DATA [A]");
expected.add("eris%00;dysnomia AdjacentCelestialBodies/FROM-TO:20150713/COSMOS_DATA-COSMOS_DATA [B]");
expected.add("pluto%00;charon AdjacentCelestialBodies/FROM-TO:20150713/NEW_HORIZONS-NEW_HORIZONS [C]");
expected.add("pluto%00;neptune AdjacentDwarfPlanets/FROM-TO:20150713/NEW_HORIZONS-NEW_HORIZONS [C]");
expected.add("mars%00;ceres AdjacentCelestialBodies/FROM-TO:20150713/COSMOS_DATA-COSMOS_DATA [B]");
expected.add("ceres%00;jupiter AdjacentCelestialBodies/FROM-TO:20150713/COSMOS_DATA-COSMOS_DATA [A]");
expected.add("ceres%00;jupiter AdjacentDwarfPlanets/FROM-TO:20150713/COSMOS_DATA-COSMOS_DATA [B]");
expected.add("ceres%00;mars AdjacentDwarfPlanets/FROM-TO:20150713/COSMOS_DATA-COSMOS_DATA [B]");
expected.add("asteroid_belt%00;mars AdjacentCelestialBodies/FROM-TO:20150713/COSMOS_DATA-COSMOS_DATA [A]");
expected.add("asteroid_belt%00;ceres AdjacentCelestialBodies/FROM-TO:20150713/COSMOS_DATA-COSMOS_DATA [A]");
expected.add("asteroid_belt%00;jupiter AdjacentCelestialBodies/FROM-TO:20150713/COSMOS_DATA-COSMOS_DATA [A]");
expected.add("mars%00;jupiter AdjacentPlanets/FROM-TO:20150713/COSMOS_DATA-COSMOS_DATA [A]");
expected.add("mercury%00;venus AdjacentPlanets/FROM-TO:20150713/COSMOS_DATA-COSMOS_DATA [A]");
compareResults(logic, expected);
}
use of datawave.webservice.query.QueryImpl in project datawave by NationalSecurityAgency.
the class EdgeQueryFunctionalTest method testTypeQuery.
@Test
public void testTypeQuery() throws Exception {
QueryImpl q = configQuery("SOURCE == 'JUPITER' && TYPE == 'AdjacentDwarfPlanets'", auths);
EdgeQueryLogic logic = runLogic(q, auths);
List<String> expected = new ArrayList<>();
expected.add("jupiter%00;ceres AdjacentDwarfPlanets/TO-FROM:20150713/COSMOS_DATA-COSMOS_DATA [B]");
compareResults(logic, expected);
}
Aggregations