Can you show a short self contained example of what is failing that should be passing that demonstrates what in unitils you are trying to do?
Without knowing anything about unitils, is there a way to specify that subclasses of Collection use something like CollectionUtils.isEqualCollection from commons-collections (which I think would work in your case if you can have that invoked for equality tests on Collections)? On Friday, September 14, 2012 5:14:16 AM UTC-6, Jan Goyvaerts wrote: > > 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 view this discussion on the web visit https://groups.google.com/d/msg/javaposse/-/LuN2K-Xys8wJ. 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.
