Repository: ranger Updated Branches: refs/heads/master ea30b1355 -> 1ab501c3b
http://git-wip-us.apache.org/repos/asf/ranger/blob/1ab501c3/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlasrest/RangerAtlasEntity.java ---------------------------------------------------------------------- diff --git a/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlasrest/RangerAtlasEntity.java b/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlasrest/RangerAtlasEntity.java deleted file mode 100644 index 991dcca..0000000 --- a/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlasrest/RangerAtlasEntity.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.apache.ranger.tagsync.source.atlasrest; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.util.HashMap; -import java.util.Map; - -public class RangerAtlasEntity { - - private final String typeName; - private final String guid; - private final Map<String, Object> attributes; - - public RangerAtlasEntity(String typeName, String guid, Map<String, Object> attributes) { - this.typeName = typeName; - this.guid = guid; - this.attributes = attributes == null ? new HashMap<String, Object>() : attributes; - } - - public String getTypeName() { - return typeName; - } - - public String getGuid() { - return guid; - } - - public Map<String, Object> getAttributes() { return attributes; } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - - sb.append("{typeName=").append(typeName); - sb.append(", guid=").append(guid); - sb.append(", attributes={"); - for (Map.Entry<String, Object> entry : attributes.entrySet()) { - sb.append(" name=").append(entry.getKey()).append(", value=").append(entry.getValue()); - } - sb.append("}"); - - return sb.toString(); - } -} http://git-wip-us.apache.org/repos/asf/ranger/blob/1ab501c3/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlasrest/RangerAtlasEntityWithTags.java ---------------------------------------------------------------------- diff --git a/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlasrest/RangerAtlasEntityWithTags.java b/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlasrest/RangerAtlasEntityWithTags.java deleted file mode 100644 index b25a241..0000000 --- a/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlasrest/RangerAtlasEntityWithTags.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ranger.tagsync.source.atlasrest; - -import org.apache.atlas.type.AtlasClassificationType; -import org.apache.atlas.type.AtlasStructType; -import org.apache.atlas.type.AtlasTypeRegistry; -import org.apache.atlas.v1.model.notification.EntityNotificationV1; -import org.apache.atlas.v1.model.instance.Referenceable; -import org.apache.atlas.v1.model.instance.Struct; -import org.apache.commons.lang.StringUtils; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class RangerAtlasEntityWithTags { - private final RangerAtlasEntity entity; - private final Map<String, Map<String, String>> tags; - private final AtlasTypeRegistry typeRegistry; - - public RangerAtlasEntityWithTags(EntityNotificationV1 notification ) { - Referenceable atlasEntity = notification.getEntity(); - - String guid = atlasEntity.getId()._getId(); - String typeName = atlasEntity.getTypeName(); - - this.entity = new RangerAtlasEntity(typeName, guid, atlasEntity.getValues()); - - this.tags = new HashMap<>(); - - List<Struct> allTraits = notification.getAllTraits(); - for (Struct trait : allTraits) { - String traitName = trait.getTypeName(); - - Map<String, Object> valuesMap = trait.getValuesMap(); - Map<String, String> attributes = new HashMap<>(); - if (valuesMap != null) { - for (Map.Entry<String, Object> value : valuesMap.entrySet()) { - if (value.getValue() != null) { - attributes.put(value.getKey(), value.getValue().toString()); - } - } - } - this.tags.put(traitName, attributes); - } - this.typeRegistry = null; - } - - public RangerAtlasEntityWithTags(RangerAtlasEntity entity, Map<String, Map<String, String>> tags, AtlasTypeRegistry typeRegistry) { - this.entity = entity; - this.tags = tags; - this.typeRegistry = typeRegistry; - } - - public RangerAtlasEntity getEntity() { - return entity; - } - - public Map<String, Map<String, String>> getTags() { - return tags; - } - - public String getTagAttributeType(String tagTypeName, String tagAttributeName) { - String ret = StringUtils.EMPTY; - - if (typeRegistry != null) { - AtlasClassificationType classificationType = typeRegistry.getClassificationTypeByName(tagTypeName); - if (classificationType != null) { - AtlasStructType.AtlasAttribute atlasAttribute = classificationType.getAttribute(tagAttributeName); - - if (atlasAttribute != null) { - ret = atlasAttribute.getTypeName(); - } - } - } - - return ret; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - - if (entity != null) { - sb.append("{entity=").append(entity).append(", "); - } - sb.append("tags={"); - for (Map.Entry<String, Map<String, String>> tag : tags.entrySet()) { - sb.append("{tagName=").append(tag.getKey()); - sb.append(", attributes={"); - for (Map.Entry<String, String> attribute : tag.getValue().entrySet()) { - sb.append("{attributeName=").append(attribute.getKey()); - sb.append(",attributeValue=").append(attribute.getValue()); - sb.append("}"); - } - sb.append("}"); - sb.append("}"); - } - return sb.toString(); - } -} http://git-wip-us.apache.org/repos/asf/ranger/blob/1ab501c3/tagsync/src/test/java/org/apache/ranger/tagsync/process/TestHbaseResourceMapper.java ---------------------------------------------------------------------- diff --git a/tagsync/src/test/java/org/apache/ranger/tagsync/process/TestHbaseResourceMapper.java b/tagsync/src/test/java/org/apache/ranger/tagsync/process/TestHbaseResourceMapper.java index 499247c..e990c28 100644 --- a/tagsync/src/test/java/org/apache/ranger/tagsync/process/TestHbaseResourceMapper.java +++ b/tagsync/src/test/java/org/apache/ranger/tagsync/process/TestHbaseResourceMapper.java @@ -19,9 +19,9 @@ package org.apache.ranger.tagsync.process; +import org.apache.atlas.typesystem.IReferenceableInstance; import org.apache.ranger.plugin.model.RangerServiceResource; import org.apache.ranger.tagsync.source.atlas.AtlasHbaseResourceMapper; -import org.apache.ranger.tagsync.source.atlasrest.RangerAtlasEntity; import org.junit.Assert; import org.junit.Test; import org.mockito.Mockito; @@ -29,8 +29,6 @@ import org.mockito.Mockito; import java.util.HashMap; import java.util.Map; -import static org.apache.ranger.tagsync.source.atlas.AtlasHbaseResourceMapper.ENTITY_ATTRIBUTE_QUALIFIED_NAME; - public class TestHbaseResourceMapper { private static final String TABLE_QUALIFIED_NAME = "table@cl1"; private static final String COLUMN_FAMILY_QUALIFIED_NAME = "table.family@cl1"; @@ -53,9 +51,9 @@ public class TestHbaseResourceMapper { public void testHbaseTable() throws Exception { Map<String, Object> entAttribs = new HashMap<String, Object>(); - entAttribs.put(ENTITY_ATTRIBUTE_QUALIFIED_NAME, TABLE_QUALIFIED_NAME); + entAttribs.put(AtlasHbaseResourceMapper.ENTITY_ATTRIBUTE_QUALIFIED_NAME, TABLE_QUALIFIED_NAME); - RangerAtlasEntity entity = getHbaseTableEntity(entAttribs); + IReferenceableInstance entity = getHbaseTableEntity(entAttribs); RangerServiceResource resource = resourceMapper.buildResource(entity); assertTableResource(resource, false); @@ -65,9 +63,9 @@ public class TestHbaseResourceMapper { public void testHbaseColumnFamily() throws Exception { Map<String, Object> entAttribs = new HashMap<String, Object>(); - entAttribs.put(ENTITY_ATTRIBUTE_QUALIFIED_NAME, COLUMN_FAMILY_QUALIFIED_NAME); + entAttribs.put(AtlasHbaseResourceMapper.ENTITY_ATTRIBUTE_QUALIFIED_NAME, COLUMN_FAMILY_QUALIFIED_NAME); - RangerAtlasEntity entity = getHbaseColumnFamilyEntity(entAttribs); + IReferenceableInstance entity = getHbaseColumnFamilyEntity(entAttribs); RangerServiceResource resource = resourceMapper.buildResource(entity); assertColumnFamilyResource(resource, false); @@ -77,9 +75,9 @@ public class TestHbaseResourceMapper { public void testHbaseColumn() throws Exception { Map<String, Object> entAttribs = new HashMap<String, Object>(); - entAttribs.put(ENTITY_ATTRIBUTE_QUALIFIED_NAME, COLUMN_QUALIFIED_NAME); + entAttribs.put(AtlasHbaseResourceMapper.ENTITY_ATTRIBUTE_QUALIFIED_NAME, COLUMN_QUALIFIED_NAME); - RangerAtlasEntity entity = getHbaseColumnEntity(entAttribs); + IReferenceableInstance entity = getHbaseColumnEntity(entAttribs); RangerServiceResource resource = resourceMapper.buildResource(entity); assertColumnResource(resource, false); @@ -89,7 +87,7 @@ public class TestHbaseResourceMapper { public void testHbaseResourceFromMissingAttribs() throws Exception { Map<String, Object> entAttribs = new HashMap<String, Object>(); - RangerAtlasEntity entity = getHbaseTableEntity(entAttribs); + IReferenceableInstance entity = getHbaseTableEntity(entAttribs); try { RangerServiceResource resource = resourceMapper.buildResource(entity); @@ -104,9 +102,9 @@ public class TestHbaseResourceMapper { public void testHbaseResourceFromMissingColumnFamilyName() throws Exception { Map<String, Object> entAttribs = new HashMap<String, Object>(); - entAttribs.put(ENTITY_ATTRIBUTE_QUALIFIED_NAME, TABLE_QUALIFIED_NAME); + entAttribs.put(AtlasHbaseResourceMapper.ENTITY_ATTRIBUTE_QUALIFIED_NAME, TABLE_QUALIFIED_NAME); - RangerAtlasEntity entity = getHbaseColumnFamilyEntity(entAttribs); + IReferenceableInstance entity = getHbaseColumnFamilyEntity(entAttribs); try { RangerServiceResource resource = resourceMapper.buildResource(entity); @@ -121,9 +119,9 @@ public class TestHbaseResourceMapper { public void testHbaseResourceFromMissingColumnName() throws Exception { Map<String, Object> entAttribs = new HashMap<String, Object>(); - entAttribs.put(ENTITY_ATTRIBUTE_QUALIFIED_NAME, COLUMN_FAMILY_QUALIFIED_NAME); + entAttribs.put(AtlasHbaseResourceMapper.ENTITY_ATTRIBUTE_QUALIFIED_NAME, COLUMN_FAMILY_QUALIFIED_NAME); - RangerAtlasEntity entity = getHbaseColumnEntity(entAttribs); + IReferenceableInstance entity = getHbaseColumnEntity(entAttribs); try { RangerServiceResource resource = resourceMapper.buildResource(entity); @@ -138,9 +136,9 @@ public class TestHbaseResourceMapper { public void testHbaseDottedTable() throws Exception { Map<String, Object> entAttribs = new HashMap<String, Object>(); - entAttribs.put(ENTITY_ATTRIBUTE_QUALIFIED_NAME, DOTTED_TABLE_QUALIFIED_NAME); + entAttribs.put(AtlasHbaseResourceMapper.ENTITY_ATTRIBUTE_QUALIFIED_NAME, DOTTED_TABLE_QUALIFIED_NAME); - RangerAtlasEntity entity = getHbaseTableEntity(entAttribs); + IReferenceableInstance entity = getHbaseTableEntity(entAttribs); RangerServiceResource resource = resourceMapper.buildResource(entity); assertTableResource(resource, true); @@ -150,9 +148,9 @@ public class TestHbaseResourceMapper { public void testHbaseDottedColumnFamily() throws Exception { Map<String, Object> entAttribs = new HashMap<String, Object>(); - entAttribs.put(ENTITY_ATTRIBUTE_QUALIFIED_NAME, DOTTED_COLUMN_FAMILY_QUALIFIED_NAME); + entAttribs.put(AtlasHbaseResourceMapper.ENTITY_ATTRIBUTE_QUALIFIED_NAME, DOTTED_COLUMN_FAMILY_QUALIFIED_NAME); - RangerAtlasEntity entity = getHbaseColumnFamilyEntity(entAttribs); + IReferenceableInstance entity = getHbaseColumnFamilyEntity(entAttribs); RangerServiceResource resource = resourceMapper.buildResource(entity); assertColumnFamilyResource(resource, true); @@ -162,37 +160,37 @@ public class TestHbaseResourceMapper { public void testHbaseDottedColumn() throws Exception { Map<String, Object> entAttribs = new HashMap<String, Object>(); - entAttribs.put(ENTITY_ATTRIBUTE_QUALIFIED_NAME, DOTTED_COLUMN_QUALIFIED_NAME); + entAttribs.put(AtlasHbaseResourceMapper.ENTITY_ATTRIBUTE_QUALIFIED_NAME, DOTTED_COLUMN_QUALIFIED_NAME); - RangerAtlasEntity entity = getHbaseColumnEntity(entAttribs); + IReferenceableInstance entity = getHbaseColumnEntity(entAttribs); RangerServiceResource resource = resourceMapper.buildResource(entity); assertColumnResource(resource, true); } - private RangerAtlasEntity getHbaseTableEntity(Map<String, Object> entAttribs) throws Exception { - RangerAtlasEntity entity = Mockito.mock(RangerAtlasEntity.class); + private IReferenceableInstance getHbaseTableEntity(Map<String, Object> entAttribs) throws Exception { + IReferenceableInstance entity = Mockito.mock(IReferenceableInstance.class); Mockito.when(entity.getTypeName()).thenReturn(AtlasHbaseResourceMapper.ENTITY_TYPE_HBASE_TABLE); - Mockito.when(entity.getAttributes()).thenReturn(entAttribs); + Mockito.when(entity.getValuesMap()).thenReturn(entAttribs); return entity; } - private RangerAtlasEntity getHbaseColumnFamilyEntity(Map<String, Object> entAttribs) throws Exception { - RangerAtlasEntity entity = Mockito.mock(RangerAtlasEntity.class); + private IReferenceableInstance getHbaseColumnFamilyEntity(Map<String, Object> entAttribs) throws Exception { + IReferenceableInstance entity = Mockito.mock(IReferenceableInstance.class); Mockito.when(entity.getTypeName()).thenReturn(AtlasHbaseResourceMapper.ENTITY_TYPE_HBASE_COLUMN_FAMILY); - Mockito.when(entity.getAttributes()).thenReturn(entAttribs); + Mockito.when(entity.getValuesMap()).thenReturn(entAttribs); return entity; } - private RangerAtlasEntity getHbaseColumnEntity(Map<String, Object> entAttribs) throws Exception { - RangerAtlasEntity entity = Mockito.mock(RangerAtlasEntity.class); + private IReferenceableInstance getHbaseColumnEntity(Map<String, Object> entAttribs) throws Exception { + IReferenceableInstance entity = Mockito.mock(IReferenceableInstance.class); Mockito.when(entity.getTypeName()).thenReturn(AtlasHbaseResourceMapper.ENTITY_TYPE_HBASE_COLUMN); - Mockito.when(entity.getAttributes()).thenReturn(entAttribs); + Mockito.when(entity.getValuesMap()).thenReturn(entAttribs); return entity; } http://git-wip-us.apache.org/repos/asf/ranger/blob/1ab501c3/tagsync/src/test/java/org/apache/ranger/tagsync/process/TestHdfsResourceMapper.java ---------------------------------------------------------------------- diff --git a/tagsync/src/test/java/org/apache/ranger/tagsync/process/TestHdfsResourceMapper.java b/tagsync/src/test/java/org/apache/ranger/tagsync/process/TestHdfsResourceMapper.java index 6276904..392b096 100644 --- a/tagsync/src/test/java/org/apache/ranger/tagsync/process/TestHdfsResourceMapper.java +++ b/tagsync/src/test/java/org/apache/ranger/tagsync/process/TestHdfsResourceMapper.java @@ -23,10 +23,10 @@ import java.util.HashMap; import java.util.Map; import java.util.Properties; +import org.apache.atlas.typesystem.IReferenceableInstance; import org.apache.ranger.plugin.model.RangerServiceResource; import org.apache.ranger.tagsync.source.atlas.AtlasHdfsResourceMapper; import org.apache.ranger.tagsync.source.atlas.AtlasResourceMapper; -import org.apache.ranger.tagsync.source.atlasrest.RangerAtlasEntity; import org.junit.Test; import org.mockito.Mockito; @@ -60,7 +60,7 @@ public class TestHdfsResourceMapper { entAttribs.put(AtlasHdfsResourceMapper.ENTITY_ATTRIBUTE_PATH, PATH); entAttribs.put(AtlasHdfsResourceMapper.ENTITY_ATTRIBUTE_CLUSTER_NAME, CLUSTER_NAME); - RangerAtlasEntity entity = getHdfsPathEntity(entAttribs); + IReferenceableInstance entity = getHdfsPathEntity(entAttribs); RangerServiceResource resource = resourceMapper.buildResource(entity); assertServiceResource(resource); @@ -73,7 +73,7 @@ public class TestHdfsResourceMapper { entAttribs.put(AtlasHdfsResourceMapper.ENTITY_ATTRIBUTE_PATH, PATH); entAttribs.put(AtlasHdfsResourceMapper.ENTITY_ATTRIBUTE_QUALIFIED_NAME, QUALIFIED_NAME); - RangerAtlasEntity entity = getHdfsPathEntity(entAttribs); + IReferenceableInstance entity = getHdfsPathEntity(entAttribs); RangerServiceResource resource = resourceMapper.buildResource(entity); assertServiceResource(resource); @@ -86,7 +86,7 @@ public class TestHdfsResourceMapper { entAttribs.put(AtlasHdfsResourceMapper.ENTITY_ATTRIBUTE_CLUSTER_NAME, CLUSTER_NAME); entAttribs.put(AtlasHdfsResourceMapper.ENTITY_ATTRIBUTE_QUALIFIED_NAME, QUALIFIED_NAME); - RangerAtlasEntity entity = getHdfsPathEntity(entAttribs); + IReferenceableInstance entity = getHdfsPathEntity(entAttribs); RangerServiceResource resource = resourceMapper.buildResource(entity); assertServiceResource(resource); @@ -100,7 +100,7 @@ public class TestHdfsResourceMapper { entAttribs.put(AtlasHdfsResourceMapper.ENTITY_ATTRIBUTE_CLUSTER_NAME, CLUSTER_NAME); entAttribs.put(AtlasHdfsResourceMapper.ENTITY_ATTRIBUTE_QUALIFIED_NAME, QUALIFIED_NAME); - RangerAtlasEntity entity = getHdfsPathEntity(entAttribs); + IReferenceableInstance entity = getHdfsPathEntity(entAttribs); RangerServiceResource resource = resourceMapper.buildResource(entity); assertServiceResource(resource); @@ -112,7 +112,7 @@ public class TestHdfsResourceMapper { entAttribs.put(AtlasHdfsResourceMapper.ENTITY_ATTRIBUTE_QUALIFIED_NAME, PATH); - RangerAtlasEntity entity = getHdfsPathEntity(entAttribs); + IReferenceableInstance entity = getHdfsPathEntity(entAttribs); RangerServiceResource resource = resourceMapperWithDefaultClusterName.buildResource(entity); assertServiceResource(resource); @@ -124,7 +124,7 @@ public class TestHdfsResourceMapper { entAttribs.put(AtlasHdfsResourceMapper.ENTITY_ATTRIBUTE_PATH, PATH); - RangerAtlasEntity entity = getHdfsPathEntity(entAttribs); + IReferenceableInstance entity = getHdfsPathEntity(entAttribs); RangerServiceResource resource = resourceMapperWithDefaultClusterName.buildResource(entity); assertServiceResource(resource); @@ -134,7 +134,7 @@ public class TestHdfsResourceMapper { public void testHdfsResourceFromMissingAttribs() throws Exception { Map<String, Object> entAttribs = new HashMap<String, Object>(); - RangerAtlasEntity entity = getHdfsPathEntity(entAttribs); + IReferenceableInstance entity = getHdfsPathEntity(entAttribs); try { RangerServiceResource resource = resourceMapper.buildResource(entity); @@ -145,13 +145,11 @@ public class TestHdfsResourceMapper { } } - private RangerAtlasEntity getHdfsPathEntity(Map<String, Object> entAttribs) throws Exception { - RangerAtlasEntity entity = Mockito.mock(RangerAtlasEntity.class); + private IReferenceableInstance getHdfsPathEntity(Map<String, Object> entAttribs) throws Exception { + IReferenceableInstance entity = Mockito.mock(IReferenceableInstance.class); Mockito.when(entity.getTypeName()).thenReturn(AtlasHdfsResourceMapper.ENTITY_TYPE_HDFS_PATH); - Mockito.when(entity.getAttributes()).thenReturn(entAttribs); - Mockito.when(entity.getAttributes()).thenReturn(entAttribs); - Mockito.when(entity.getAttributes()).thenReturn(entAttribs); + Mockito.when(entity.getValuesMap()).thenReturn(entAttribs); return entity; } http://git-wip-us.apache.org/repos/asf/ranger/blob/1ab501c3/tagsync/src/test/java/org/apache/ranger/tagsync/process/TestHiveResourceMapper.java ---------------------------------------------------------------------- diff --git a/tagsync/src/test/java/org/apache/ranger/tagsync/process/TestHiveResourceMapper.java b/tagsync/src/test/java/org/apache/ranger/tagsync/process/TestHiveResourceMapper.java index 22a0bb4..7fde91a 100644 --- a/tagsync/src/test/java/org/apache/ranger/tagsync/process/TestHiveResourceMapper.java +++ b/tagsync/src/test/java/org/apache/ranger/tagsync/process/TestHiveResourceMapper.java @@ -19,9 +19,9 @@ package org.apache.ranger.tagsync.process; +import org.apache.atlas.typesystem.IReferenceableInstance; import org.apache.ranger.plugin.model.RangerServiceResource; import org.apache.ranger.tagsync.source.atlas.AtlasHiveResourceMapper; -import org.apache.ranger.tagsync.source.atlasrest.RangerAtlasEntity; import org.junit.Assert; import org.junit.Test; import org.mockito.Mockito; @@ -48,7 +48,7 @@ public class TestHiveResourceMapper { entAttribs.put(AtlasHiveResourceMapper.ENTITY_ATTRIBUTE_QUALIFIED_NAME, DB_QUALIFIED_NAME); - RangerAtlasEntity entity = getHiveDbEntity(entAttribs); + IReferenceableInstance entity = getHiveDbEntity(entAttribs); RangerServiceResource resource = resourceMapper.buildResource(entity); assertDbResource(resource); @@ -60,7 +60,7 @@ public class TestHiveResourceMapper { entAttribs.put(AtlasHiveResourceMapper.ENTITY_ATTRIBUTE_QUALIFIED_NAME, TABLE_QUALIFIED_NAME); - RangerAtlasEntity entity = getHiveTableEntity(entAttribs); + IReferenceableInstance entity = getHiveTableEntity(entAttribs); RangerServiceResource resource = resourceMapper.buildResource(entity); assertTableResource(resource); @@ -72,7 +72,7 @@ public class TestHiveResourceMapper { entAttribs.put(AtlasHiveResourceMapper.ENTITY_ATTRIBUTE_QUALIFIED_NAME, COLUMN_QUALIFIED_NAME); - RangerAtlasEntity entity = getHiveColumnEntity(entAttribs); + IReferenceableInstance entity = getHiveColumnEntity(entAttribs); RangerServiceResource resource = resourceMapper.buildResource(entity); assertColumnResource(resource); @@ -82,7 +82,7 @@ public class TestHiveResourceMapper { public void testHiveResourceFromMissingAttribs() throws Exception { Map<String, Object> entAttribs = new HashMap<String, Object>(); - RangerAtlasEntity entity = getHiveDbEntity(entAttribs); + IReferenceableInstance entity = getHiveDbEntity(entAttribs); try { RangerServiceResource resource = resourceMapper.buildResource(entity); @@ -93,29 +93,29 @@ public class TestHiveResourceMapper { } } - private RangerAtlasEntity getHiveDbEntity(Map<String, Object> entAttribs) throws Exception { - RangerAtlasEntity entity = Mockito.mock(RangerAtlasEntity.class); + private IReferenceableInstance getHiveDbEntity(Map<String, Object> entAttribs) throws Exception { + IReferenceableInstance entity = Mockito.mock(IReferenceableInstance.class); Mockito.when(entity.getTypeName()).thenReturn(AtlasHiveResourceMapper.ENTITY_TYPE_HIVE_DB); - Mockito.when(entity.getAttributes()).thenReturn(entAttribs); + Mockito.when(entity.getValuesMap()).thenReturn(entAttribs); return entity; } - private RangerAtlasEntity getHiveTableEntity(Map<String, Object> entAttribs) throws Exception { - RangerAtlasEntity entity = Mockito.mock(RangerAtlasEntity.class); + private IReferenceableInstance getHiveTableEntity(Map<String, Object> entAttribs) throws Exception { + IReferenceableInstance entity = Mockito.mock(IReferenceableInstance.class); Mockito.when(entity.getTypeName()).thenReturn(AtlasHiveResourceMapper.ENTITY_TYPE_HIVE_TABLE); - Mockito.when(entity.getAttributes()).thenReturn(entAttribs); + Mockito.when(entity.getValuesMap()).thenReturn(entAttribs); return entity; } - private RangerAtlasEntity getHiveColumnEntity(Map<String, Object> entAttribs) throws Exception { - RangerAtlasEntity entity = Mockito.mock(RangerAtlasEntity.class); + private IReferenceableInstance getHiveColumnEntity(Map<String, Object> entAttribs) throws Exception { + IReferenceableInstance entity = Mockito.mock(IReferenceableInstance.class); Mockito.when(entity.getTypeName()).thenReturn(AtlasHiveResourceMapper.ENTITY_TYPE_HIVE_COLUMN); - Mockito.when(entity.getAttributes()).thenReturn(entAttribs); + Mockito.when(entity.getValuesMap()).thenReturn(entAttribs); return entity; } http://git-wip-us.apache.org/repos/asf/ranger/blob/1ab501c3/tagsync/src/test/java/org/apache/ranger/tagsync/process/TestKafkaResourceMapper.java ---------------------------------------------------------------------- diff --git a/tagsync/src/test/java/org/apache/ranger/tagsync/process/TestKafkaResourceMapper.java b/tagsync/src/test/java/org/apache/ranger/tagsync/process/TestKafkaResourceMapper.java index ce35944..3beb82f 100644 --- a/tagsync/src/test/java/org/apache/ranger/tagsync/process/TestKafkaResourceMapper.java +++ b/tagsync/src/test/java/org/apache/ranger/tagsync/process/TestKafkaResourceMapper.java @@ -22,9 +22,9 @@ package org.apache.ranger.tagsync.process; import java.util.HashMap; import java.util.Map; +import org.apache.atlas.typesystem.IReferenceableInstance; import org.apache.ranger.plugin.model.RangerServiceResource; import org.apache.ranger.tagsync.source.atlas.AtlasKafkaResourceMapper; -import org.apache.ranger.tagsync.source.atlasrest.RangerAtlasEntity; import org.junit.Test; import org.mockito.Mockito; @@ -46,7 +46,7 @@ public class TestKafkaResourceMapper { entAttribs.put(AtlasKafkaResourceMapper.ENTITY_ATTRIBUTE_QUALIFIED_NAME, QUALIFIED_NAME); - RangerAtlasEntity entity = getKafkaTopicEntity(entAttribs); + IReferenceableInstance entity = getKafkaTopicEntity(entAttribs); RangerServiceResource resource = resourceMapper.buildResource(entity); assertServiceResource(resource); @@ -58,7 +58,7 @@ public class TestKafkaResourceMapper { entAttribs.put(AtlasKafkaResourceMapper.ENTITY_ATTRIBUTE_QUALIFIED_NAME, TOPIC); - RangerAtlasEntity entity = getKafkaTopicEntity(entAttribs); + IReferenceableInstance entity = getKafkaTopicEntity(entAttribs); try { RangerServiceResource resource = resourceMapper.buildResource(entity); @@ -75,7 +75,7 @@ public class TestKafkaResourceMapper { entAttribs.put(AtlasKafkaResourceMapper.ENTITY_ATTRIBUTE_QUALIFIED_NAME, CLUSTER_NAME); - RangerAtlasEntity entity = getKafkaTopicEntity(entAttribs); + IReferenceableInstance entity = getKafkaTopicEntity(entAttribs); try { RangerServiceResource resource = resourceMapper.buildResource(entity); @@ -90,7 +90,7 @@ public class TestKafkaResourceMapper { public void testKafkaResourceFromMissingAttribs() throws Exception { Map<String, Object> entAttribs = new HashMap<String, Object>(); - RangerAtlasEntity entity = getKafkaTopicEntity(entAttribs); + IReferenceableInstance entity = getKafkaTopicEntity(entAttribs); try { RangerServiceResource resource = resourceMapper.buildResource(entity); @@ -101,11 +101,11 @@ public class TestKafkaResourceMapper { } } - private RangerAtlasEntity getKafkaTopicEntity(Map<String, Object> entAttribs) throws Exception { - RangerAtlasEntity entity = Mockito.mock(RangerAtlasEntity.class); + private IReferenceableInstance getKafkaTopicEntity(Map<String, Object> entAttribs) throws Exception { + IReferenceableInstance entity = Mockito.mock(IReferenceableInstance.class); Mockito.when(entity.getTypeName()).thenReturn(AtlasKafkaResourceMapper.ENTITY_TYPE_KAFKA_TOPIC); - Mockito.when(entity.getAttributes()).thenReturn(entAttribs); + Mockito.when(entity.getValuesMap()).thenReturn(entAttribs); return entity; }