Search in sources :

Example 21 with InstanceRequest

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);
}
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 22 with InstanceRequest

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);
    }
}
Also used : HashMap(java.util.HashMap) AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) InstanceRequest(org.apache.atlas.catalog.InstanceRequest) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Example 23 with InstanceRequest

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);
}
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 24 with InstanceRequest

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