Search in sources :

Example 6 with CollectionRequest

use of org.apache.atlas.catalog.CollectionRequest in project incubator-atlas by apache.

the class QueryFactoryTest method testCollectionQuery_TermQuery.

@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");
}
Also used : CollectionRequest(org.apache.atlas.catalog.CollectionRequest) CollectionRequest(org.apache.atlas.catalog.CollectionRequest) InstanceRequest(org.apache.atlas.catalog.InstanceRequest) Request(org.apache.atlas.catalog.Request) Test(org.testng.annotations.Test)

Example 7 with CollectionRequest

use of org.apache.atlas.catalog.CollectionRequest in project incubator-atlas by apache.

the class QueryFactoryTest method testCollectionQuery_BooleanQuery.

@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");
}
Also used : CollectionRequest(org.apache.atlas.catalog.CollectionRequest) CollectionRequest(org.apache.atlas.catalog.CollectionRequest) InstanceRequest(org.apache.atlas.catalog.InstanceRequest) Request(org.apache.atlas.catalog.Request) Test(org.testng.annotations.Test)

Example 8 with CollectionRequest

use of org.apache.atlas.catalog.CollectionRequest in project incubator-atlas by apache.

the class QueryFactoryTest method testCollectionQuery_ProjectionQuery.

@Test
public void testCollectionQuery_ProjectionQuery() throws Exception {
    String queryString = "relation/name:foo";
    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(), ProjectionQueryExpression.class);
    ProjectionQueryExpression projectionExpression = (ProjectionQueryExpression) queryExpression;
    QueryExpression underlyingExpression = projectionExpression.getUnderlyingExpression();
    assertEquals(underlyingExpression.getClass(), TermQueryExpression.class);
    assertEquals(underlyingExpression.getField(), QueryFactory.escape("relation/name"));
    assertEquals(underlyingExpression.getExpectedValue(), "foo");
    assertEquals(query.getRequest(), request);
    assertEquals(query.getResourceDefinition().getTypeName(), "Taxonomy");
}
Also used : CollectionRequest(org.apache.atlas.catalog.CollectionRequest) CollectionRequest(org.apache.atlas.catalog.CollectionRequest) InstanceRequest(org.apache.atlas.catalog.InstanceRequest) Request(org.apache.atlas.catalog.Request) Test(org.testng.annotations.Test)

Example 9 with CollectionRequest

use of org.apache.atlas.catalog.CollectionRequest in project incubator-atlas by apache.

the class TermResourceDefinitionTest method testFilterProperties_Collection.

@Test
public void testFilterProperties_Collection() {
    Map<String, Object> resourceProps = new HashMap<>();
    resourceProps.put("id", "111-222-333");
    resourceProps.put("name", "nameVal");
    resourceProps.put("type", "someType");
    resourceProps.put("foo", "fooVal");
    resourceProps.put("bar", "barVal");
    resourceProps.put("description", "desc");
    resourceProps.put("creation_time", "2016:10:10");
    resourceProps.put("acceptable_use", "something");
    resourceProps.put("available_as_tag", true);
    resourceProps.put("other", "otherVal");
    Request request = new CollectionRequest(resourceProps, "someProperty:someValue");
    request.addAdditionalSelectProperties(Collections.singleton("foo"));
    ResourceDefinition termDefinition = new TermResourceDefinition();
    Map<String, Object> filteredProps = termDefinition.filterProperties(request, resourceProps);
    assertEquals(filteredProps.size(), 3);
    // registered collection props
    assertTrue(filteredProps.containsKey("name"));
    assertTrue(filteredProps.containsKey("description"));
    // added prop
    assertTrue(filteredProps.containsKey("foo"));
}
Also used : CollectionRequest(org.apache.atlas.catalog.CollectionRequest) CollectionRequest(org.apache.atlas.catalog.CollectionRequest) InstanceRequest(org.apache.atlas.catalog.InstanceRequest) Request(org.apache.atlas.catalog.Request) Test(org.testng.annotations.Test)

Example 10 with CollectionRequest

use of org.apache.atlas.catalog.CollectionRequest in project incubator-atlas by apache.

the class QueryFactoryTest method testCollectionQuery_TermRangeQuery.

@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");
}
Also used : CollectionRequest(org.apache.atlas.catalog.CollectionRequest) CollectionRequest(org.apache.atlas.catalog.CollectionRequest) InstanceRequest(org.apache.atlas.catalog.InstanceRequest) Request(org.apache.atlas.catalog.Request) Test(org.testng.annotations.Test)

Aggregations

CollectionRequest (org.apache.atlas.catalog.CollectionRequest)13 InstanceRequest (org.apache.atlas.catalog.InstanceRequest)10 Request (org.apache.atlas.catalog.Request)10 Test (org.testng.annotations.Test)10 Produces (javax.ws.rs.Produces)3 AtlasPerfTracer (org.apache.atlas.utils.AtlasPerfTracer)3 GET (javax.ws.rs.GET)2 BaseRequest (org.apache.atlas.catalog.BaseRequest)2 Result (org.apache.atlas.catalog.Result)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 GenericEntity (javax.ws.rs.core.GenericEntity)1 CatalogException (org.apache.atlas.catalog.exception.CatalogException)1