eed3si9n/scalaxb — Issue #120: equals on two scalaxb identical object fails because DataRecord
Author: deanhiller
Created: 2011-11-18 17:51:30+00:00
State: open

I have two for all intensive purposes equal scalaxb objects BUT they both have a DataRecord and both DataRecords have a different writer field instance and the writer field instance is some anonymous class....can't tell what it was but it seems to have no equals method so object identity is used which fails. I have a huge heirarchy and had to diggggg like so to find out write field in the DataRecord is making my equals assertion fail....

My digging to find the issue(I believe you can simply marshal, unmarshal and compare with Assert.assertEquals(oldObj, newObj) to see the issue BUT you have to have a DataRecord in use to see the issue.....

Assert.assertEquals(evtDoc.EPCISHeader, docFromServer.EPCISHeader)
Assert.assertEquals(evtDoc.any, docFromServer.any)
Assert.assertEquals(evtDoc.attributes, docFromServer.attributes)
Assert.assertEquals(evtDoc.creationDate, docFromServer.creationDate)

Assert.assertEquals(evtDoc.EPCISBody.any, docFromServer.EPCISBody.any)
Assert.assertEquals(evtDoc.EPCISBody.attributes, docFromServer.EPCISBody.attributes)

Assert.assertEquals(evtDoc.EPCISBody.EventList.size, docFromServer.EPCISBody.EventList.size)
val old = evtDoc.EPCISBody.EventList.head
val newOne = docFromServer.EPCISBody.EventList.head
val dr1 :DataRecord[Any] = old.eventlisttypeoption.head
val dr2 :DataRecord[Any] = newOne.eventlisttypeoption.head

val evt1 = dr1.as[ObjectEventType]
val evt2 = dr2.as[ObjectEventType]

Assert.assertEquals(evt1, evt2)

Assert.assertEquals(dr1.key, dr2.key)
Assert.assertEquals(dr1.namespace, dr2.namespace)
Assert.assertEquals(dr1.value, dr2.value)
Assert.assertEquals(dr1, dr2)
Assert.assertEquals(old.eventlisttypeoption, newOne.eventlisttypeoption)

Assert.assertEquals(old, newOne)
Assert.assertEquals(evtDoc.EPCISBody.EventList.head, docFromServer.EPCISBody.EventList.head)

Assert.assertEquals(evtDoc.EPCISBody.EventList, docFromServer.EPCISBody.EventList)
Assert.assertEquals(evtDoc.EPCISBody.extension, docFromServer.EPCISBody.extension)

Assert.assertEquals(evtDoc.EPCISBody, docFromServer.EPCISBody)

Assert.assertEquals(evtDoc.extension, docFromServer.extension)
Assert.assertEquals(evtDoc.schemaVersion, docFromServer.schemaVersion)