QueryFactory { public AtlasQuery createTaxonomyQuery(Request request) throws InvalidQueryException { ResourceDefinition taxonomyDefinition = new TaxonomyResourceDefinition(); QueryExpression queryExpression = create(request, taxonomyDefinition); return new AtlasTaxonomyQuery(queryExpression, taxonomyDefinition, request); } QueryFactory(); AtlasQuery createTaxonomyQuery(Request request); AtlasQuery createTermQuery(Request request); AtlasQuery createEntityQuery(Request request); AtlasQuery createEntityTagQuery(Request request); static final String PATH_SEP_TOKEN; }
@Test public void testCreateTaxonomyQuery() throws Exception { Map<String, Object> requestProps = new HashMap<>(); requestProps.put("name", "test_taxonomy"); Request request = new InstanceRequest(requestProps); QueryFactory factory = new QueryFactory(); AtlasTaxonomyQuery query = (AtlasTaxonomyQuery) factory.createTaxonomyQuery(request); QueryExpression queryExpression = query.getQueryExpression(); assertEquals(queryExpression.getClass(), TermQueryExpression.class); assertEquals(queryExpression.getField(), "name"); assertEquals(queryExpression.getExpectedValue(), "test_taxonomy"); assertEquals(query.getRequest(), request); assertEquals(query.getResourceDefinition().getTypeName(), "Taxonomy"); }
@Test public void testCollectionQuery_TermQuery() throws Exception { String queryString = "name:test_taxonomy"; Request request = new CollectionRequest(Collections.<String, Object>emptyMap(), queryString); QueryFactory factory = new QueryFactory(); AtlasTaxonomyQuery query = (AtlasTaxonomyQuery) factory.createTaxonomyQuery(request); QueryExpression queryExpression = query.getQueryExpression(); assertEquals(queryExpression.getClass(), TermQueryExpression.class); assertEquals(queryExpression.getField(), "name"); assertEquals(queryExpression.getExpectedValue(), "test_taxonomy"); assertEquals(query.getRequest(), request); assertEquals(query.getResourceDefinition().getTypeName(), "Taxonomy"); }
@Test public void testCollectionQuery_PrefixQuery() throws Exception { String queryString = "name:t*"; Request request = new CollectionRequest(Collections.<String, Object>emptyMap(), queryString); QueryFactory factory = new QueryFactory(); AtlasTaxonomyQuery query = (AtlasTaxonomyQuery) factory.createTaxonomyQuery(request); QueryExpression queryExpression = query.getQueryExpression(); assertEquals(queryExpression.getClass(), PrefixQueryExpression.class); assertEquals(queryExpression.getField(), "name"); assertEquals(queryExpression.getExpectedValue(), "t"); assertEquals(query.getRequest(), request); assertEquals(query.getResourceDefinition().getTypeName(), "Taxonomy"); }
@Test public void testCollectionQuery_TermRangeQuery() throws Exception { String queryString = "creation_time:[2013-01-01:07:29:00 TO 2017-01-02]"; Request request = new CollectionRequest(Collections.<String, Object>emptyMap(), queryString); QueryFactory factory = new QueryFactory(); AtlasTaxonomyQuery query = (AtlasTaxonomyQuery) factory.createTaxonomyQuery(request); QueryExpression queryExpression = query.getQueryExpression(); assertEquals(queryExpression.getClass(), TermRangeQueryExpression.class); assertEquals(queryExpression.getField(), "creation_time"); assertEquals(query.getRequest(), request); assertEquals(query.getResourceDefinition().getTypeName(), "Taxonomy"); }
@Test public void testCollectionQuery_WildcardQuery() throws Exception { String queryString = "name:ta?onomy"; Request request = new CollectionRequest(Collections.<String, Object>emptyMap(), queryString); QueryFactory factory = new QueryFactory(); AtlasTaxonomyQuery query = (AtlasTaxonomyQuery) factory.createTaxonomyQuery(request); QueryExpression queryExpression = query.getQueryExpression(); assertEquals(queryExpression.getClass(), WildcardQueryExpression.class); assertEquals(queryExpression.getField(), "name"); assertEquals(queryExpression.getExpectedValue(), "ta?onomy"); assertEquals(query.getRequest(), request); assertEquals(query.getResourceDefinition().getTypeName(), "Taxonomy"); }
@Test public void testCollectionQuery_BooleanQuery() throws Exception { String queryString = "name:foo OR name:bar"; Request request = new CollectionRequest(Collections.<String, Object>emptyMap(), queryString); QueryFactory factory = new QueryFactory(); AtlasTaxonomyQuery query = (AtlasTaxonomyQuery) factory.createTaxonomyQuery(request); QueryExpression queryExpression = query.getQueryExpression(); assertEquals(queryExpression.getClass(), BooleanQueryExpression.class); assertEquals(query.getRequest(), request); assertEquals(query.getResourceDefinition().getTypeName(), "Taxonomy"); }