Search in sources :

Example 71 with QueryImpl

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

the class DefaultEdgeEventQueryLogicTest method moreOrTesting.

@Test(expected = IllegalArgumentException.class)
public void moreOrTesting() 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')) OR " + "(SOURCE == 'sourceValue2' AND SINK == 'targetValue2' AND TYPE == 'TEST1' AND RELATION == 'REL1-REL2' AND ATTRIBUTE1 == 'SOURCE1-SOURCE2')");
    String transformed = logic.getEventQuery(query);
    assertEquals("(SOURCEFIELD == 'sourceValue' AND TARGETFIELD == 'targetValue' AND ENRICHFIELD == 'enrichValue') " + "OR (SOURCEFIELD == 'sourceValue2' AND TARGETFIELD == 'targetValue2' 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' AND (ATTRIBUTE2 == 'red' OR ATTRIBUTE3 == 'blue')");
    // throws
    transformed = logic.getEventQuery(query);
}
Also used : QueryImpl(datawave.webservice.query.QueryImpl) Query(datawave.webservice.query.Query) Test(org.junit.Test)

Example 72 with QueryImpl

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

the class DefaultEdgeEventQueryLogicTest method testParseWithLucene.

@Test
public void testParseWithLucene() throws Exception {
    Query query = new QueryImpl();
    Map<String, QueryParser> parsers = new HashMap<>();
    parsers.put("LUCENE", new LuceneToJexlQueryParser());
    logic.setQuerySyntaxParsers(parsers);
    query.setQuery("SOURCE:sourceValue SINK:targetValue TYPE:TEST1 RELATION:REL1-REL2 ATTRIBUTE1:SOURCE1-SOURCE2");
    query.addParameter(QueryParameters.QUERY_SYNTAX, "LUCENE");
    String transformed = logic.getEventQuery(query);
    assertEquals("(SOURCEFIELD == 'sourceValue' AND TARGETFIELD == 'targetValue' AND ENRICHFIELD == 'enrichValue')", transformed);
}
Also used : QueryImpl(datawave.webservice.query.QueryImpl) QueryParser(datawave.query.language.parser.QueryParser) LuceneToJexlQueryParser(datawave.query.language.parser.jexl.LuceneToJexlQueryParser) Query(datawave.webservice.query.Query) HashMap(java.util.HashMap) LuceneToJexlQueryParser(datawave.query.language.parser.jexl.LuceneToJexlQueryParser) Test(org.junit.Test)

Example 73 with QueryImpl

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

the class DefaultEdgeEventQueryLogicTest method testBasicQueryParse.

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

Example 74 with QueryImpl

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

the class DefaultEdgeEventQueryLogicTest method testNoEnrichment.

@Test
public void testNoEnrichment() throws Exception {
    Query query = new QueryImpl();
    query.setQuery("SOURCE == 'sourceValue' AND SINK == 'targetValue' AND TYPE == 'TEST3' AND RELATION == 'REL1-REL2' AND ATTRIBUTE1 == 'SOURCE1-SOURCE2'");
    String transformed = logic.getEventQuery(query);
    assertEquals("(SOURCEFIELD1 == 'sourceValue' AND TARGETFIELD1 == 'targetValue')", transformed);
}
Also used : QueryImpl(datawave.webservice.query.QueryImpl) Query(datawave.webservice.query.Query) Test(org.junit.Test)

Example 75 with QueryImpl

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

the class DefaultEdgeEventQueryLogicTest method testMismatchAttribute1Source.

@Test(expected = IllegalArgumentException.class)
public void testMismatchAttribute1Source() throws Exception {
    Query query = new QueryImpl();
    query.setQuery("SOURCE == 'sourceValue' AND SINK == 'targetValue' AND TYPE == 'TEST7' AND RELATION == 'REL1-REL2' AND ATTRIBUTE1 == 'BLAH1-BLAH2'");
    // throws because BLAH1 and BLAH2 aren't in the edge dictionary
    logic.getEventQuery(query);
}
Also used : QueryImpl(datawave.webservice.query.QueryImpl) Query(datawave.webservice.query.Query) 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