Skip to content

Commit

Permalink
fix: Make validated items to be default preferred source for grouping
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Palafox committed Jun 6, 2024
1 parent 78fddb9 commit 305779e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,12 @@ public void createNewWorkGroup(List<Long> workIds, String orcid) throws MissingG
MinimizedWorkEntity userPreferred = null;

boolean groupableExternalIdFound = false;
for (MinimizedWorkEntity work : works) {
for (MinimizedWorkEntity work : works) {
if (orcid.equals(work.getSourceId())) {
userVersions.add(work);
work.setDisplayIndex(0L);
} else {
work.setDisplayIndex(1L);
}
if (userPreferred == null || userPreferred.getDisplayIndex() < work.getDisplayIndex()) {
userPreferred = work;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public void displayIndexIsSetTo_1_FromUI() {
WorkEntity w = workDao.find(w1.getPutCode());

assertNotNull(w1);
assertEquals(Long.valueOf(1), w.getDisplayIndex());
assertEquals(Long.valueOf(0), w.getDisplayIndex());

Check failure on line 223 in orcid-core/src/test/java/org/orcid/core/manager/v3/WorkManagerTest.java

View workflow job for this annotation

GitHub Actions / orcid-core Unit Tests

org.orcid.core.manager.v3.WorkManagerTest ► displayIndexIsSetTo_1_FromUI

Failed test found in: TEST-org.orcid.core.manager.v3.WorkManagerTest.xml Error: java.lang.AssertionError: expected:<0> but was:<1>
Raw output
java.lang.AssertionError: expected:<0> but was:<1>
	at org.orcid.core.manager.v3.WorkManagerTest.displayIndexIsSetTo_1_FromUI(WorkManagerTest.java:223)
}

@Test
Expand Down Expand Up @@ -1435,7 +1435,7 @@ public void testCreateNewWorkGroup() throws MissingGroupableExternalIDException,

// full work matching user preferred id should be loaded from db (10 is
// highest display index)
Mockito.when(mockDao.find(Mockito.eq(4l))).thenReturn(getUserPreferredWork());
Mockito.when(mockDao.find(Mockito.eq(1l))).thenReturn(getUserPreferredWork());

workManager.createNewWorkGroup(Arrays.asList(1l, 2l, 3l, 4l), "some-orcid");

Expand Down

0 comments on commit 305779e

Please sign in to comment.