Search in sources :

Example 91 with OrcidProfile

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();
    }
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Registration(org.orcid.pojo.ajaxForm.Registration) ArrayList(java.util.ArrayList) Text(org.orcid.pojo.ajaxForm.Text) InvalidRequestException(org.springframework.security.oauth2.common.exceptions.InvalidRequestException) InvalidRequestException(org.springframework.security.oauth2.common.exceptions.InvalidRequestException) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 92 with OrcidProfile

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());
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 93 with OrcidProfile

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());
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidSearchResult(org.orcid.jaxb.model.message.OrcidSearchResult) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) DeactivatedException(org.orcid.core.exception.DeactivatedException) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 94 with OrcidProfile

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());
}
Also used : OrcidSearchResult(org.orcid.jaxb.model.message.OrcidSearchResult) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest) Rollback(org.springframework.test.annotation.Rollback)

Example 95 with OrcidProfile

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());
}
Also used : OrcidSearchResult(org.orcid.jaxb.model.message.OrcidSearchResult) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) Funding(org.orcid.jaxb.model.message.Funding) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest) Rollback(org.springframework.test.annotation.Rollback)

Aggregations

OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)241 Test (org.junit.Test)118 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)77 Transactional (org.springframework.transaction.annotation.Transactional)50 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)45 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)43 DBUnitTest (org.orcid.test.DBUnitTest)43 Rollback (org.springframework.test.annotation.Rollback)40 OrcidWorks (org.orcid.jaxb.model.message.OrcidWorks)36 OrcidActivities (org.orcid.jaxb.model.message.OrcidActivities)35 Date (java.util.Date)27 PersonalDetails (org.orcid.jaxb.model.message.PersonalDetails)27 OrcidIdentifier (org.orcid.jaxb.model.message.OrcidIdentifier)25 WorkExternalIdentifier (org.orcid.jaxb.model.message.WorkExternalIdentifier)23 Affiliations (org.orcid.jaxb.model.message.Affiliations)22 FundingTitle (org.orcid.jaxb.model.message.FundingTitle)22 Title (org.orcid.jaxb.model.message.Title)22 Email (org.orcid.jaxb.model.message.Email)21 GivenNames (org.orcid.jaxb.model.message.GivenNames)21 OrcidHistory (org.orcid.jaxb.model.message.OrcidHistory)21