diff --git a/orcid-core/src/main/java/org/orcid/core/utils/v3/activities/FundingComparators.java b/orcid-core/src/main/java/org/orcid/core/utils/v3/activities/FundingComparators.java index 857461b6e12..ae0864cd3ab 100644 --- a/orcid-core/src/main/java/org/orcid/core/utils/v3/activities/FundingComparators.java +++ b/orcid-core/src/main/java/org/orcid/core/utils/v3/activities/FundingComparators.java @@ -18,16 +18,8 @@ public class FundingComparators { private final String TYPE_SORT_KEY = "type"; - private final String SOURCE_SORT_KEY = "source"; - - private String orcid = null; - public FundingComparators() {} - public FundingComparators(String orcid) { - this.orcid = orcid; - } - public Comparator getInstance(String key, boolean sortAsc, String orcid) { Comparator comparator = null; if (DATE_SORT_KEY.equals(key)) { @@ -120,7 +112,7 @@ public List sortBySource(List fundingGroups, boolean selfAsserted.sort(new FundingComparators().TITLE_COMPARATOR); validated.sort(new FundingComparators().TITLE_COMPARATOR); - return (sortAsc ? Stream.concat(selfAsserted.stream(), validated.stream()) : Stream.concat(validated.stream(), selfAsserted.stream())) + return (sortAsc ? Stream.concat(validated.stream(), selfAsserted.stream()) : Stream.concat(selfAsserted.stream(), validated.stream())) .collect(Collectors.toList()); } } diff --git a/orcid-web/src/main/java/org/orcid/frontend/web/pagination/WorksPaginator.java b/orcid-web/src/main/java/org/orcid/frontend/web/pagination/WorksPaginator.java index 58931afd1a3..9553e641f11 100644 --- a/orcid-web/src/main/java/org/orcid/frontend/web/pagination/WorksPaginator.java +++ b/orcid-web/src/main/java/org/orcid/frontend/web/pagination/WorksPaginator.java @@ -475,8 +475,7 @@ public List sortBySour selfAsserted.sort(new TitleComparator()); validated.sort(new TitleComparator()); - return sortAsc ? Stream.concat(selfAsserted.stream(), validated.stream()) - .collect(Collectors.toList()) : Stream.concat(validated.stream(), selfAsserted.stream()) + return (sortAsc ? Stream.concat(validated.stream(), selfAsserted.stream()) : Stream.concat(selfAsserted.stream(), validated.stream())) .collect(Collectors.toList()); } @@ -492,7 +491,7 @@ public List sortBySourceExtended(List work selfAsserted.sort(new TitleComparatorWorkGroupExtended()); validated.sort(new TitleComparatorWorkGroupExtended()); - return (sortAsc ? Stream.concat(selfAsserted.stream(), validated.stream()) : Stream.concat(validated.stream(), selfAsserted.stream())) + return (sortAsc ? Stream.concat(validated.stream(), selfAsserted.stream()) : Stream.concat(selfAsserted.stream(), validated.stream())) .collect(Collectors.toList()); } diff --git a/orcid-web/src/test/java/org/orcid/frontend/web/controllers/FundingsControllerTest.java b/orcid-web/src/test/java/org/orcid/frontend/web/controllers/FundingsControllerTest.java index da8c571d045..711dd988f02 100644 --- a/orcid-web/src/test/java/org/orcid/frontend/web/controllers/FundingsControllerTest.java +++ b/orcid-web/src/test/java/org/orcid/frontend/web/controllers/FundingsControllerTest.java @@ -646,8 +646,8 @@ public void testGetFundingsJsonSortedBySource() { List fundings = fundingController.getFundingsJson("source", true); assertNotNull(fundings); assertEquals(3, fundings.size()); - assertEquals("4444-4444-4444-4443", fundings.get(0).getFundings().get(0).getSource()); - assertEquals("4444-4444-4444-4441", fundings.get(2).getFundings().get(0).getSource()); + assertEquals("4444-4444-4444-4441", fundings.get(0).getFundings().get(0).getSource()); + assertEquals("4444-4444-4444-4443", fundings.get(2).getFundings().get(0).getSource()); } private FundingForm getFundingForm() { diff --git a/orcid-web/src/test/java/org/orcid/frontend/web/pagination/WorksPaginatorTest.java b/orcid-web/src/test/java/org/orcid/frontend/web/pagination/WorksPaginatorTest.java index 2a10808f122..b9ca7dce213 100644 --- a/orcid-web/src/test/java/org/orcid/frontend/web/pagination/WorksPaginatorTest.java +++ b/orcid-web/src/test/java/org/orcid/frontend/web/pagination/WorksPaginatorTest.java @@ -181,8 +181,8 @@ public void testSourceSort() { Mockito.when(worksCacheManager.getGroupedWorks(Mockito.anyString())).thenReturn(works); Page page = worksPaginator.getWorksPage("orcid", 0, pageSize, false, WorksPaginator.SOURCE_SORT_KEY, false); - assertEquals("APP-5555-5555-5555-5555", page.getGroups().get(0).getWorks().get(0).getSource()); - assertEquals("orcid", page.getGroups().get(49).getWorks().get(0).getSource()); + assertEquals("orcid", page.getGroups().get(0).getWorks().get(0).getSource()); + assertEquals("APP-5555-5555-5555-5555", page.getGroups().get(49).getWorks().get(0).getSource()); } @Test @@ -218,8 +218,8 @@ public void testTitleSortCase() { Mockito.when(worksCacheManager.getGroupedWorks(Mockito.anyString())).thenReturn(works); Page page = worksPaginator.getWorksPage("orcid", 0, pageSize, false, WorksPaginator.SOURCE_SORT_KEY, false); - assertEquals("APP-5555-5555-5555-5555", page.getGroups().get(0).getWorks().get(0).getSource()); - assertEquals("orcid", page.getGroups().get(49).getWorks().get(0).getSource()); + assertEquals("orcid", page.getGroups().get(0).getWorks().get(0).getSource()); + assertEquals("APP-5555-5555-5555-5555", page.getGroups().get(49).getWorks().get(0).getSource()); } @Test