Search in sources :

Example 11 with Request

use of org.apache.atlas.catalog.Request 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 12 with Request

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

the class TermResourceDefinitionTest method testValidate.

@Test
public void testValidate() throws Exception {
    Map<String, Object> properties = new HashMap<>();
    properties.put("name", "taxonomy1.termName");
    properties.put("description", "foo");
    properties.put("available_as_tag", true);
    properties.put("acceptable_use", "something");
    Request request = new InstanceRequest(properties);
    ResourceDefinition termDefinition = new TermResourceDefinition();
    termDefinition.validateCreatePayload(request);
}
Also used : CollectionRequest(org.apache.atlas.catalog.CollectionRequest) InstanceRequest(org.apache.atlas.catalog.InstanceRequest) Request(org.apache.atlas.catalog.Request) InstanceRequest(org.apache.atlas.catalog.InstanceRequest) Test(org.testng.annotations.Test)

Example 13 with Request

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

the class TermResourceDefinitionTest method testValidate_invalidTermName.

@Test(expectedExceptions = InvalidPayloadException.class)
public void testValidate_invalidTermName() throws Exception {
    Map<String, Object> properties = new HashMap<>();
    properties.put("name", "NotQualifiedTermName");
    properties.put("description", "foo");
    properties.put("available_as_tag", true);
    Request request = new InstanceRequest(properties);
    ResourceDefinition termDefinition = new TermResourceDefinition();
    termDefinition.validateCreatePayload(request);
}
Also used : CollectionRequest(org.apache.atlas.catalog.CollectionRequest) InstanceRequest(org.apache.atlas.catalog.InstanceRequest) Request(org.apache.atlas.catalog.Request) InstanceRequest(org.apache.atlas.catalog.InstanceRequest) Test(org.testng.annotations.Test)

Example 14 with Request

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

the class TermResourceDefinitionTest method testValidate_invalidProperty.

@Test(expectedExceptions = InvalidPayloadException.class)
public void testValidate_invalidProperty() throws Exception {
    Map<String, Object> properties = new HashMap<>();
    properties.put("name", "foo");
    properties.put("unknownProperty", "value");
    Request request = new InstanceRequest(properties);
    ResourceDefinition termDefinition = new TermResourceDefinition();
    termDefinition.validateCreatePayload(request);
}
Also used : CollectionRequest(org.apache.atlas.catalog.CollectionRequest) InstanceRequest(org.apache.atlas.catalog.InstanceRequest) Request(org.apache.atlas.catalog.Request) InstanceRequest(org.apache.atlas.catalog.InstanceRequest) Test(org.testng.annotations.Test)

Example 15 with Request

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

the class EntityTagResourceDefinitionTest method testValidate.

@Test
public void testValidate() throws Exception {
    Map<String, Object> properties = new HashMap<>();
    properties.put("name", "taxonomy1.termName");
    Request request = new InstanceRequest(properties);
    ResourceDefinition entityTagDefinition = new EntityTagResourceDefinition();
    entityTagDefinition.validateCreatePayload(request);
}
Also used : CollectionRequest(org.apache.atlas.catalog.CollectionRequest) InstanceRequest(org.apache.atlas.catalog.InstanceRequest) Request(org.apache.atlas.catalog.Request) InstanceRequest(org.apache.atlas.catalog.InstanceRequest) Test(org.testng.annotations.Test)

Aggregations

Request (org.apache.atlas.catalog.Request)45 Test (org.testng.annotations.Test)45 CollectionRequest (org.apache.atlas.catalog.CollectionRequest)30 InstanceRequest (org.apache.atlas.catalog.InstanceRequest)30 HashMap (java.util.HashMap)12 Response (javax.ws.rs.core.Response)12 UriInfo (javax.ws.rs.core.UriInfo)12 ResourceProvider (org.apache.atlas.catalog.ResourceProvider)12 TaxonomyResourceProvider (org.apache.atlas.catalog.TaxonomyResourceProvider)12 MetadataService (org.apache.atlas.services.MetadataService)12 AtlasTypeDefStore (org.apache.atlas.store.AtlasTypeDefStore)12 URI (java.net.URI)10 TermPath (org.apache.atlas.catalog.TermPath)9 ArrayList (java.util.ArrayList)6 Map (java.util.Map)6 JsonSerializer (org.apache.atlas.catalog.JsonSerializer)6 Result (org.apache.atlas.catalog.Result)6 GremlinPipeline (com.tinkerpop.gremlin.java.GremlinPipeline)3 Pipe (com.tinkerpop.pipes.Pipe)3 ResourceDefinition (org.apache.atlas.catalog.definition.ResourceDefinition)3