Skip to content

Commit

Permalink
[DSC-1589] Fixes ResearcherProfileRestRepositoryIT
Browse files Browse the repository at this point in the history
  • Loading branch information
vins01-4science committed Mar 27, 2024
1 parent 61516a7 commit 0c63c29
Showing 1 changed file with 39 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2246,14 +2246,14 @@ public void testOrcidSynchronizationPreferenceUpdateForceOrcidQueueRecalculation
context.turnOffAuthorisationSystem();

EPerson ePerson = EPersonBuilder.createEPerson(context)
.withCanLogin(true)
.withOrcid("0000-1111-2222-3333")
.withOrcidScope("/read")
.withOrcidScope("/write")
.withEmail("[email protected]")
.withPassword(password)
.withNameInMetadata("Test", "User")
.build();
.withCanLogin(true)
.withOrcid("0000-1111-2222-3333")
.withOrcidScope("/read")
.withOrcidScope("/write")
.withEmail("[email protected]")
.withPassword(password)
.withNameInMetadata("Test", "User")
.build();

OrcidTokenBuilder.create(context, ePerson, "3de2e370-8aa9-4bbe-8d7e-f5b1577bdad4").build();

Expand Down Expand Up @@ -2289,18 +2289,18 @@ public void testOrcidSynchronizationPreferenceUpdateForceOrcidQueueRecalculation
String authToken = getAuthToken(ePerson.getEmail(), password);

getClient(authToken).perform(patch("/api/eperson/profiles/{id}", ePersonId.toString())
.content(getPatchContent(asList(new ReplaceOperation("/orcid/publications", "ALL"))))
.contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isOk());
.content(getPatchContent(asList(new ReplaceOperation("/orcid/publications", "ALL"))))
.contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isOk());

List<OrcidQueue> queueRecords = orcidQueueService.findByProfileItemId(context, profileItemId);
assertThat(queueRecords, hasSize(1));
assertThat(queueRecords, has(orcidQueueRecordWithEntity(publication)));

getClient(authToken).perform(patch("/api/eperson/profiles/{id}", ePersonId.toString())
.content(getPatchContent(asList(new ReplaceOperation("/orcid/fundings", "ALL"))))
.contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isOk());
.content(getPatchContent(asList(new ReplaceOperation("/orcid/fundings", "ALL"))))
.contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isOk());

queueRecords = orcidQueueService.findByProfileItemId(context, profileItemId);
assertThat(queueRecords, hasSize(3));
Expand All @@ -2309,21 +2309,9 @@ public void testOrcidSynchronizationPreferenceUpdateForceOrcidQueueRecalculation
assertThat(queueRecords, has(orcidQueueRecordWithEntity(secondFunding)));

getClient(authToken).perform(patch("/api/eperson/profiles/{id}", ePersonId.toString())
.content(getPatchContent(asList(new ReplaceOperation("/orcid/products", "ALL"))))
.contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isOk());

queueRecords = orcidQueueService.findByProfileItemId(context, profileItemId);
assertThat(queueRecords, hasSize(4));
assertThat(queueRecords, has(orcidQueueRecordWithEntity(publication)));
assertThat(queueRecords, has(orcidQueueRecordWithEntity(firstFunding)));
assertThat(queueRecords, has(orcidQueueRecordWithEntity(secondFunding)));
assertThat(queueRecords, has(orcidQueueRecordWithEntity(product)));

getClient(authToken).perform(patch("/api/eperson/profiles/{id}", ePersonId.toString())
.content(getPatchContent(asList(new ReplaceOperation("/orcid/products", "ALL"))))
.contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isOk());
.content(getPatchContent(asList(new ReplaceOperation("/orcid/products", "ALL"))))
.contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isOk());

queueRecords = orcidQueueService.findByProfileItemId(context, profileItemId);
assertThat(queueRecords, hasSize(4));
Expand All @@ -2333,9 +2321,9 @@ public void testOrcidSynchronizationPreferenceUpdateForceOrcidQueueRecalculation
assertThat(queueRecords, has(orcidQueueRecordWithEntity(product)));

getClient(authToken).perform(patch("/api/eperson/profiles/{id}", ePersonId.toString())
.content(getPatchContent(asList(new ReplaceOperation("/orcid/patents", "ALL"))))
.contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isOk());
.content(getPatchContent(asList(new ReplaceOperation("/orcid/patents", "ALL"))))
.contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isOk());

queueRecords = orcidQueueService.findByProfileItemId(context, profileItemId);
assertThat(queueRecords, hasSize(6));
Expand All @@ -2347,9 +2335,9 @@ public void testOrcidSynchronizationPreferenceUpdateForceOrcidQueueRecalculation
assertThat(queueRecords, has(orcidQueueRecordWithEntity(secondPatent)));

