Search in sources :

Example 76 with QueryImpl

use of datawave.webservice.query.QueryImpl in project datawave by NationalSecurityAgency.

the class DefaultEdgeEventQueryLogicTest method orAbleFieldtest.

@Test(expected = IllegalArgumentException.class)
public void orAbleFieldtest() throws Exception {
    Query query = new QueryImpl();
    query.setQuery("SOURCE == 'sourceValue' AND SINK == 'targetValue' AND TYPE == 'TEST1' AND RELATION == 'REL1-REL2' AND ATTRIBUTE1 == 'SOURCE1-SOURCE2' AND (ATTRIBUTE2 == 'red' OR ATTRIBUTE2 == 'blue')");
    String transformed = logic.getEventQuery(query);
    assertEquals("(SOURCEFIELD == 'sourceValue' AND TARGETFIELD == 'targetValue' AND ENRICHFIELD == 'enrichValue')", transformed);
    query = new QueryImpl();
    query.setQuery("SOURCE == 'sourceValue' AND SINK == 'targetValue' AND TYPE == 'TEST1' AND RELATION == 'REL1-REL2' AND (ATTRIBUTE1 == 'SOURCE1-SOURCE2' OR ATTRIBUTE1 == 'SOURCE2-SOURCE2')");
    // throws
    transformed = logic.getEventQuery(query);
}
Also used : QueryImpl(datawave.webservice.query.QueryImpl) Query(datawave.webservice.query.Query) Test(org.junit.Test)

Example 77 with QueryImpl

use of datawave.webservice.query.QueryImpl in project datawave by NationalSecurityAgency.

the class DefaultEdgeEventQueryLogicTest method testGroupedEnrichmentField.

@Test
public void testGroupedEnrichmentField() throws Exception {
    Query query = new QueryImpl();
    query.setQuery("SOURCE == 'sourceValue' AND SINK == 'targetValue' AND TYPE == 'TEST8' AND RELATION == 'REL1-REL2' AND ATTRIBUTE1 == 'SOURCE1-SOURCE2'");
    String transformed = logic.getEventQuery(query);
    assertEquals("(SOURCEFIELD == 'sourceValue' AND TARGETFIELD == 'targetValue' AND $1_5 == 'enrichValue')", transformed);
}
Also used : QueryImpl(datawave.webservice.query.QueryImpl) Query(datawave.webservice.query.Query) Test(org.junit.Test)

Example 78 with QueryImpl

use of datawave.webservice.query.QueryImpl in project datawave by NationalSecurityAgency.

the class DefaultEdgeEventQueryLogicTest method testInvalidEdgeEventQuery.

@Test(expected = IllegalArgumentException.class)
public void testInvalidEdgeEventQuery() throws Exception {
    Query query = new QueryImpl();
    query.setQuery("SOURCE == 'sourceValue' AND TYPE == 'TEST1' AND RELATION == 'REL1-REL2' AND ATTRIBUTE1 == 'SOURCE1-SOURCE2'");
    // throws
    logic.getEventQuery(query);
}
Also used : QueryImpl(datawave.webservice.query.QueryImpl) Query(datawave.webservice.query.Query) Test(org.junit.Test)

Example 79 with QueryImpl

use of datawave.webservice.query.QueryImpl in project datawave by NationalSecurityAgency.

the class EdgeQueryFunctionalTest method testUnknownFunction.

@Test(expected = UnsupportedOperationException.class)
public void testUnknownFunction() throws Exception {
    QueryImpl q = configQuery("SOURCE == 'SUN' && (filter:includeregex(SINK, 'earth|mars'))", auths);
    EdgeQueryLogic logic = runLogic(q, auths);
    List<String> expected = new ArrayList<>();
    compareResults(logic, expected);
}
Also used : QueryImpl(datawave.webservice.query.QueryImpl) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 80 with QueryImpl

use of datawave.webservice.query.QueryImpl in project datawave by NationalSecurityAgency.

the class EdgeQueryFunctionalTest method testComplexQuery1.

@Test
public void testComplexQuery1() throws Exception {
    QueryImpl q = configQuery("(SOURCE == 'EARTH' || SOURCE == 'PLUTO' || SOURCE == 'MARS' || SOURCE == 'CERES' || SOURCE == 'ASTEROID_BELT') && RELATION == 'FROM-TO' && TYPE == 'AdjacentCelestialBodies'", auths);
    EdgeQueryLogic logic = runLogic(q, auths);
    List<String> expected = new ArrayList<>();
    expected.add("earth%00;moon AdjacentCelestialBodies/FROM-TO:20150713/COSMOS_DATA-COSMOS_DATA [A]");
    expected.add("pluto%00;charon AdjacentCelestialBodies/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("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]");
    compareResults(logic, expected);
}
Also used : QueryImpl(datawave.webservice.query.QueryImpl) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

QueryImpl (datawave.webservice.query.QueryImpl)131 Test (org.junit.Test)96 ArrayList (java.util.ArrayList)54 Query (datawave.webservice.query.Query)40 HashSet (java.util.HashSet)27 BaseQueryLogic (datawave.webservice.query.logic.BaseQueryLogic)18 GenericQueryConfiguration (datawave.webservice.query.configuration.GenericQueryConfiguration)16 Date (java.util.Date)16 QueryParametersImpl (datawave.webservice.query.QueryParametersImpl)14 MultivaluedMapImpl (org.jboss.resteasy.specimpl.MultivaluedMapImpl)13 QueryMetricFactoryImpl (datawave.microservice.querymetric.QueryMetricFactoryImpl)12 QueryParameters (datawave.webservice.query.QueryParameters)12 Value (org.apache.accumulo.core.data.Value)10 Document (datawave.query.attributes.Document)9 ShardQueryConfiguration (datawave.query.config.ShardQueryConfiguration)9 EdgeQueryFunctionalTest (datawave.query.tables.edge.EdgeQueryFunctionalTest)9 QueryLogic (datawave.webservice.query.logic.QueryLogic)9 HashMap (java.util.HashMap)9 Key (org.apache.accumulo.core.data.Key)9 Authorizations (org.apache.accumulo.core.security.Authorizations)9