mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 15:03:18 +00:00
DS-3406: Resolve review feedback
This commit is contained in:
@@ -226,7 +226,7 @@ public class Item extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the collections this item is in. The order is indeterminate.
|
||||
* Get the collections this item is in. The order is sorted ascending by collection name.
|
||||
*
|
||||
* @return the collections this item is in, if any.
|
||||
*/
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
package org.dspace.content.comparator;
|
||||
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
|
||||
import java.util.Comparator;
|
||||
@@ -23,7 +23,9 @@ public class NameAscendingComparator implements Comparator<DSpaceObject>{
|
||||
}else if (dso2 == null){
|
||||
return 1;
|
||||
}else {
|
||||
return ObjectUtils.compare(dso1.getName(),dso2.getName());
|
||||
String name1 = StringUtils.trimToEmpty(dso1.getName());
|
||||
String name2 = StringUtils.trimToEmpty(dso2.getName());
|
||||
return name1.compareToIgnoreCase(name2);
|
||||
}
|
||||
}
|
||||
}
|
@@ -61,7 +61,7 @@ public class NameAscendingComparatorTest {
|
||||
|
||||
@Test
|
||||
public void testCompareSecondNull() throws Exception {
|
||||
when(dso2.getName()).thenReturn("b");
|
||||
when(dso1.getName()).thenReturn("a");
|
||||
|
||||
assertTrue(comparator.compare(dso1, null) > 0);
|
||||
}
|
||||
@@ -78,4 +78,20 @@ public class NameAscendingComparatorTest {
|
||||
|
||||
assertTrue(comparator.compare(dso1, dso2) < 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompareCaseInsensitive() throws Exception {
|
||||
when(dso1.getName()).thenReturn("a");
|
||||
when(dso2.getName()).thenReturn("B");
|
||||
|
||||
assertTrue(comparator.compare(dso1, dso2) < 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompareCaseTrimmed() throws Exception {
|
||||
when(dso1.getName()).thenReturn("a");
|
||||
when(dso2.getName()).thenReturn(" b ");
|
||||
|
||||
assertTrue(comparator.compare(dso1, dso2) < 0);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user