How to assert that my return data from MockMvc correctly sorts my data

15 Views Asked by At

I am writing test for a Spring Controller, and I want to assert that the returned data is sorted according to supplied parameters (sort column, ascending/descending). So far I've been extracting a list of objects from the sorted return data, cloned that list, sorted the clone on the supplied field and then compared the original list with the cloned and sorted list. This works somewhat, but I believe I am not guaranteed a specific order within a specific category, ie. SQL will return a,b,c,d etd. if I sort but if there are multiple objects with a b value, they are not necessarily in the same order as the original list, after sorting the clone. Ideas?

I tried cloning the return data, sorting it in the intended way and comparing it to the original sorted return data

0

There are 0 best solutions below