Commit 73640cc6 by Shwetha GS

ATLAS-723 JSON deserialization regression (guptaneeru via shwethags)

parent c69df40f
......@@ -18,6 +18,7 @@ ATLAS-409 Atlas will not import avro tables with schema read from a file (dosset
ATLAS-379 Create sqoop and falcon metadata addons (venkatnrangan,bvellanki,sowmyaramesh via shwethags)
ALL CHANGES:
ATLAS-723 JSON deserialization regression (guptaneeru via shwethags)
ATLAS-728 Fix few typos in committer email IDs (yhemanth)
ATLAS-435 Add ORDER BY and Limit to search DSL (neerugupta via sumasai)
ATLAS-543 Entity Instance requests should not require ID element for new Entities (harishjp via shwethags)
......
......@@ -104,9 +104,9 @@ object InstanceSerialization {
refClass <- idClass
typNm <- typeName
i <- id
s <- state
s <- Some (state)
v <- version
} yield _Id(i, v, typNm, Some(s))
} yield _Id(i, v, typNm, s)
}
/**
......
......@@ -18,14 +18,20 @@
package org.apache.atlas.typesystem.json
import com.google.common.collect.ImmutableSet
import scala.util.Random
import org.apache.atlas.typesystem.Referenceable
import org.apache.atlas.typesystem.types.{DataTypes, TypeSystem}
import org.apache.atlas.typesystem.persistence.Id
import org.apache.atlas.typesystem.types.DataTypes
import org.apache.atlas.typesystem.types.TypeSystem
import org.apache.atlas.typesystem.types.utils.TypesUtil
import org.testng.Assert._
import org.testng.annotations.{BeforeClass, Test}
import org.testng.Assert.assertEquals
import org.testng.Assert.assertNotNull
import org.testng.Assert.assertTrue
import org.testng.annotations.BeforeClass
import org.testng.annotations.Test
import scala.util.Random
import com.google.common.collect.ImmutableSet
class InstanceSerializationTest {
private var typeName: String = null
......@@ -46,6 +52,64 @@ class InstanceSerializationTest {
assertEquals(entity2.getTraits, entity.getTraits, "Traits mismatch")
}
@Test def testReferenceArrayWithNoState {
val staticJson = """{
"jsonClass": "org.apache.atlas.typesystem.json.InstanceSerialization$_Reference",
"id": {
"jsonClass": "org.apache.atlas.typesystem.json.InstanceSerialization$_Id",
"version": 0,
"typeName": "LoadProcess"
},
"typeName": "LoadProcess",
"values": {
"inputTables": [{
"jsonClass": "org.apache.atlas.typesystem.json.InstanceSerialization$_Id",
"id": "bacfa996-e88e-4d7e-9630-68c9829b10b4",
"version": 0,
"typeName": "Table"
}, {
"jsonClass": "org.apache.atlas.typesystem.json.InstanceSerialization$_Id",
"id": "6da06805-3f56-446f-8831-672a65ac2199",
"version": 0,
"typeName": "Table"
}
],
"outputTable": {
"jsonClass": "org.apache.atlas.typesystem.json.InstanceSerialization$_Id",
"id": "d5c3d6d0-aa10-44c1-b05d-ed9400d2a5ac",
"version": 0,
"typeName": "Table"
},
"name": "loadSalesDaily"
},
"traitNames": [
"ETL"
],
"traits": {
"ETL": {
"jsonClass": "org.apache.atlas.typesystem.json.InstanceSerialization$_Struct",
"typeName": "ETL",
"values": {
}
}
}
}
""";
val entity: Referenceable = InstanceSerialization.fromJsonReferenceable(staticJson, true)
val outputTable = entity.getValuesMap.get("outputTable")
val inputTables : java.util.List[_] = entity.getValuesMap().get("inputTables").asInstanceOf[java.util.List[_]]
assertTrue(outputTable.isInstanceOf[Id]);
import scala.collection.JavaConversions._
for(inputTable <- inputTables) {
assertTrue(inputTable.isInstanceOf[Id]);
}
}
@Test def testMissingStateInId: Unit = {
val entity: Referenceable = new Referenceable(typeName)
val json: String = InstanceSerialization.toJson(entity, true)
......
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