You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a scenario as below.
arrayList countryList =new arrayList();
I have taken arrayList and added all dates to it . Now I need to verify those are in ascending order or not.
When i used below assert its giving error but actually its not an error.
assertThat(sortAscending(countryList)).as("Ascending Sorted order is: "+countryList).isSorted();
Dates sorted in ascending order(MM/DD/YYYY):
09/08/2017
11/08/2017
12/18/2017
12/28/2017
01/08/2018
02/08/2018
03/08/2018
it is giving error at below dates
12/28/2017, 01/08/2018
Can you please help me how to assert date filed with assertJ assertions ?
Also how to verify Descending order with assertJ assertions?
The text was updated successfully, but these errors were encountered:
isSorted relies on the element compareTo method (Date in your case) and checks that consecutive elements are in order.
Can you double check your sortAscending implementation ? My gut feeling is that it does not take the time part of the date.
If you want further help please provide a test case that we can run to reproduce the issue.
One way to to check the reverse order is to create the opposite comparator and use isSortedAccordingTo.
I'm closing this issue as it should have been raised in assertj-core (assertj-examples is just a demo project) but feel free to continue commenting it.
Hi,
I have a scenario as below.
arrayList countryList =new arrayList();
I have taken arrayList and added all dates to it . Now I need to verify those are in ascending order or not.
When i used below assert its giving error but actually its not an error.
assertThat(sortAscending(countryList)).as("Ascending Sorted order is: "+countryList).isSorted();
Dates sorted in ascending order(MM/DD/YYYY):
09/08/2017
11/08/2017
12/18/2017
12/28/2017
01/08/2018
02/08/2018
03/08/2018
it is giving error at below dates
12/28/2017, 01/08/2018
Can you please help me how to assert date filed with assertJ assertions ?
Also how to verify Descending order with assertJ assertions?
The text was updated successfully, but these errors were encountered: