Search in sources :

Example 1 with OrcidSearchResult

use of org.orcid.jaxb.model.message.OrcidSearchResult in project ORCID-Source by ORCID.

the class VisibilityFilterImplTest method testOrcidMessageWithNullOrcidProfile.

@Test
public void testOrcidMessageWithNullOrcidProfile() throws JAXBException {
    OrcidMessage orcidMessage = getOrcidMessage("/orcid-search-result-message.xml");
    OrcidMessage filteredMessage = visibilityFilter.filter(orcidMessage, Visibility.PUBLIC);
    assertNotNull(filteredMessage);
    assertNull(filteredMessage.getOrcidProfile());
    assertEquals(2, filteredMessage.getOrcidSearchResults().getNumFound());
    for (int i = 0; i < filteredMessage.getOrcidSearchResults().getNumFound(); i++) {
        OrcidSearchResult searchResult = filteredMessage.getOrcidSearchResults().getOrcidSearchResult().get(i);
        OrcidBio orcidBio = searchResult.getOrcidProfile().getOrcidBio();
        // check private emails stripped out
        assertEquals(1, orcidBio.getContactDetails().getEmail().size());
    }
}
Also used : OrcidSearchResult(org.orcid.jaxb.model.message.OrcidSearchResult) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) Test(org.junit.Test)

Example 2 with OrcidSearchResult

use of org.orcid.jaxb.model.message.OrcidSearchResult in project ORCID-Source by ORCID.

the class T1OrcidApiServiceImplLatestMetricsTest method orcidWithMultipleResults.

private Response orcidWithMultipleResults() {
    OrcidMessage orcidMessage = new OrcidMessage();
    OrcidProfile orcidProfile1 = new OrcidProfile();
    OrcidProfile orcidProfile2 = new OrcidProfile();
    OrcidProfile orcidProfile3 = new OrcidProfile();
    OrcidSearchResult orcidSearchResult1 = new OrcidSearchResult();
    OrcidSearchResult orcidSearchResult2 = new OrcidSearchResult();
    OrcidSearchResult orcidSearchResult3 = new OrcidSearchResult();
    orcidSearchResult1.setOrcidProfile(orcidProfile1);
    orcidSearchResult2.setOrcidProfile(orcidProfile2);
    orcidSearchResult3.setOrcidProfile(orcidProfile3);
    List<OrcidSearchResult> searchResults = new ArrayList<OrcidSearchResult>();
    searchResults.add(orcidSearchResult1);
    searchResults.add(orcidSearchResult2);
    searchResults.add(orcidSearchResult3);
    OrcidSearchResults orcidSearchResults = new OrcidSearchResults();
    orcidSearchResults.getOrcidSearchResult().addAll(searchResults);
    orcidMessage.setOrcidSearchResults(orcidSearchResults);
    return Response.ok(orcidMessage).build();
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidSearchResult(org.orcid.jaxb.model.message.OrcidSearchResult) OrcidSearchResults(org.orcid.jaxb.model.message.OrcidSearchResults) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) ArrayList(java.util.ArrayList)

Example 3 with OrcidSearchResult

use of org.orcid.jaxb.model.message.OrcidSearchResult 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 4 with OrcidSearchResult

use of org.orcid.jaxb.model.message.OrcidSearchResult 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 5 with OrcidSearchResult

use of org.orcid.jaxb.model.message.OrcidSearchResult 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

OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)26 OrcidSearchResult (org.orcid.jaxb.model.message.OrcidSearchResult)26 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)19 Test (org.junit.Test)15 BaseTest (org.orcid.core.BaseTest)14 OrcidSearchResults (org.orcid.jaxb.model.message.OrcidSearchResults)8 OrcidSolrResult (org.orcid.utils.solr.entities.OrcidSolrResult)8 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)7 Rollback (org.springframework.test.annotation.Rollback)6 ArrayList (java.util.ArrayList)5 DeactivatedException (org.orcid.core.exception.DeactivatedException)4 OrcidDeprecatedException (org.orcid.core.exception.OrcidDeprecatedException)4 LockedException (org.orcid.core.security.aop.LockedException)4 Funding (org.orcid.jaxb.model.message.Funding)4 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)4 OrcidWorks (org.orcid.jaxb.model.message.OrcidWorks)4 OrcidSolrResults (org.orcid.utils.solr.entities.OrcidSolrResults)4 BufferedReader (java.io.BufferedReader)2 IOException (java.io.IOException)2 Reader (java.io.Reader)2