Search in sources :

Example 16 with RangerAtlasEntity

use of org.apache.ranger.tagsync.source.atlasrest.RangerAtlasEntity in project ranger by apache.

the class TestKafkaResourceMapper method testKafkaResourceFromOnlyClusterName.

@Test
public void testKafkaResourceFromOnlyClusterName() throws Exception {
    Map<String, Object> entAttribs = new HashMap<String, Object>();
    entAttribs.put(AtlasKafkaResourceMapper.ENTITY_ATTRIBUTE_QUALIFIED_NAME, CLUSTER_NAME);
    RangerAtlasEntity entity = getKafkaTopicEntity(entAttribs);
    try {
        RangerServiceResource resource = resourceMapper.buildResource(entity);
        Assert.fail("expected exception. Found " + resource);
    } catch (Exception excp) {
    // ignore
    }
}
Also used : RangerAtlasEntity(org.apache.ranger.tagsync.source.atlasrest.RangerAtlasEntity) HashMap(java.util.HashMap) RangerServiceResource(org.apache.ranger.plugin.model.RangerServiceResource) Test(org.junit.Test)

Example 17 with RangerAtlasEntity

use of org.apache.ranger.tagsync.source.atlasrest.RangerAtlasEntity in project ranger by apache.

the class AtlasNotificationMapper method buildServiceTagsForEntityDeleteNotification.

@SuppressWarnings("unchecked")
private static ServiceTags buildServiceTagsForEntityDeleteNotification(RangerAtlasEntityWithTags entityWithTags) {
    final ServiceTags ret;
    RangerAtlasEntity entity = entityWithTags.getEntity();
    String guid = entity.getGuid();
    if (StringUtils.isNotBlank(guid)) {
        ret = new ServiceTags();
        RangerServiceResource serviceResource = new RangerServiceResource();
        serviceResource.setGuid(guid);
        ret.getServiceResources().add(serviceResource);
    } else {
        ret = buildServiceTags(entityWithTags, null);
        if (ret != null) {
            // tag-definitions should NOT be deleted as part of service-resource delete
            ret.setTagDefinitions(MapUtils.EMPTY_MAP);
            // Ranger deletes tags associated with deleted service-resource
            ret.setTags(MapUtils.EMPTY_MAP);
        }
    }
    if (ret != null) {
        ret.setOp(ServiceTags.OP_DELETE);
    }
    return ret;
}
Also used : RangerAtlasEntity(org.apache.ranger.tagsync.source.atlasrest.RangerAtlasEntity) RangerServiceResource(org.apache.ranger.plugin.model.RangerServiceResource) ServiceTags(org.apache.ranger.plugin.util.ServiceTags)

Example 18 with RangerAtlasEntity

use of org.apache.ranger.tagsync.source.atlasrest.RangerAtlasEntity in project ranger by apache.

the class TestHbaseResourceMapper method getHbaseColumnEntity.

private RangerAtlasEntity getHbaseColumnEntity(Map<String, Object> entAttribs) throws Exception {
    RangerAtlasEntity entity = Mockito.mock(RangerAtlasEntity.class);
    Mockito.when(entity.getTypeName()).thenReturn(AtlasHbaseResourceMapper.ENTITY_TYPE_HBASE_COLUMN);
    Mockito.when(entity.getAttributes()).thenReturn(entAttribs);
    return entity;
}
Also used : RangerAtlasEntity(org.apache.ranger.tagsync.source.atlasrest.RangerAtlasEntity)

Example 19 with RangerAtlasEntity

use of org.apache.ranger.tagsync.source.atlasrest.RangerAtlasEntity in project ranger by apache.

the class TestHbaseResourceMapper method getHbaseTableEntity.

private RangerAtlasEntity getHbaseTableEntity(Map<String, Object> entAttribs) throws Exception {
    RangerAtlasEntity entity = Mockito.mock(RangerAtlasEntity.class);
    Mockito.when(entity.getTypeName()).thenReturn(AtlasHbaseResourceMapper.ENTITY_TYPE_HBASE_TABLE);
    Mockito.when(entity.getAttributes()).thenReturn(entAttribs);
    return entity;
}
Also used : RangerAtlasEntity(org.apache.ranger.tagsync.source.atlasrest.RangerAtlasEntity)

Example 20 with RangerAtlasEntity

use of org.apache.ranger.tagsync.source.atlasrest.RangerAtlasEntity in project ranger by apache.

the class TestHbaseResourceMapper method testHbaseDottedColumn.

@Test
public void testHbaseDottedColumn() throws Exception {
    Map<String, Object> entAttribs = new HashMap<String, Object>();
    entAttribs.put(ENTITY_ATTRIBUTE_QUALIFIED_NAME, DOTTED_COLUMN_QUALIFIED_NAME);
    RangerAtlasEntity entity = getHbaseColumnEntity(entAttribs);
    RangerServiceResource resource = resourceMapper.buildResource(entity);
    assertColumnResource(resource, true);
}
Also used : RangerAtlasEntity(org.apache.ranger.tagsync.source.atlasrest.RangerAtlasEntity) HashMap(java.util.HashMap) RangerServiceResource(org.apache.ranger.plugin.model.RangerServiceResource) Test(org.junit.Test)

Aggregations

RangerAtlasEntity (org.apache.ranger.tagsync.source.atlasrest.RangerAtlasEntity)40 RangerServiceResource (org.apache.ranger.plugin.model.RangerServiceResource)30 HashMap (java.util.HashMap)29 Test (org.junit.Test)28 ServiceTags (org.apache.ranger.plugin.util.ServiceTags)3 RangerTagDef (org.apache.ranger.plugin.model.RangerTagDef)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 RangerTag (org.apache.ranger.plugin.model.RangerTag)1 RangerTagAttributeDef (org.apache.ranger.plugin.model.RangerTagDef.RangerTagAttributeDef)1 RangerAtlasEntityWithTags (org.apache.ranger.tagsync.source.atlasrest.RangerAtlasEntityWithTags)1