mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-08 02:24:18 +00:00
Merge pull request #8212 from tdonohue/fix_8211
Fix GoogleBitstreamComparator to return 0 when equal
This commit is contained in:
@@ -86,8 +86,10 @@ public class GoogleBitstreamComparator implements Comparator<Bitstream> {
|
|||||||
if (priority1 > priority2) {
|
if (priority1 > priority2) {
|
||||||
return 1;
|
return 1;
|
||||||
} else if (priority1 == priority2) {
|
} else if (priority1 == priority2) {
|
||||||
if (b1.getSizeBytes() <= b2.getSizeBytes()) {
|
if (b1.getSizeBytes() < b2.getSizeBytes()) {
|
||||||
return 1;
|
return 1;
|
||||||
|
} else if (b1.getSizeBytes() == b2.getSizeBytes()) {
|
||||||
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@@ -164,6 +164,12 @@ public class GoogleBitstreamComparatorTest extends AbstractUnitTest {
|
|||||||
toSort.get(1).getName());
|
toSort.get(1).getName());
|
||||||
assertEquals("Bitstreams have same size and type, so order should remain unchanged", "bitstream3",
|
assertEquals("Bitstreams have same size and type, so order should remain unchanged", "bitstream3",
|
||||||
toSort.get(2).getName());
|
toSort.get(2).getName());
|
||||||
|
|
||||||
|
// Also, verify all bitstreams are considered equal (comparison returns 0)
|
||||||
|
GoogleBitstreamComparator comparator = new GoogleBitstreamComparator(context, settings);
|
||||||
|
assertEquals(0, comparator.compare(bitstream1, bitstream2));
|
||||||
|
assertEquals(0, comparator.compare(bitstream2, bitstream3));
|
||||||
|
assertEquals(0, comparator.compare(bitstream3, bitstream1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user