Search in sources :

Example 21 with OrcidSearchResult

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

the class OrcidSearchManagerImplTest method oneOrcidInDbOtherMissing.

@Test
@Rollback
public void oneOrcidInDbOtherMissing() {
    when(mockSolrDao.findByDocumentCriteria("rndQuery", null, null)).thenReturn(multipleResultsForQuery());
    when(mockOrcidProfileCacheManager.retrievePublicBio("5678")).thenReturn(getOrcidProfile5678MandatoryOnly());
    when(mockOrcidProfileCacheManager.retrievePublicBio("6789")).thenReturn(null);
    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("5678", profileReturnedFromSearch.getOrcidIdentifier().getPath());
}
Also used : OrcidSearchResult(org.orcid.jaxb.model.message.OrcidSearchResult) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest) Rollback(org.springframework.test.annotation.Rollback)

Example 22 with OrcidSearchResult

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

the class OrcidSearchManagerImplTest method recordLockedTest.

@Test
public void recordLockedTest() {
    OrcidProfile orcidProfile = getOrcidProfileAllIndexFieldsPopulated();
    orcidProfile.getOrcidIdentifier().setPath("0000");
    when(mockSolrDao.findByDocumentCriteria("rndQuery", null, null)).thenReturn(invalidRecordSearchResult());
    when(mockOrcidProfileCacheManager.retrievePublicBio("0000")).thenReturn(orcidProfile);
    doThrow(new LockedException()).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) LockedException(org.orcid.core.security.aop.LockedException) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 23 with OrcidSearchResult

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

the class OrcidSearchManagerImpl method findOrcidsByQuery.

@Override
public OrcidMessage findOrcidsByQuery(String query, Integer start, Integer rows) {
    OrcidMessage orcidMessage = new OrcidMessage();
    OrcidSearchResults searchResults = new OrcidSearchResults();
    OrcidSolrResults orcidSolrResults = solrDao.findByDocumentCriteria(query, start, rows);
    searchResults.setNumFound(orcidSolrResults.getNumFound());
    List<OrcidSolrResult> indexedOrcids = orcidSolrResults.getResults();
    if (indexedOrcids != null && !indexedOrcids.isEmpty()) {
        List<OrcidSearchResult> orcidSearchResults = buildSearchResultsFromPublicProfile(indexedOrcids);
        searchResults.getOrcidSearchResult().addAll(orcidSearchResults);
    }
    orcidMessage.setOrcidSearchResults(searchResults);
    return orcidMessage;
}
Also used : OrcidSearchResult(org.orcid.jaxb.model.message.OrcidSearchResult) OrcidSolrResult(org.orcid.utils.solr.entities.OrcidSolrResult) OrcidSearchResults(org.orcid.jaxb.model.message.OrcidSearchResults) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrcidSolrResults(org.orcid.utils.solr.entities.OrcidSolrResults)

Example 24 with OrcidSearchResult

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

the class OrcidSearchManagerImplTest method recordLockedTest.

@Test
public void recordLockedTest() {
    OrcidProfile orcidProfile = getOrcidProfileAllIndexFieldsPopulated();
    orcidProfile.getOrcidIdentifier().setPath("0000");
    when(mockSolrDao.findByDocumentCriteria("rndQuery", null, null)).thenReturn(invalidRecordSearchResult());
    when(mockOrcidProfileCacheManager.retrievePublicBio("0000")).thenReturn(orcidProfile);
    doThrow(new LockedException()).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) LockedException(org.orcid.core.security.aop.LockedException) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 25 with OrcidSearchResult

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

the class OrcidSearchManagerImplTest method recordDeprecatedTest.

@Test
public void recordDeprecatedTest() {
    OrcidProfile orcidProfile = getOrcidProfileAllIndexFieldsPopulated();
    orcidProfile.getOrcidIdentifier().setPath("0000");
    when(mockSolrDao.findByDocumentCriteria("rndQuery", null, null)).thenReturn(invalidRecordSearchResult());
    when(mockOrcidProfileCacheManager.retrievePublicBio("0000")).thenReturn(orcidProfile);
    doThrow(new OrcidDeprecatedException()).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) OrcidDeprecatedException(org.orcid.core.exception.OrcidDeprecatedException) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

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