I have list returning with Name and Value, I am interested in creating a Junit test by checking whether the return list is alphabetized or not. So far i have done this but i get result always = TRUE as i believe it’s taking “MINTS…… ” into consideration. So my goal would be to remove MINTS ( Name ) from the list and check the list ( VALUE ) for order.
list from table

Junit code
public void test() throws Exception
{
DataObj dao = new DataObj();
HashMap<String, Object> params = new HashMap<String, Object>();
params.put( "code", 100 );
List<?> values = dao.getDataObj( params, conn );
String previous = "";
boolean result = false;
for ( final Object vCurrent : values )
{
String current = vCurrent.toString();
if ( current.compareTo( previous ) < 0 )
{
result = false;
previous = current;
}
result = true;
}
}
if i do a print on values i would get something like ” mints Dave mints Jackie mints Derek…..”
If this is supposed to be a JUnit test, then you should be using the JUnit “assertXxxx” methods to do the low-level tests; e.g. something like this
This entirely removes the need to produce a “result”.