use of org.apache.atlas.catalog.InstanceRequest in project incubator-atlas by apache.
the class TaxonomyResourceDefinitionTest 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 taxonomyDefinition = new TaxonomyResourceDefinition();
taxonomyDefinition.validateCreatePayload(request);
}
use of org.apache.atlas.catalog.InstanceRequest in project incubator-atlas by apache.
the class EntityService method tagEntity.
@POST
@Path("{entityId}/tags/{tag}")
@Produces(Servlets.JSON_MEDIA_TYPE)
public Response tagEntity(String body, @Context HttpHeaders headers, @Context UriInfo ui, @PathParam("entityId") String entityId, @PathParam("tag") String tagName) throws CatalogException {
AtlasPerfTracer perf = null;
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityService.tagEntity(" + entityId + ", " + tagName + ")");
}
Map<String, Object> properties = new HashMap<>();
properties.put("id", entityId);
properties.put("name", tagName);
createResource(entityTagResourceProvider, new InstanceRequest(properties));
return Response.status(Response.Status.CREATED).entity(new Results(ui.getRequestUri().toString(), 201)).build();
} finally {
AtlasPerfTracer.log(perf);
}
}
use of org.apache.atlas.catalog.InstanceRequest in project incubator-atlas by apache.
the class EntityResourceDefinitionTest method testValidate.
// Because we don't currently support entity creation, this method is basically a no-op.
@Test
public void testValidate() throws Exception {
Request request = new InstanceRequest(Collections.<String, Object>emptyMap());
ResourceDefinition entityDefinition = new EntityResourceDefinition();
entityDefinition.validateCreatePayload(request);
}
use of org.apache.atlas.catalog.InstanceRequest in project incubator-atlas by apache.
the class EntityTagResourceDefinitionTest 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 entityTagDefinition = new EntityTagResourceDefinition();
Map<String, Object> filteredProperties = entityTagDefinition.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