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());
}
}
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();
}
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());
}
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());
}
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());
}
Aggregations