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"));
}
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);
}
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);
}
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");
}
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"));
}
Aggregations