For testing purposes I'm using Unitil's utility classes to compare extensive graph models. Rather than spell out the logic to navigate the tree. More precisely to compare a complex JPA entity graph before and after saving. To make sure it survived persisting to the database.
However, it gets into trouble when comparing collections and arrays. When the comparison is said to be "lenient", it compares without taking the order into account. And of course when it isn't lenient it does take the order into account. There's a problem with this approach: When being lenient it has to decide how to relate the collections elements to each other. It has no concept of keys. And sometimes it plainly fail. When being non-lenient, the arrays and List are compared fine. But then the Set are failing sometimes. Because the order is not guaranteed. And sometimes the order happen to be the same. And sometimes not. The bottom line is that it reports a failed test while in fact there isn't. The data only happened to be in a different order. --- A solution to this is to make the relationships with a Map. In that case it seems to be able to relate the right collection elements (with the same key). But then I'll have to make all my relationships with maps. On the other hand, there is indeed a kind of secondary key... I'm a bit puzzled here what to do with it: Change it to Map, look for a different library, ... Somebody ever had to break his/her head on this kind of problem ? TIA - Jan -- You received this message because you are subscribed to the Google Groups "Java Posse" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.
