From 305779eae1183a4f8920dffdc39fb1603c516f8b Mon Sep 17 00:00:00 2001 From: Daniel Palafox Date: Wed, 5 Jun 2024 23:20:06 -0500 Subject: [PATCH 1/3] fix: Make validated items to be default preferred source for grouping --- .../java/org/orcid/core/manager/v3/impl/WorkManagerImpl.java | 5 ++++- .../test/java/org/orcid/core/manager/v3/WorkManagerTest.java | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/orcid-core/src/main/java/org/orcid/core/manager/v3/impl/WorkManagerImpl.java b/orcid-core/src/main/java/org/orcid/core/manager/v3/impl/WorkManagerImpl.java index cdb636c282f..cf22b5b8126 100644 --- a/orcid-core/src/main/java/org/orcid/core/manager/v3/impl/WorkManagerImpl.java +++ b/orcid-core/src/main/java/org/orcid/core/manager/v3/impl/WorkManagerImpl.java @@ -477,9 +477,12 @@ public void createNewWorkGroup(List 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; diff --git a/orcid-core/src/test/java/org/orcid/core/manager/v3/WorkManagerTest.java b/orcid-core/src/test/java/org/orcid/core/manager/v3/WorkManagerTest.java index 051de4368da..e964cccd114 100644 --- a/orcid-core/src/test/java/org/orcid/core/manager/v3/WorkManagerTest.java +++ b/orcid-core/src/test/java/org/orcid/core/manager/v3/WorkManagerTest.java @@ -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()); } @Test @@ -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"); From 1fcca3f5888c19f41c94ef27a3864d5aaafdf1ab Mon Sep 17 00:00:00 2001 From: Daniel Palafox Date: Thu, 6 Jun 2024 17:02:40 -0500 Subject: [PATCH 2/3] fix: Make elements added via API preferred sources --- .../java/org/orcid/core/cli/AnonymizeWorksFromCSV.java | 1 - .../orcid/core/utils/DisplayIndexCalculatorHelper.java | 4 ++-- .../java/org/orcid/core/manager/AddressManagerTest.java | 8 ++++---- .../orcid/core/manager/ExternalIdentifierManagerTest.java | 8 ++++---- .../java/org/orcid/core/manager/OtherNameManagerTest.java | 8 ++++---- .../org/orcid/core/manager/ProfileFundingManagerTest.java | 8 ++++---- .../org/orcid/core/manager/ProfileKeywordManagerTest.java | 8 ++++---- .../org/orcid/core/manager/ResearcherUrlManagerTest.java | 8 ++++---- .../test/java/org/orcid/core/manager/WorkManagerTest.java | 8 ++++---- .../org/orcid/core/manager/v3/AddressManagerTest.java | 8 ++++---- .../core/manager/v3/ExternalIdentifierManagerTest.java | 8 ++++---- .../org/orcid/core/manager/v3/OtherNameManagerTest.java | 8 ++++---- .../org/orcid/core/manager/v3/PeerReviewManagerTest.java | 8 ++++---- .../orcid/core/manager/v3/ProfileFundingManagerTest.java | 8 ++++---- .../orcid/core/manager/v3/ProfileKeywordManagerTest.java | 8 ++++---- .../orcid/core/manager/v3/ResearcherUrlManagerTest.java | 8 ++++---- .../java/org/orcid/core/manager/v3/WorkManagerTest.java | 6 +++--- 17 files changed, 61 insertions(+), 62 deletions(-) diff --git a/orcid-core/src/main/java/org/orcid/core/cli/AnonymizeWorksFromCSV.java b/orcid-core/src/main/java/org/orcid/core/cli/AnonymizeWorksFromCSV.java index 3eb89c73b3c..cbe22cf9599 100644 --- a/orcid-core/src/main/java/org/orcid/core/cli/AnonymizeWorksFromCSV.java +++ b/orcid-core/src/main/java/org/orcid/core/cli/AnonymizeWorksFromCSV.java @@ -18,7 +18,6 @@ import org.orcid.core.manager.ProfileEntityCacheManager; import org.orcid.core.togglz.OrcidTogglzConfiguration; -import org.orcid.core.utils.DisplayIndexCalculatorHelper; import org.orcid.core.utils.v3.ContributorUtils; import org.orcid.persistence.dao.WorkDao; import org.orcid.persistence.jpa.entities.WorkEntity; diff --git a/orcid-core/src/main/java/org/orcid/core/utils/DisplayIndexCalculatorHelper.java b/orcid-core/src/main/java/org/orcid/core/utils/DisplayIndexCalculatorHelper.java index 75e4a57ed1f..48f7405e9c4 100644 --- a/orcid-core/src/main/java/org/orcid/core/utils/DisplayIndexCalculatorHelper.java +++ b/orcid-core/src/main/java/org/orcid/core/utils/DisplayIndexCalculatorHelper.java @@ -20,9 +20,9 @@ public static void setDisplayIndexOnExistingEntity(DisplayIndexInterface entity, private static void setDisplayIndex(DisplayIndexInterface e, boolean isApiRequest) { if(isApiRequest) { - e.setDisplayIndex(0L); - } else { e.setDisplayIndex(1L); + } else { + e.setDisplayIndex(0L); } } } diff --git a/orcid-core/src/test/java/org/orcid/core/manager/AddressManagerTest.java b/orcid-core/src/test/java/org/orcid/core/manager/AddressManagerTest.java index 22234f24738..96d1540e5d5 100644 --- a/orcid-core/src/test/java/org/orcid/core/manager/AddressManagerTest.java +++ b/orcid-core/src/test/java/org/orcid/core/manager/AddressManagerTest.java @@ -96,7 +96,7 @@ public void testAddAddressToClaimedRecordPreserveUserDefaultVisibility() { } @Test - public void displayIndexIsSetTo_1_FromUI() { + public void displayIndexIsSetTo_0_FromUI() { when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID))); Address address = getAddress(Iso3166Country.MX); @@ -104,11 +104,11 @@ public void displayIndexIsSetTo_1_FromUI() { address = addressManager.getAddress(claimedOrcid, address.getPutCode()); assertNotNull(address); - assertEquals(Long.valueOf(1), address.getDisplayIndex()); + assertEquals(Long.valueOf(0), address.getDisplayIndex()); } @Test - public void displayIndexIsSetTo_0_FromAPI() { + public void displayIndexIsSetTo_1_FromAPI() { when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID))); Address address = getAddress(Iso3166Country.PE); @@ -116,7 +116,7 @@ public void displayIndexIsSetTo_0_FromAPI() { address = addressManager.getAddress(claimedOrcid, address.getPutCode()); assertNotNull(address); - assertEquals(Long.valueOf(0), address.getDisplayIndex()); + assertEquals(Long.valueOf(1), address.getDisplayIndex()); } @Test diff --git a/orcid-core/src/test/java/org/orcid/core/manager/ExternalIdentifierManagerTest.java b/orcid-core/src/test/java/org/orcid/core/manager/ExternalIdentifierManagerTest.java index 4df529e803e..c26af27e00a 100644 --- a/orcid-core/src/test/java/org/orcid/core/manager/ExternalIdentifierManagerTest.java +++ b/orcid-core/src/test/java/org/orcid/core/manager/ExternalIdentifierManagerTest.java @@ -133,7 +133,7 @@ public void testAddEqualsExternalIdentifiersFromSameSource() { } @Test - public void displayIndexIsSetTo_1_FromUI() { + public void displayIndexIsSetTo_0_FromUI() { when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID))); PersonExternalIdentifier extId = getExternalIdentifier(); extId.setType(extId.getType() + System.currentTimeMillis()); @@ -141,11 +141,11 @@ public void displayIndexIsSetTo_1_FromUI() { extId1 = externalIdentifierManager.getExternalIdentifier(claimedOrcid, extId1.getPutCode()); assertNotNull(extId1); - assertEquals(Long.valueOf(1), extId1.getDisplayIndex()); + assertEquals(Long.valueOf(0), extId1.getDisplayIndex()); } @Test - public void displayIndexIsSetTo_0_FromAPI() { + public void displayIndexIsSetTo_1_FromAPI() { when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID))); PersonExternalIdentifier extId = getExternalIdentifier(); extId.setType(extId.getType() + System.currentTimeMillis()); @@ -153,7 +153,7 @@ public void displayIndexIsSetTo_0_FromAPI() { extId1 = externalIdentifierManager.getExternalIdentifier(claimedOrcid, extId1.getPutCode()); assertNotNull(extId1); - assertEquals(Long.valueOf(0), extId1.getDisplayIndex()); + assertEquals(Long.valueOf(1), extId1.getDisplayIndex()); } @Test diff --git a/orcid-core/src/test/java/org/orcid/core/manager/OtherNameManagerTest.java b/orcid-core/src/test/java/org/orcid/core/manager/OtherNameManagerTest.java index e07739c0f14..02506cae64c 100644 --- a/orcid-core/src/test/java/org/orcid/core/manager/OtherNameManagerTest.java +++ b/orcid-core/src/test/java/org/orcid/core/manager/OtherNameManagerTest.java @@ -91,7 +91,7 @@ public void testAddOtherNameToClaimedRecordPreserveUserDefaultVisibility() { } @Test - public void displayIndexIsSetTo_1_FromUI() { + public void displayIndexIsSetTo_0_FromUI() { when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID))); OtherName otherName = getOtherName(); otherName.setContent(otherName.getContent() + " fromUI"); @@ -100,11 +100,11 @@ public void displayIndexIsSetTo_1_FromUI() { otherName = otherNameManager.getOtherName(claimedOrcid, otherName.getPutCode()); assertNotNull(otherName); - assertEquals(Long.valueOf(1), otherName.getDisplayIndex()); + assertEquals(Long.valueOf(0), otherName.getDisplayIndex()); } @Test - public void displayIndexIsSetTo_0_FromAPI() { + public void displayIndexIsSetTo_1_FromAPI() { when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID))); OtherName otherName = getOtherName(); otherName.setContent(otherName.getContent() + " fromAPI"); @@ -113,7 +113,7 @@ public void displayIndexIsSetTo_0_FromAPI() { otherName = otherNameManager.getOtherName(claimedOrcid, otherName.getPutCode()); assertNotNull(otherName); - assertEquals(Long.valueOf(0), otherName.getDisplayIndex()); + assertEquals(Long.valueOf(1), otherName.getDisplayIndex()); } @Test diff --git a/orcid-core/src/test/java/org/orcid/core/manager/ProfileFundingManagerTest.java b/orcid-core/src/test/java/org/orcid/core/manager/ProfileFundingManagerTest.java index 5a2f0036bc4..804afbd08b7 100644 --- a/orcid-core/src/test/java/org/orcid/core/manager/ProfileFundingManagerTest.java +++ b/orcid-core/src/test/java/org/orcid/core/manager/ProfileFundingManagerTest.java @@ -134,7 +134,7 @@ public void testAddMultipleModifiesIndexingStatus() { } @Test - public void displayIndexIsSetTo_1_FromUI() { + public void displayIndexIsSetTo_0_FromUI() { when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID))); Funding f1 = getFunding("fromUI-1"); @@ -142,11 +142,11 @@ public void displayIndexIsSetTo_1_FromUI() { ProfileFundingEntity f = profileFundingDao.find(f1.getPutCode()); assertNotNull(f); - assertEquals(Long.valueOf(1), f.getDisplayIndex()); + assertEquals(Long.valueOf(0), f.getDisplayIndex()); } @Test - public void displayIndexIsSetTo_0_FromAPI() { + public void displayIndexIsSetTo_1_FromAPI() { when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID))); Funding f1 = getFunding("fromAPI-1"); @@ -154,7 +154,7 @@ public void displayIndexIsSetTo_0_FromAPI() { ProfileFundingEntity f = profileFundingDao.find(f1.getPutCode()); assertNotNull(f); - assertEquals(Long.valueOf(0), f.getDisplayIndex()); + assertEquals(Long.valueOf(1), f.getDisplayIndex()); } @Test diff --git a/orcid-core/src/test/java/org/orcid/core/manager/ProfileKeywordManagerTest.java b/orcid-core/src/test/java/org/orcid/core/manager/ProfileKeywordManagerTest.java index 2c77a968b48..28dfdfeb027 100644 --- a/orcid-core/src/test/java/org/orcid/core/manager/ProfileKeywordManagerTest.java +++ b/orcid-core/src/test/java/org/orcid/core/manager/ProfileKeywordManagerTest.java @@ -86,7 +86,7 @@ public void testAddKeywordToClaimedRecordPreserveUserDefaultVisibility() { } @Test - public void displayIndexIsSetTo_1_FromUI() { + public void displayIndexIsSetTo_0_FromUI() { when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID))); Keyword keyword = getKeyword(); keyword.setContent(keyword.getContent() + " fromUI1"); @@ -95,11 +95,11 @@ public void displayIndexIsSetTo_1_FromUI() { keyword = profileKeywordManager.getKeyword(claimedOrcid, keyword.getPutCode()); assertNotNull(keyword); - assertEquals(Long.valueOf(1), keyword.getDisplayIndex()); + assertEquals(Long.valueOf(0), keyword.getDisplayIndex()); } @Test - public void displayIndexIsSetTo_0_FromAPI() { + public void displayIndexIsSetTo_1_FromAPI() { when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID))); Keyword keyword = getKeyword(); keyword.setContent(keyword.getContent() + " fromAPI1"); @@ -108,7 +108,7 @@ public void displayIndexIsSetTo_0_FromAPI() { keyword = profileKeywordManager.getKeyword(claimedOrcid, keyword.getPutCode()); assertNotNull(keyword); - assertEquals(Long.valueOf(0), keyword.getDisplayIndex()); + assertEquals(Long.valueOf(1), keyword.getDisplayIndex()); } @Test diff --git a/orcid-core/src/test/java/org/orcid/core/manager/ResearcherUrlManagerTest.java b/orcid-core/src/test/java/org/orcid/core/manager/ResearcherUrlManagerTest.java index 3ab864011d4..4b9d9bf0738 100644 --- a/orcid-core/src/test/java/org/orcid/core/manager/ResearcherUrlManagerTest.java +++ b/orcid-core/src/test/java/org/orcid/core/manager/ResearcherUrlManagerTest.java @@ -87,7 +87,7 @@ public void testAddResearcherUrToClaimedRecordPreserveUserDefaultVisibility() { } @Test - public void displayIndexIsSetTo_1_FromUI() { + public void displayIndexIsSetTo_0_FromUI() { when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID))); ResearcherUrl rUrl = getResearcherUrl(); rUrl.getUrl().setValue(rUrl.getUrl().getValue() + "/fromUI"); @@ -96,11 +96,11 @@ public void displayIndexIsSetTo_1_FromUI() { rUrl = researcherUrlManager.getResearcherUrl(claimedOrcid, rUrl.getPutCode()); assertNotNull(rUrl); - assertEquals(Long.valueOf(1), rUrl.getDisplayIndex()); + assertEquals(Long.valueOf(0), rUrl.getDisplayIndex()); } @Test - public void displayIndexIsSetTo_0_FromAPI() { + public void displayIndexIsSetTo_1_FromAPI() { when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID))); ResearcherUrl rUrl = getResearcherUrl(); rUrl.getUrl().setValue(rUrl.getUrl().getValue() + "/fromAPI"); @@ -109,7 +109,7 @@ public void displayIndexIsSetTo_0_FromAPI() { rUrl = researcherUrlManager.getResearcherUrl(claimedOrcid, rUrl.getPutCode()); assertNotNull(rUrl); - assertEquals(Long.valueOf(0), rUrl.getDisplayIndex()); + assertEquals(Long.valueOf(1), rUrl.getDisplayIndex()); } @Test diff --git a/orcid-core/src/test/java/org/orcid/core/manager/WorkManagerTest.java b/orcid-core/src/test/java/org/orcid/core/manager/WorkManagerTest.java index 9242c477939..cee49648226 100644 --- a/orcid-core/src/test/java/org/orcid/core/manager/WorkManagerTest.java +++ b/orcid-core/src/test/java/org/orcid/core/manager/WorkManagerTest.java @@ -221,23 +221,23 @@ public void testAddMultipleModifiesIndexingStatus() { } @Test - public void displayIndexIsSetTo_1_FromUI() { + public void displayIndexIsSetTo_0_FromUI() { Work w1 = getWork("fromUI-1"); w1 = workManager.createWork(claimedOrcid, w1, false); WorkEntity w = workDao.find(w1.getPutCode()); assertNotNull(w1); - assertEquals(Long.valueOf(1), w.getDisplayIndex()); + assertEquals(Long.valueOf(0), w.getDisplayIndex()); } @Test - public void displayIndexIsSetTo_0_FromAPI() { + public void displayIndexIsSetTo_1_FromAPI() { Work w1 = getWork("fromAPI-1"); w1 = workManager.createWork(claimedOrcid, w1, true); WorkEntity w = workDao.find(w1.getPutCode()); assertNotNull(w1); - assertEquals(Long.valueOf(0), w.getDisplayIndex()); + assertEquals(Long.valueOf(1), w.getDisplayIndex()); } @Test diff --git a/orcid-core/src/test/java/org/orcid/core/manager/v3/AddressManagerTest.java b/orcid-core/src/test/java/org/orcid/core/manager/v3/AddressManagerTest.java index 8cf38522403..acaa5d6a0ad 100644 --- a/orcid-core/src/test/java/org/orcid/core/manager/v3/AddressManagerTest.java +++ b/orcid-core/src/test/java/org/orcid/core/manager/v3/AddressManagerTest.java @@ -169,7 +169,7 @@ public void testAddAddressToClaimedRecordPreserveUserDefaultVisibility() { } @Test - public void displayIndexIsSetTo_1_FromUI() { + public void displayIndexIsSetTo_0_FromUI() { when(mockSourceManager.retrieveActiveSource()).thenReturn(Source.forClient(CLIENT_1_ID)); Address address = getAddress(Iso3166Country.MX); @@ -177,11 +177,11 @@ public void displayIndexIsSetTo_1_FromUI() { address = addressManager.getAddress(claimedOrcid, address.getPutCode()); assertNotNull(address); - assertEquals(Long.valueOf(1), address.getDisplayIndex()); + assertEquals(Long.valueOf(0), address.getDisplayIndex()); } @Test - public void displayIndexIsSetTo_0_FromAPI() { + public void displayIndexIsSetTo_1_FromAPI() { when(mockSourceManager.retrieveActiveSource()).thenReturn(Source.forClient(CLIENT_1_ID)); Address address = getAddress(Iso3166Country.PE); @@ -189,7 +189,7 @@ public void displayIndexIsSetTo_0_FromAPI() { address = addressManager.getAddress(claimedOrcid, address.getPutCode()); assertNotNull(address); - assertEquals(Long.valueOf(0), address.getDisplayIndex()); + assertEquals(Long.valueOf(1), address.getDisplayIndex()); } @Test diff --git a/orcid-core/src/test/java/org/orcid/core/manager/v3/ExternalIdentifierManagerTest.java b/orcid-core/src/test/java/org/orcid/core/manager/v3/ExternalIdentifierManagerTest.java index d4e41ffcba4..c61cfb149a0 100644 --- a/orcid-core/src/test/java/org/orcid/core/manager/v3/ExternalIdentifierManagerTest.java +++ b/orcid-core/src/test/java/org/orcid/core/manager/v3/ExternalIdentifierManagerTest.java @@ -148,7 +148,7 @@ public void testAddEqualsExternalIdentifiersFromSameSource() { } @Test - public void displayIndexIsSetTo_1_FromUI() { + public void displayIndexIsSetTo_0_FromUI() { when(mockSourceManager.retrieveActiveSource()).thenReturn(Source.forClient(CLIENT_1_ID)); PersonExternalIdentifier extId = getExternalIdentifier(); extId.setType(extId.getType() + System.currentTimeMillis()); @@ -156,11 +156,11 @@ public void displayIndexIsSetTo_1_FromUI() { extId1 = externalIdentifierManager.getExternalIdentifier(claimedOrcid, extId1.getPutCode()); assertNotNull(extId1); - assertEquals(Long.valueOf(1), extId1.getDisplayIndex()); + assertEquals(Long.valueOf(0), extId1.getDisplayIndex()); } @Test - public void displayIndexIsSetTo_0_FromAPI() { + public void displayIndexIsSetTo_1_FromAPI() { when(mockSourceManager.retrieveActiveSource()).thenReturn(Source.forClient(CLIENT_1_ID)); PersonExternalIdentifier extId = getExternalIdentifier(); extId.setType(extId.getType() + System.currentTimeMillis()); @@ -168,7 +168,7 @@ public void displayIndexIsSetTo_0_FromAPI() { extId1 = externalIdentifierManager.getExternalIdentifier(claimedOrcid, extId1.getPutCode()); assertNotNull(extId1); - assertEquals(Long.valueOf(0), extId1.getDisplayIndex()); + assertEquals(Long.valueOf(1), extId1.getDisplayIndex()); } @Test diff --git a/orcid-core/src/test/java/org/orcid/core/manager/v3/OtherNameManagerTest.java b/orcid-core/src/test/java/org/orcid/core/manager/v3/OtherNameManagerTest.java index 179f453595d..1ea7602439d 100644 --- a/orcid-core/src/test/java/org/orcid/core/manager/v3/OtherNameManagerTest.java +++ b/orcid-core/src/test/java/org/orcid/core/manager/v3/OtherNameManagerTest.java @@ -150,7 +150,7 @@ public void testAddOtherNameToClaimedRecordPreserveUserDefaultVisibility() { } @Test - public void displayIndexIsSetTo_1_FromUI() { + public void displayIndexIsSetTo_0_FromUI() { when(mockSourceManager.retrieveActiveSource()).thenReturn(Source.forClient(CLIENT_1_ID)); OtherName otherName = getOtherName(); otherName.setContent(otherName.getContent() + " fromUI"); @@ -159,11 +159,11 @@ public void displayIndexIsSetTo_1_FromUI() { otherName = otherNameManager.getOtherName(claimedOrcid, otherName.getPutCode()); assertNotNull(otherName); - assertEquals(Long.valueOf(1), otherName.getDisplayIndex()); + assertEquals(Long.valueOf(0), otherName.getDisplayIndex()); } @Test - public void displayIndexIsSetTo_0_FromAPI() { + public void displayIndexIsSetTo_1_FromAPI() { when(mockSourceManager.retrieveActiveSource()).thenReturn(Source.forClient(CLIENT_1_ID)); OtherName otherName = getOtherName(); otherName.setContent(otherName.getContent() + " fromAPI"); @@ -172,7 +172,7 @@ public void displayIndexIsSetTo_0_FromAPI() { otherName = otherNameManager.getOtherName(claimedOrcid, otherName.getPutCode()); assertNotNull(otherName); - assertEquals(Long.valueOf(0), otherName.getDisplayIndex()); + assertEquals(Long.valueOf(1), otherName.getDisplayIndex()); } @Test diff --git a/orcid-core/src/test/java/org/orcid/core/manager/v3/PeerReviewManagerTest.java b/orcid-core/src/test/java/org/orcid/core/manager/v3/PeerReviewManagerTest.java index c5b32b32521..888070b58bc 100644 --- a/orcid-core/src/test/java/org/orcid/core/manager/v3/PeerReviewManagerTest.java +++ b/orcid-core/src/test/java/org/orcid/core/manager/v3/PeerReviewManagerTest.java @@ -201,25 +201,25 @@ public void testAddMultipleModifiesIndexingStatus() { } @Test - public void displayIndexIsSetTo_1_FromUI() { + public void displayIndexIsSetTo_0_FromUI() { when(mockSourceManager.retrieveActiveSource()).thenReturn(Source.forClient(CLIENT_1_ID)); PeerReview p1 = getPeerReview("fromUI-1"); p1 = peerReviewManager.createPeerReview(claimedOrcid, p1, false); PeerReviewEntity p = peerReviewDao.find(p1.getPutCode()); assertNotNull(p); - assertEquals(Long.valueOf(1), p.getDisplayIndex()); + assertEquals(Long.valueOf(0), p.getDisplayIndex()); } @Test - public void displayIndexIsSetTo_0_FromAPI() { + public void displayIndexIsSetTo_1_FromAPI() { when(mockSourceManager.retrieveActiveSource()).thenReturn(Source.forClient(CLIENT_1_ID)); PeerReview p1 = getPeerReview("fromAPI-1"); p1 = peerReviewManager.createPeerReview(claimedOrcid, p1, true); PeerReviewEntity p = peerReviewDao.find(p1.getPutCode()); assertNotNull(91); - assertEquals(Long.valueOf(0), p.getDisplayIndex()); + assertEquals(Long.valueOf(1), p.getDisplayIndex()); } @Test diff --git a/orcid-core/src/test/java/org/orcid/core/manager/v3/ProfileFundingManagerTest.java b/orcid-core/src/test/java/org/orcid/core/manager/v3/ProfileFundingManagerTest.java index 4f72b89b02b..75d463427ef 100644 --- a/orcid-core/src/test/java/org/orcid/core/manager/v3/ProfileFundingManagerTest.java +++ b/orcid-core/src/test/java/org/orcid/core/manager/v3/ProfileFundingManagerTest.java @@ -190,7 +190,7 @@ public void testAddMultipleModifiesIndexingStatus() { } @Test - public void displayIndexIsSetTo_1_FromUI() { + public void displayIndexIsSetTo_0_FromUI() { when(mockSourceManager.retrieveActiveSource()).thenReturn(Source.forClient(CLIENT_1_ID)); Funding f1 = getFunding("fromUI-1"); @@ -198,11 +198,11 @@ public void displayIndexIsSetTo_1_FromUI() { ProfileFundingEntity f = profileFundingDao.find(f1.getPutCode()); assertNotNull(f); - assertEquals(Long.valueOf(1), f.getDisplayIndex()); + assertEquals(Long.valueOf(0), f.getDisplayIndex()); } @Test - public void displayIndexIsSetTo_0_FromAPI() { + public void displayIndexIsSetTo_1_FromAPI() { when(mockSourceManager.retrieveActiveSource()).thenReturn(Source.forClient(CLIENT_1_ID)); Funding f1 = getFunding("fromAPI-1"); @@ -210,7 +210,7 @@ public void displayIndexIsSetTo_0_FromAPI() { ProfileFundingEntity f = profileFundingDao.find(f1.getPutCode()); assertNotNull(f); - assertEquals(Long.valueOf(0), f.getDisplayIndex()); + assertEquals(Long.valueOf(1), f.getDisplayIndex()); } @Test diff --git a/orcid-core/src/test/java/org/orcid/core/manager/v3/ProfileKeywordManagerTest.java b/orcid-core/src/test/java/org/orcid/core/manager/v3/ProfileKeywordManagerTest.java index 8490f14bdf7..d540160eeb8 100644 --- a/orcid-core/src/test/java/org/orcid/core/manager/v3/ProfileKeywordManagerTest.java +++ b/orcid-core/src/test/java/org/orcid/core/manager/v3/ProfileKeywordManagerTest.java @@ -126,7 +126,7 @@ public void testAddKeywordToClaimedRecordPreserveUserDefaultVisibility() { } @Test - public void displayIndexIsSetTo_1_FromUI() { + public void displayIndexIsSetTo_0_FromUI() { when(mockSourceManager.retrieveActiveSource()).thenReturn(Source.forClient(CLIENT_1_ID)); Keyword keyword = getKeyword(); keyword.setContent(keyword.getContent() + " fromUI1"); @@ -135,11 +135,11 @@ public void displayIndexIsSetTo_1_FromUI() { keyword = profileKeywordManager.getKeyword(claimedOrcid, keyword.getPutCode()); assertNotNull(keyword); - assertEquals(Long.valueOf(1), keyword.getDisplayIndex()); + assertEquals(Long.valueOf(0), keyword.getDisplayIndex()); } @Test - public void displayIndexIsSetTo_0_FromAPI() { + public void displayIndexIsSetTo_1_FromAPI() { when(mockSourceManager.retrieveActiveSource()).thenReturn(Source.forClient(CLIENT_1_ID)); Keyword keyword = getKeyword(); keyword.setContent(keyword.getContent() + " fromAPI1"); @@ -148,7 +148,7 @@ public void displayIndexIsSetTo_0_FromAPI() { keyword = profileKeywordManager.getKeyword(claimedOrcid, keyword.getPutCode()); assertNotNull(keyword); - assertEquals(Long.valueOf(0), keyword.getDisplayIndex()); + assertEquals(Long.valueOf(1), keyword.getDisplayIndex()); } @Test diff --git a/orcid-core/src/test/java/org/orcid/core/manager/v3/ResearcherUrlManagerTest.java b/orcid-core/src/test/java/org/orcid/core/manager/v3/ResearcherUrlManagerTest.java index 3345da68de3..63e9be3c9e9 100644 --- a/orcid-core/src/test/java/org/orcid/core/manager/v3/ResearcherUrlManagerTest.java +++ b/orcid-core/src/test/java/org/orcid/core/manager/v3/ResearcherUrlManagerTest.java @@ -159,7 +159,7 @@ public void testAddResearcherUrToClaimedRecordPreserveUserDefaultVisibility() { } @Test - public void displayIndexIsSetTo_1_FromUI() { + public void displayIndexIsSetTo_0_FromUI() { when(mockSourceManager.retrieveActiveSource()).thenReturn(Source.forClient(CLIENT_1_ID)); ResearcherUrl rUrl = getResearcherUrl(); rUrl.getUrl().setValue(rUrl.getUrl().getValue() + "/fromUI"); @@ -168,11 +168,11 @@ public void displayIndexIsSetTo_1_FromUI() { rUrl = researcherUrlManager.getResearcherUrl(claimedOrcid, rUrl.getPutCode()); assertNotNull(rUrl); - assertEquals(Long.valueOf(1), rUrl.getDisplayIndex()); + assertEquals(Long.valueOf(0), rUrl.getDisplayIndex()); } @Test - public void displayIndexIsSetTo_0_FromAPI() { + public void displayIndexIsSetTo_1_FromAPI() { when(mockSourceManager.retrieveActiveSource()).thenReturn(Source.forClient(CLIENT_1_ID)); ResearcherUrl rUrl = getResearcherUrl(); rUrl.getUrl().setValue(rUrl.getUrl().getValue() + "/fromAPI"); @@ -181,7 +181,7 @@ public void displayIndexIsSetTo_0_FromAPI() { rUrl = researcherUrlManager.getResearcherUrl(claimedOrcid, rUrl.getPutCode()); assertNotNull(rUrl); - assertEquals(Long.valueOf(0), rUrl.getDisplayIndex()); + assertEquals(Long.valueOf(1), rUrl.getDisplayIndex()); } @Test diff --git a/orcid-core/src/test/java/org/orcid/core/manager/v3/WorkManagerTest.java b/orcid-core/src/test/java/org/orcid/core/manager/v3/WorkManagerTest.java index e964cccd114..6cf5447d90c 100644 --- a/orcid-core/src/test/java/org/orcid/core/manager/v3/WorkManagerTest.java +++ b/orcid-core/src/test/java/org/orcid/core/manager/v3/WorkManagerTest.java @@ -214,7 +214,7 @@ public void testAddWorkToClaimedRecordPreserveUserDefaultVisibility() { } @Test - public void displayIndexIsSetTo_1_FromUI() { + public void displayIndexIsSetTo_0_FromUI() { Work w1 = getWork("fromUI-1"); w1 = workManager.createWork(claimedOrcid, w1, false); WorkEntity w = workDao.find(w1.getPutCode()); @@ -224,13 +224,13 @@ public void displayIndexIsSetTo_1_FromUI() { } @Test - public void displayIndexIsSetTo_0_FromAPI() { + public void displayIndexIsSetTo_1_FromAPI() { Work w1 = getWork("fromAPI-1"); w1 = workManager.createWork(claimedOrcid, w1, true); WorkEntity w = workDao.find(w1.getPutCode()); assertNotNull(w1); - assertEquals(Long.valueOf(0), w.getDisplayIndex()); + assertEquals(Long.valueOf(1), w.getDisplayIndex()); } @Test From 59cf916afc8152388da42fe8a44dda59c79ea9fd Mon Sep 17 00:00:00 2001 From: Daniel Palafox Date: Thu, 6 Jun 2024 18:15:13 -0500 Subject: [PATCH 3/3] test: Fix add multiple items modify indexing status tests --- .../org/orcid/core/manager/PeerReviewManagerTest.java | 10 +++++----- .../orcid/core/manager/ProfileFundingManagerTest.java | 2 +- .../java/org/orcid/core/manager/WorkManagerTest.java | 2 +- .../orcid/core/manager/v3/PeerReviewManagerTest.java | 2 +- .../core/manager/v3/ProfileFundingManagerTest.java | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/orcid-core/src/test/java/org/orcid/core/manager/PeerReviewManagerTest.java b/orcid-core/src/test/java/org/orcid/core/manager/PeerReviewManagerTest.java index 033e6cee63d..adb8b4c3592 100644 --- a/orcid-core/src/test/java/org/orcid/core/manager/PeerReviewManagerTest.java +++ b/orcid-core/src/test/java/org/orcid/core/manager/PeerReviewManagerTest.java @@ -137,7 +137,7 @@ public void testAddMultipleModifiesIndexingStatus() { assertNotNull(entity1.getDisplayIndex()); assertNotNull(entity2.getDisplayIndex()); assertNotNull(entity3.getDisplayIndex()); - assertEquals(Long.valueOf(0), entity3.getDisplayIndex()); + assertEquals(Long.valueOf(1), entity3.getDisplayIndex()); // Rollback all changes peerReviewDao.remove(entity1.getId()); @@ -146,25 +146,25 @@ public void testAddMultipleModifiesIndexingStatus() { } @Test - public void displayIndexIsSetTo_1_FromUI() { + public void displayIndexIsSetTo_0_FromUI() { when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID))); PeerReview p1 = getPeerReview("fromUI-1"); p1 = peerReviewManager.createPeerReview(claimedOrcid, p1, false); PeerReviewEntity p = peerReviewDao.find(p1.getPutCode()); assertNotNull(p); - assertEquals(Long.valueOf(1), p.getDisplayIndex()); + assertEquals(Long.valueOf(0), p.getDisplayIndex()); } @Test - public void displayIndexIsSetTo_0_FromAPI() { + public void displayIndexIsSetTo_1_FromAPI() { when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID))); PeerReview p1 = getPeerReview("fromAPI-1"); p1 = peerReviewManager.createPeerReview(claimedOrcid, p1, true); PeerReviewEntity p = peerReviewDao.find(p1.getPutCode()); assertNotNull(91); - assertEquals(Long.valueOf(0), p.getDisplayIndex()); + assertEquals(Long.valueOf(1), p.getDisplayIndex()); } @Test diff --git a/orcid-core/src/test/java/org/orcid/core/manager/ProfileFundingManagerTest.java b/orcid-core/src/test/java/org/orcid/core/manager/ProfileFundingManagerTest.java index 804afbd08b7..13650551506 100644 --- a/orcid-core/src/test/java/org/orcid/core/manager/ProfileFundingManagerTest.java +++ b/orcid-core/src/test/java/org/orcid/core/manager/ProfileFundingManagerTest.java @@ -125,7 +125,7 @@ public void testAddMultipleModifiesIndexingStatus() { assertNotNull(entity1.getDisplayIndex()); assertNotNull(entity2.getDisplayIndex()); assertNotNull(entity3.getDisplayIndex()); - assertEquals(Long.valueOf(0), entity3.getDisplayIndex()); + assertEquals(Long.valueOf(1), entity3.getDisplayIndex()); // Rollback all changes profileFundingDao.remove(entity1.getId()); diff --git a/orcid-core/src/test/java/org/orcid/core/manager/WorkManagerTest.java b/orcid-core/src/test/java/org/orcid/core/manager/WorkManagerTest.java index cee49648226..99ab4226e39 100644 --- a/orcid-core/src/test/java/org/orcid/core/manager/WorkManagerTest.java +++ b/orcid-core/src/test/java/org/orcid/core/manager/WorkManagerTest.java @@ -212,7 +212,7 @@ public void testAddMultipleModifiesIndexingStatus() { assertNotNull(entity1.getDisplayIndex()); assertNotNull(entity2.getDisplayIndex()); assertNotNull(entity3.getDisplayIndex()); - assertEquals(Long.valueOf(0), entity3.getDisplayIndex()); + assertEquals(Long.valueOf(1), entity3.getDisplayIndex()); // Rollback all changes workDao.remove(entity1.getId()); diff --git a/orcid-core/src/test/java/org/orcid/core/manager/v3/PeerReviewManagerTest.java b/orcid-core/src/test/java/org/orcid/core/manager/v3/PeerReviewManagerTest.java index 888070b58bc..45055260732 100644 --- a/orcid-core/src/test/java/org/orcid/core/manager/v3/PeerReviewManagerTest.java +++ b/orcid-core/src/test/java/org/orcid/core/manager/v3/PeerReviewManagerTest.java @@ -192,7 +192,7 @@ public void testAddMultipleModifiesIndexingStatus() { assertNotNull(entity1.getDisplayIndex()); assertNotNull(entity2.getDisplayIndex()); assertNotNull(entity3.getDisplayIndex()); - assertEquals(Long.valueOf(0), entity3.getDisplayIndex()); + assertEquals(Long.valueOf(1), entity3.getDisplayIndex()); //Rollback all changes peerReviewDao.remove(entity1.getId()); diff --git a/orcid-core/src/test/java/org/orcid/core/manager/v3/ProfileFundingManagerTest.java b/orcid-core/src/test/java/org/orcid/core/manager/v3/ProfileFundingManagerTest.java index 75d463427ef..27da969c320 100644 --- a/orcid-core/src/test/java/org/orcid/core/manager/v3/ProfileFundingManagerTest.java +++ b/orcid-core/src/test/java/org/orcid/core/manager/v3/ProfileFundingManagerTest.java @@ -181,7 +181,7 @@ public void testAddMultipleModifiesIndexingStatus() { assertNotNull(entity1.getDisplayIndex()); assertNotNull(entity2.getDisplayIndex()); assertNotNull(entity3.getDisplayIndex()); - assertEquals(Long.valueOf(0), entity3.getDisplayIndex()); + assertEquals(Long.valueOf(1), entity3.getDisplayIndex()); //Rollback all changes profileFundingDao.remove(entity1.getId());