Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Invert selfAsserted and validated in sort by source #6916

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<FundingGroup> getInstance(String key, boolean sortAsc, String orcid) {
Comparator<FundingGroup> comparator = null;
if (DATE_SORT_KEY.equals(key)) {
Expand Down Expand Up @@ -120,7 +112,7 @@ public List<FundingGroup> sortBySource(List<FundingGroup> 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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,7 @@ public List<org.orcid.jaxb.model.v3.release.record.summary.WorkGroup> 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());
}

Expand All @@ -492,7 +491,7 @@ public List<WorkGroupExtended> sortBySourceExtended(List<WorkGroupExtended> 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());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,8 +646,8 @@ public void testGetFundingsJsonSortedBySource() {
List<FundingGroup> 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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ public void testSourceSort() {
Mockito.when(worksCacheManager.getGroupedWorks(Mockito.anyString())).thenReturn(works);
Page<org.orcid.pojo.grouping.WorkGroup> 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
Expand Down Expand Up @@ -218,8 +218,8 @@ public void testTitleSortCase() {
Mockito.when(worksCacheManager.getGroupedWorks(Mockito.anyString())).thenReturn(works);
Page<org.orcid.pojo.grouping.WorkGroup> 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
Expand Down