use of org.orcid.jaxb.model.message.OrcidProfile in project ORCID-Source by ORCID.
the class RegistrationManagerImplTest method testCreateMinimalRegistrationWithExistingTwoEmailsAdditionalThatCanBeAutoDeprecated.
@Test
public void testCreateMinimalRegistrationWithExistingTwoEmailsAdditionalThatCanBeAutoDeprecated() {
// Create a user, but set it as unclaimed
String email = "new_user_" + System.currentTimeMillis() + "@test.orcid.org";
// Create a record by a member
OrcidProfile orcidProfile = createBasicProfile(email, false, CLIENT_ID_AUTODEPRECATE_ENABLED);
orcidProfile = orcidProfileManager.createOrcidProfile(orcidProfile, true, true);
assertNotNull(orcidProfile);
assertNotNull(orcidProfile.getOrcidIdentifier());
assertNotNull(orcidProfile.getOrcidIdentifier().getPath());
String orcidBefore = orcidProfile.getOrcidIdentifier().getPath();
Map<String, String> map1 = emailManager.findOricdIdsByCommaSeparatedEmails(email);
assertNotNull(map1);
assertEquals(orcidBefore, map1.get(email));
// Create another user, but set it as unclaimed
String email2 = "new_user2_" + System.currentTimeMillis() + "@test.orcid.org";
// Create another record by a member
OrcidProfile orcidProfile2 = createBasicProfile(email2, false, CLIENT_ID_AUTODEPRECATE_ENABLED);
orcidProfile2 = orcidProfileManager.createOrcidProfile(orcidProfile2, true, true);
assertNotNull(orcidProfile2);
assertNotNull(orcidProfile.getOrcidIdentifier());
assertNotNull(orcidProfile2.getOrcidIdentifier().getPath());
String orcidBefore2 = orcidProfile2.getOrcidIdentifier().getPath();
Map<String, String> map2 = emailManager.findOricdIdsByCommaSeparatedEmails(email2);
assertNotNull(map2);
assertEquals(orcidBefore2, map2.get(email2));
try {
String email3 = "new_user3_" + System.currentTimeMillis() + "@test.orcid.org";
List<Text> emailsAdditionalList = new ArrayList<Text>();
Text emailAdditional = new Text();
emailAdditional.setValue(email);
emailsAdditionalList.add(emailAdditional);
Text emailAdditional2 = new Text();
emailAdditional2.setValue(email2);
emailsAdditionalList.add(emailAdditional2);
Registration form = createRegistrationFormMultipleEmails(email3, emailsAdditionalList, true);
registrationManager.createMinimalRegistration(form, true, java.util.Locale.ENGLISH, "0.0.0.0");
fail();
} catch (InvalidRequestException e) {
assertEquals("Unable to register user due: More than 2 duplicate emails", e.getMessage());
} catch (Exception e) {
fail();
}
}
use of org.orcid.jaxb.model.message.OrcidProfile in project ORCID-Source by ORCID.
the class NotificationManagerTest method testSendVerificationEmail.
@Test
public void testSendVerificationEmail() throws JAXBException, IOException, URISyntaxException {
OrcidMessage orcidMessage = (OrcidMessage) unmarshaller.unmarshal(getClass().getResourceAsStream(ORCID_INTERNAL_FULL_XML));
OrcidProfile orcidProfile = orcidMessage.getOrcidProfile();
notificationManager.sendVerificationEmail(orcidProfile.getOrcidIdentifier().getPath(), orcidProfile.getOrcidBio().getContactDetails().retrievePrimaryEmail().getValue());
}
use of org.orcid.jaxb.model.message.OrcidProfile in project ORCID-Source by ORCID.
the class OrcidSearchManagerImplTest method recordDeactivatedTest.
@Test
public void recordDeactivatedTest() {
OrcidProfile orcidProfile = getOrcidProfileAllIndexFieldsPopulated();
orcidProfile.getOrcidIdentifier().setPath("0000");
when(mockSolrDao.findByDocumentCriteria("rndQuery", null, null)).thenReturn(invalidRecordSearchResult());
when(mockOrcidProfileCacheManager.retrievePublicBio("0000")).thenReturn(orcidProfile);
doThrow(new DeactivatedException()).when(mockOrcidSecurityManager).checkProfile("0000");
OrcidMessage retrievedOrcidMessage = orcidSearchManager.findOrcidsByQuery("rndQuery");
assertNotNull(retrievedOrcidMessage);
assertTrue(retrievedOrcidMessage.getOrcidSearchResults() != null && retrievedOrcidMessage.getOrcidSearchResults().getOrcidSearchResult().size() == 1);
OrcidSearchResult searchResult = retrievedOrcidMessage.getOrcidSearchResults().getOrcidSearchResult().get(0);
OrcidProfile profileReturnedFromSearch = searchResult.getOrcidProfile();
assertEquals("0000", profileReturnedFromSearch.getOrcidIdentifier().getPath());
assertNotNull(profileReturnedFromSearch.getOrcidHistory().getLastModifiedDate().getValue());
assertNull(profileReturnedFromSearch.getOrcidActivities());
assertNull(profileReturnedFromSearch.getOrcidBio());
}
use of org.orcid.jaxb.model.message.OrcidProfile in project ORCID-Source by ORCID.
the class OrcidSearchManagerImplTest method orcidRetrievalMandatoryFieldsOnly.
@Test
@Rollback
public void orcidRetrievalMandatoryFieldsOnly() {
when(mockSolrDao.findByOrcid("1434")).thenReturn(getOrcidSolrResult("5678", new Float(37.2)));
when(mockOrcidProfileCacheManager.retrievePublicBio("5678")).thenReturn(getOrcidProfile5678MandatoryOnly());
OrcidMessage retrievedOrcidMessage = orcidSearchManager.findOrcidSearchResultsById("1434");
assertNotNull(retrievedOrcidMessage);
assertTrue(retrievedOrcidMessage.getOrcidSearchResults().getOrcidSearchResult().size() == 1);
OrcidSearchResult result = retrievedOrcidMessage.getOrcidSearchResults().getOrcidSearchResult().get(0);
OrcidProfile retrievedProfile = result.getOrcidProfile();
assertEquals("5678", retrievedProfile.getOrcidIdentifier().getPath());
OrcidBio orcidBio = retrievedProfile.getOrcidBio();
assertEquals("Logan", orcidBio.getPersonalDetails().getFamilyName().getContent());
assertEquals("Donald Edward", orcidBio.getPersonalDetails().getGivenNames().getContent());
}
use of org.orcid.jaxb.model.message.OrcidProfile in project ORCID-Source by ORCID.
the class OrcidSearchManagerImplTest method orcidRetrievalAllDataPresentInDb.
@Test
@Rollback
public void orcidRetrievalAllDataPresentInDb() throws Exception {
when(mockSolrDao.findByOrcid("1434")).thenReturn(getOrcidSolrResult("5678", new Float(37.2)));
when(mockOrcidProfileCacheManager.retrievePublicBio("5678")).thenReturn(getOrcidProfileAllIndexFieldsPopulated());
String orcid = "1434";
// demonstrate that the mapping from solr (profile 1234) and dao (5678)
// are truly seperate - the search results only return a subset of the
// full orcid
// because we want to keep the payload down.
OrcidMessage retrievedOrcidMessage = orcidSearchManager.findOrcidSearchResultsById(orcid);
assertNotNull(retrievedOrcidMessage);
assertTrue(retrievedOrcidMessage.getOrcidSearchResults().getOrcidSearchResult().size() == 1);
OrcidSearchResult result = retrievedOrcidMessage.getOrcidSearchResults().getOrcidSearchResult().get(0);
assertTrue(new Float(37.2).compareTo(result.getRelevancyScore().getValue()) == 0);
OrcidProfile retrievedProfile = result.getOrcidProfile();
assertEquals("5678", retrievedProfile.getOrcidIdentifier().getPath());
OrcidBio orcidBio = retrievedProfile.getOrcidBio();
assertEquals("Logan", orcidBio.getPersonalDetails().getFamilyName().getContent());
assertEquals("Donald Edward", orcidBio.getPersonalDetails().getGivenNames().getContent());
assertEquals("Stanley Higgins", orcidBio.getPersonalDetails().getCreditName().getContent());
List<String> otherNames = orcidBio.getPersonalDetails().getOtherNames().getOtherNamesAsStrings();
assertTrue(otherNames.contains("Edward Bass"));
assertTrue(otherNames.contains("Gareth Dove"));
OrcidWorks orcidWorks = retrievedProfile.retrieveOrcidWorks();
OrcidWork orcidWork1 = orcidWorks.getOrcidWork().get(0);
OrcidWork orcidWork2 = orcidWorks.getOrcidWork().get(1);
assertTrue(orcidWork1.getWorkExternalIdentifiers().getWorkExternalIdentifier().size() == 1);
assertEquals("work1-doi1", orcidWork1.getWorkExternalIdentifiers().getWorkExternalIdentifier().get(0).getWorkExternalIdentifierId().getContent());
assertTrue(orcidWork2.getWorkExternalIdentifiers().getWorkExternalIdentifier().size() == 2);
assertEquals("work2-doi1", orcidWork2.getWorkExternalIdentifiers().getWorkExternalIdentifier().get(0).getWorkExternalIdentifierId().getContent());
assertEquals("work2-doi2", orcidWork2.getWorkExternalIdentifiers().getWorkExternalIdentifier().get(1).getWorkExternalIdentifierId().getContent());
List<Funding> fundings = retrievedProfile.retrieveFundings().getFundings();
Funding funding1 = fundings.get(0);
Funding funding2 = fundings.get(1);
// check returns a reduced payload
assertNotNull(funding1.getTitle());
assertNotNull(funding1.getTitle().getTitle());
assertEquals("grant1", funding1.getTitle().getTitle().getContent());
assertEquals("Grant 1 - a short description", funding1.getDescription());
assertNull(funding1.getPutCode());
assertNotNull(funding2.getTitle());
assertNotNull(funding2.getTitle().getTitle());
assertEquals("grant2", funding2.getTitle().getTitle().getContent());
assertEquals("Grant 2 - a short description", funding2.getDescription());
assertNull(funding2.getPutCode());
}
Aggregations