getClient(authToken).perform(patch("/api/eperson/profiles/{id}", ePersonId.toString())
.content(getPatchContent(asList(new ReplaceOperation("/orcid/publications", "DISABLED"))))
.contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isOk());
.content(getPatchContent(asList(new ReplaceOperation("/orcid/publications", "DISABLED"))))
.contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isOk());

queueRecords = orcidQueueService.findByProfileItemId(context, profileItemId);
assertThat(queueRecords, hasSize(5));
Expand All @@ -2360,18 +2348,9 @@ public void testOrcidSynchronizationPreferenceUpdateForceOrcidQueueRecalculation
assertThat(queueRecords, has(orcidQueueRecordWithEntity(secondPatent)));

getClient(authToken).perform(patch("/api/eperson/profiles/{id}", ePersonId.toString())
.content(getPatchContent(asList(new ReplaceOperation("/orcid/fundings", "DISABLED"))))
.contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isOk());

queueRecords = orcidQueueService.findByProfileItemId(context, profileItemId);
assertThat(queueRecords, hasSize(1));
assertThat(queueRecords, has(orcidQueueRecordWithEntity(product)));

getClient(authToken).perform(patch("/api/eperson/profiles/{id}", ePersonId.toString())
.content(getPatchContent(asList(new ReplaceOperation("/orcid/products", "DISABLED"))))
.contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isOk());
.content(getPatchContent(asList(new ReplaceOperation("/orcid/fundings", "DISABLED"))))
.contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isOk());

queueRecords = orcidQueueService.findByProfileItemId(context, profileItemId);
assertThat(queueRecords, hasSize(3));
Expand All @@ -2380,45 +2359,46 @@ public void testOrcidSynchronizationPreferenceUpdateForceOrcidQueueRecalculation
assertThat(queueRecords, has(orcidQueueRecordWithEntity(secondPatent)));

getClient(authToken).perform(patch("/api/eperson/profiles/{id}", ePersonId.toString())
.content(getPatchContent(asList(new ReplaceOperation("/orcid/products", "DISABLED"))))
.contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isOk());
.content(getPatchContent(asList(new ReplaceOperation("/orcid/products", "DISABLED"))))
.contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isOk());

queueRecords = orcidQueueService.findByProfileItemId(context, profileItemId);
assertThat(queueRecords, hasSize(2));
assertThat(queueRecords, has(orcidQueueRecordWithEntity(firstPatent)));
assertThat(queueRecords, has(orcidQueueRecordWithEntity(secondPatent)));

getClient(authToken).perform(patch("/api/eperson/profiles/{id}", ePersonId.toString())
.content(getPatchContent(asList(new ReplaceOperation("/orcid/patents", "DISABLED"))))
.contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isOk());
.content(getPatchContent(asList(new ReplaceOperation("/orcid/patents", "DISABLED"))))
.contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isOk());

assertThat(orcidQueueService.findByProfileItemId(context, profileItemId), empty());

configurationService.setProperty("orcid.linkable-metadata-fields.ignore", "crisfund.coinvestigators");

getClient(authToken).perform(patch("/api/eperson/profiles/{id}", ePersonId.toString())
.content(getPatchContent(asList(new ReplaceOperation("/orcid/fundings", "ALL"))))
.contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isOk());
.content(getPatchContent(asList(new ReplaceOperation("/orcid/fundings", "ALL"))))
.contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isOk());

queueRecords = orcidQueueService.findByProfileItemId(context, profileItemId);
assertThat(queueRecords, hasSize(1));
assertThat(queueRecords, has(orcidQueueRecordWithEntity(firstFunding)));

// verify that no ORCID queue recalculation is done if the preference does not change
getClient(authToken).perform(patch("/api/eperson/profiles/{id}", ePersonId.toString())
.content(getPatchContent(asList(new ReplaceOperation("/orcid/fundings", "ALL"))))
.contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isOk());
.content(getPatchContent(asList(new ReplaceOperation("/orcid/fundings", "ALL"))))
.contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isOk());

List<OrcidQueue> newRecords = orcidQueueService.findByProfileItemId(context, profileItemId);
assertThat(newRecords, hasSize(1));
assertThat(queueRecords.get(0).getID(), is(newRecords.get(0).getID()));

}


@Test
public void researcherProfileClaim() throws Exception {
String id = user.getID().toString();
Expand Down

0 comments on commit 0c63c29

Please sign in to comment.