Commit 4f351219 by Suma Shivaprasad

ATLAS-220 Gets on Enum attribute should return EnumValue(yhemanth via sumasai)

parent f671d3ad
...@@ -9,6 +9,7 @@ ATLAS-54 Rename configs in hive hook (shwethags) ...@@ -9,6 +9,7 @@ ATLAS-54 Rename configs in hive hook (shwethags)
ATLAS-3 Mixed Index creation fails with Date types (sumasai via shwethags) ATLAS-3 Mixed Index creation fails with Date types (sumasai via shwethags)
ALL CHANGES: ALL CHANGES:
ATLAS-220 Gets on Enum attribute should return EnumValue(yhemanth via sumasai)
ATLAS-334 Update documentation to reflect copying required atlas file on solr installation (sumasai via shwethags) ATLAS-334 Update documentation to reflect copying required atlas file on solr installation (sumasai via shwethags)
ATLAS-294 Select queries(ex: from DB select DB.name) response contains column names as "_col_x" instead of the actual names requested in the query.(thiyag via sumasai) ATLAS-294 Select queries(ex: from DB select DB.name) response contains column names as "_col_x" instead of the actual names requested in the query.(thiyag via sumasai)
ATLAS-297 KafkaNotificationTest.testSendReceiveMessage fails when atlas-server is running on the same machine (yhemanth via shwethags) ATLAS-297 KafkaNotificationTest.testSendReceiveMessage fails when atlas-server is running on the same machine (yhemanth via shwethags)
......
...@@ -31,6 +31,8 @@ import org.apache.atlas.typesystem.Referenceable; ...@@ -31,6 +31,8 @@ import org.apache.atlas.typesystem.Referenceable;
import org.apache.atlas.typesystem.TypesDef; import org.apache.atlas.typesystem.TypesDef;
import org.apache.atlas.typesystem.json.InstanceSerialization; import org.apache.atlas.typesystem.json.InstanceSerialization;
import org.apache.atlas.typesystem.json.TypesSerialization; import org.apache.atlas.typesystem.json.TypesSerialization;
import org.apache.atlas.typesystem.types.EnumType;
import org.apache.atlas.typesystem.types.EnumValue;
import org.apache.commons.lang.RandomStringUtils; import org.apache.commons.lang.RandomStringUtils;
import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONArray;
import org.testng.Assert; import org.testng.Assert;
...@@ -126,6 +128,27 @@ public class DefaultMetadataServiceTest { ...@@ -126,6 +128,27 @@ public class DefaultMetadataServiceTest {
} }
@Test @Test
public void testCreateEntityWithEnum() throws Exception {
Referenceable dbEntity = createDBEntity();
String db = createInstance(dbEntity);
Referenceable table = new Referenceable(TestUtils.TABLE_TYPE);
table.set("name", TestUtils.randomString());
table.set("description", "random table");
table.set("type", "type");
table.set("tableType", "MANAGED");
table.set("database", dbEntity);
createInstance(table);
String tableDefinitionJson =
metadataService.getEntityDefinition(TestUtils.TABLE_TYPE, "name", (String) table.get("name"));
Referenceable tableDefinition = InstanceSerialization.fromJsonReferenceable(tableDefinitionJson, true);
EnumValue tableType = (EnumValue) tableDefinition.get("tableType");
Assert.assertEquals(tableType, new EnumValue("MANAGED", 1));
}
@Test
public void testGetEntityByUniqueAttribute() throws Exception { public void testGetEntityByUniqueAttribute() throws Exception {
Referenceable entity = createDBEntity(); Referenceable entity = createDBEntity();
createInstance(entity); createInstance(entity);
......
...@@ -259,8 +259,14 @@ object InstanceSerialization { ...@@ -259,8 +259,14 @@ object InstanceSerialization {
asJava(r.traits).asInstanceOf[java.util.Map[String, IStruct]]) asJava(r.traits).asInstanceOf[java.util.Map[String, IStruct]])
} }
case l : List[_] => l.map(e => asJava(e)).toList.asJava case l : List[_] => l.map(e => asJava(e)).toList.asJava
case m : Map[_, _] if Try{m.asInstanceOf[Map[String,_]]}.isDefined => case m : Map[_, _] if Try{m.asInstanceOf[Map[String,_]]}.isDefined => {
if (m.keys.size == 2 && m.keys.contains("value") && m.keys.contains("ordinal")) {
new EnumValue(m.get("value").toString, m.get("ordinal").asInstanceOf[BigInt].intValue())
} else {
new InstanceJavaConversion(m.asInstanceOf[Map[String,_]], format).convert new InstanceJavaConversion(m.asInstanceOf[Map[String,_]], format).convert
}
}
case _ => v case _ => v
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment