Search in sources :

Example 16 with Request

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

the class EntityTagResourceDefinitionTest method testValidate_missingName.

@Test(expectedExceptions = InvalidPayloadException.class)
public void testValidate_missingName() throws Exception {
    Map<String, Object> properties = new HashMap<>();
    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)

Example 17 with Request

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

the class EntityTagResourceDefinitionTest 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("description", "desc");
    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)

Example 18 with Request

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

the class QueryFactoryTest method testCreateEntityTagQuery.

@Test
public void testCreateEntityTagQuery() throws Exception {
    Map<String, Object> requestProps = new HashMap<>();
    requestProps.put("id", "entity_id");
    requestProps.put("name", "test_taxonomy.term1");
    Request request = new InstanceRequest(requestProps);
    QueryFactory factory = new QueryFactory();
    AtlasEntityTagQuery query = (AtlasEntityTagQuery) factory.createEntityTagQuery(request);
    QueryExpression queryExpression = query.getQueryExpression();
    assertEquals(queryExpression.getClass(), TermQueryExpression.class);
    assertEquals(queryExpression.getField(), "name");
    assertEquals(queryExpression.getExpectedValue(), "test_taxonomy.term1");
    assertEquals(query.getRequest(), request);
    assertEquals(query.getResourceDefinition().getClass(), EntityTagResourceDefinition.class);
}
Also used : HashMap(java.util.HashMap) 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 19 with Request

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

the class QueryFactoryTest method testCollectionQuery_WildcardQuery.

@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");
}
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 20 with Request

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

the class TaxonomyServiceTest method testGetTaxonomy.

@Test
public void testGetTaxonomy() throws Exception {
    String taxonomyName = "testTaxonomy";
    MetadataService metadataService = createStrictMock(MetadataService.class);
    AtlasTypeDefStore typeDefStore = createStrictMock(AtlasTypeDefStore.class);
    ResourceProvider taxonomyResourceProvider = createStrictMock(ResourceProvider.class);
    ResourceProvider termResourceProvider = createStrictMock(ResourceProvider.class);
    UriInfo uriInfo = createNiceMock(UriInfo.class);
    JsonSerializer serializer = createStrictMock(JsonSerializer.class);
    Capture<Request> requestCapture = newCapture();
    Collection<Map<String, Object>> resultPropertyMaps = new ArrayList<>();
    Map<String, Object> propertyMap = new HashMap<>();
    propertyMap.put("name", "testTaxonomy");
    resultPropertyMaps.add(propertyMap);
    Result result = new Result(resultPropertyMaps);
    expect(taxonomyResourceProvider.getResourceById(capture(requestCapture))).andReturn(result);
    expect(metadataService.getTypeDefinition(TaxonomyResourceProvider.TAXONOMY_TERM_TYPE)).andReturn(TaxonomyResourceProvider.TAXONOMY_TERM_TYPE + "-definition");
    expect(serializer.serialize(result, uriInfo)).andReturn("Taxonomy Get Response");
    replay(uriInfo, metadataService, taxonomyResourceProvider, termResourceProvider, serializer);
    TestTaxonomyService service = new TestTaxonomyService(metadataService, typeDefStore, taxonomyResourceProvider, termResourceProvider, serializer);
    Response response = service.getTaxonomy(null, uriInfo, taxonomyName);
    Request request = requestCapture.getValue();
    Map<String, Object> requestProperties = request.getQueryProperties();
    assertEquals(requestProperties.size(), 1);
    assertEquals(requestProperties.get("name"), taxonomyName);
    assertEquals(response.getStatus(), 200);
    assertEquals(response.getEntity(), "Taxonomy Get Response");
    verify(uriInfo, taxonomyResourceProvider, termResourceProvider, serializer);
}
Also used : HashMap(java.util.HashMap) Request(org.apache.atlas.catalog.Request) ArrayList(java.util.ArrayList) JsonSerializer(org.apache.atlas.catalog.JsonSerializer) MetadataService(org.apache.atlas.services.MetadataService) AtlasTypeDefStore(org.apache.atlas.store.AtlasTypeDefStore) Result(org.apache.atlas.catalog.Result) Response(javax.ws.rs.core.Response) TaxonomyResourceProvider(org.apache.atlas.catalog.TaxonomyResourceProvider) ResourceProvider(org.apache.atlas.catalog.ResourceProvider) HashMap(java.util.HashMap) Map(java.util.Map) UriInfo(javax.ws.rs.core.UriInfo) 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