Search in sources :

Example 16 with InstanceRequest

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

the class TermResourceDefinitionTest method testFilterProperties_Instance.

@Test
public void testFilterProperties_Instance() {
    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 InstanceRequest(resourceProps);
    request.addAdditionalSelectProperties(Collections.singleton("foo"));
    ResourceDefinition termDefinition = new TermResourceDefinition();
    Map<String, Object> filteredProperties = termDefinition.filterProperties(request, resourceProps);
    assertEquals(filteredProperties.size(), 6);
    // registered collection props
    assertTrue(filteredProperties.containsKey("name"));
    assertTrue(filteredProperties.containsKey("description"));
    assertTrue(filteredProperties.containsKey("available_as_tag"));
    assertTrue(filteredProperties.containsKey("acceptable_use"));
    assertTrue(filteredProperties.containsKey("creation_time"));
    // added prop
    assertTrue(filteredProperties.containsKey("foo"));
}
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 InstanceRequest

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

the class TermResourceDefinitionTest method testValidate_missingName.

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

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

the class QueryFactoryTest method testCreateEntityQuery.

@Test
public void testCreateEntityQuery() throws Exception {
    Map<String, Object> requestProps = new HashMap<>();
    requestProps.put("id", "foo");
    Request request = new InstanceRequest(requestProps);
    QueryFactory factory = new QueryFactory();
    AtlasEntityQuery query = (AtlasEntityQuery) factory.createEntityQuery(request);
    QueryExpression queryExpression = query.getQueryExpression();
    assertEquals(queryExpression.getClass(), TermQueryExpression.class);
    assertEquals(queryExpression.getField(), "id");
    assertEquals(queryExpression.getExpectedValue(), "foo");
    assertEquals(query.getRequest(), request);
    assertEquals(query.getResourceDefinition().getClass(), EntityResourceDefinition.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 InstanceRequest

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

the class QueryFactoryTest method testCreateTaxonomyQuery.

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

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

the class TaxonomyResourceDefinitionTest method testFilterProperties_Instance.

@Test
public void testFilterProperties_Instance() {
    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");
    Request request = new InstanceRequest(resourceProps);
    request.addAdditionalSelectProperties(Collections.singleton("foo"));
    ResourceDefinition taxonomyDefinition = new TaxonomyResourceDefinition();
    Map<String, Object> filteredProperties = taxonomyDefinition.filterProperties(request, resourceProps);
    assertEquals(filteredProperties.size(), 4);
    // registered collection props
    assertTrue(filteredProperties.containsKey("name"));
    assertTrue(filteredProperties.containsKey("description"));
    assertTrue(filteredProperties.containsKey("creation_time"));
    // added prop
    assertTrue(filteredProperties.containsKey("foo"));
}
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

InstanceRequest (org.apache.atlas.catalog.InstanceRequest)24 CollectionRequest (org.apache.atlas.catalog.CollectionRequest)20 Request (org.apache.atlas.catalog.Request)20 Test (org.testng.annotations.Test)20 HashMap (java.util.HashMap)8 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 AtlasPerfTracer (org.apache.atlas.utils.AtlasPerfTracer)4 GET (javax.ws.rs.GET)2 Result (org.apache.atlas.catalog.Result)2 DELETE (javax.ws.rs.DELETE)1 POST (javax.ws.rs.POST)1 BaseRequest (org.apache.atlas.catalog.BaseRequest)1 TermPath (org.apache.atlas.catalog.TermPath)1