use of org.orcid.jaxb.model.search_v2.Search in project ORCID-Source by ORCID.
the class OrcidSearchManagerImpl method findOrcidIds.
@Override
public Search findOrcidIds(Map<String, List<String>> queryParameters) {
Search search = new Search();
OrcidSolrResults orcidSolrResults = solrDao.findByDocumentCriteria(queryParameters);
if (orcidSolrResults != null && orcidSolrResults.getResults() != null) {
List<Result> orcidIdList = orcidSolrResults.getResults().stream().map(r -> {
Result result = new Result();
result.setOrcidIdentifier(recordManagerReadOnly.getOrcidIdentifier(r.getOrcid()));
return result;
}).collect(Collectors.toList());
search.getResults().addAll(orcidIdList);
search.setNumFound(orcidSolrResults.getNumFound());
} else {
search.setNumFound(0L);
}
return search;
}
use of org.orcid.jaxb.model.search_v2.Search in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_GeneralTest method testSearchByQuery.
@Test
public void testSearchByQuery() {
Search search = new Search();
Result result = new Result();
result.setOrcidIdentifier(new OrcidIdentifier("some-orcid-id"));
search.getResults().add(result);
OrcidSearchManager orcidSearchManager = Mockito.mock(OrcidSearchManagerImpl.class);
Mockito.when(orcidSearchManager.findOrcidIds(Matchers.<Map<String, List<String>>>any())).thenReturn(search);
OrcidSecurityManager orcidSecurityManager = Mockito.mock(OrcidSecurityManagerImpl.class);
Mockito.doNothing().when(orcidSecurityManager).checkScopes(Mockito.any(ScopePathType.class));
MemberV2ApiServiceDelegatorImpl delegator = new MemberV2ApiServiceDelegatorImpl();
ReflectionTestUtils.setField(delegator, "orcidSearchManager", orcidSearchManager);
ReflectionTestUtils.setField(delegator, "orcidSecurityManager", orcidSecurityManager);
Response response = delegator.searchByQuery(new HashMap<String, List<String>>());
assertNotNull(response);
assertNotNull(response.getEntity());
assertTrue(response.getEntity() instanceof Search);
assertEquals(1, ((Search) response.getEntity()).getResults().size());
assertEquals("some-orcid-id", ((Search) response.getEntity()).getResults().get(0).getOrcidIdentifier().getPath());
}
use of org.orcid.jaxb.model.search_v2.Search in project ORCID-Source by ORCID.
the class OrcidSearchManagerImplTest method testFindOrcidIds.
@Test
public void testFindOrcidIds() {
when(solrDao.findByDocumentCriteria(Matchers.<Map<String, List<String>>>any())).thenReturn(multipleResultsForQuery());
Search search = orcidSearchManager.findOrcidIds(new HashMap<>());
assertNotNull(search);
assertEquals(2, search.getResults().size());
assertEquals(Long.valueOf(2), search.getNumFound());
assertEquals("5678", search.getResults().get(0).getOrcidIdentifier().getPath());
assertEquals("6789", search.getResults().get(1).getOrcidIdentifier().getPath());
}
use of org.orcid.jaxb.model.search_v2.Search in project ORCID-Source by ORCID.
the class OrcidSearchManagerImplTest method testFindOrcidIdsNoResults.
@Test
public void testFindOrcidIdsNoResults() {
when(solrDao.findByDocumentCriteria(Matchers.<Map<String, List<String>>>any())).thenReturn(new OrcidSolrResults());
Search search = orcidSearchManager.findOrcidIds(new HashMap<>());
assertNotNull(search);
assertEquals(Long.valueOf(0), search.getNumFound());
assertEquals(0, search.getResults().size());
}
use of org.orcid.jaxb.model.search_v2.Search in project ORCID-Source by ORCID.
the class PublicV2ApiServiceVersionedDelegatorTest method testSearchByQuery.
@Test
public void testSearchByQuery() {
Search search = new Search();
Result result = new Result();
result.setOrcidIdentifier(new OrcidIdentifier("some-orcid-id"));
search.getResults().add(result);
Response searchResponse = Response.ok(search).build();
PublicV2ApiServiceDelegatorImpl delegator = Mockito.mock(PublicV2ApiServiceDelegatorImpl.class);
Mockito.when(delegator.searchByQuery(Matchers.<Map<String, List<String>>>any())).thenReturn(searchResponse);
PublicV2ApiServiceVersionedDelegatorImpl versionedDelegator = new PublicV2ApiServiceVersionedDelegatorImpl();
versionedDelegator.setMemberV2ApiServiceDelegator(delegator);
Response response = versionedDelegator.searchByQuery(new HashMap<String, List<String>>());
// just testing MemberV2ApiServiceDelegatorImpl's response is returned
assertNotNull(response);
assertNotNull(response.getEntity());
assertTrue(response.getEntity() instanceof Search);
assertEquals(1, ((Search) response.getEntity()).getResults().size());
assertEquals("some-orcid-id", ((Search) response.getEntity()).getResults().get(0).getOrcidIdentifier().getPath());
}
Aggregations