use of org.orcid.jaxb.model.v3.dev1.search.Search in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_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));
MemberV3ApiServiceDelegatorImpl delegator = new MemberV3ApiServiceDelegatorImpl();
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.v3.dev1.search.Search in project ORCID-Source by ORCID.
the class PublicV3ApiServiceDelegatorTest method testSearchByQueryLegalStart.
@Test
public void testSearchByQueryLegalStart() {
Map<String, List<String>> params = new HashMap<>();
params.put("start", Arrays.asList(Integer.toString(OrcidSearchManager.MAX_SEARCH_START)));
LocaleManager localeManager = Mockito.mock(LocaleManagerImpl.class);
Mockito.when(localeManager.resolveMessage(Mockito.anyString())).thenReturn("a message");
OrcidSearchManager orcidSearchManager = Mockito.mock(OrcidSearchManagerImpl.class);
Mockito.when(orcidSearchManager.findOrcidIds(Mockito.anyMap())).thenReturn(new Search());
OrcidSecurityManager orcidSecurityManager = Mockito.mock(OrcidSecurityManagerImpl.class);
Mockito.when(orcidSecurityManager.getClientIdFromAPIRequest()).thenReturn(null);
PublicV3ApiServiceDelegatorImpl delegator = new PublicV3ApiServiceDelegatorImpl();
ReflectionTestUtils.setField(delegator, "localeManager", localeManager);
ReflectionTestUtils.setField(delegator, "orcidSearchManager", orcidSearchManager);
ReflectionTestUtils.setField(delegator, "orcidSecurityManager", orcidSecurityManager);
Response response = delegator.searchByQuery(params);
assertNotNull(response);
}
use of org.orcid.jaxb.model.v3.dev1.search.Search in project ORCID-Source by ORCID.
the class PublicV3ApiServiceDelegatorImpl method searchByQuery.
@Override
public Response searchByQuery(Map<String, List<String>> solrParams) {
validateSearchParams(solrParams);
Search search = orcidSearchManager.findOrcidIds(solrParams);
return Response.ok(search).build();
}
use of org.orcid.jaxb.model.v3.dev1.search.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.v3.dev1.search.Search in project ORCID-Source by ORCID.
the class PublicV3ApiServiceDelegatorTest 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);
PublicV3ApiServiceDelegatorImpl delegator = new PublicV3ApiServiceDelegatorImpl();
ReflectionTestUtils.setField(delegator, "orcidSearchManager", orcidSearchManager);
OrcidSecurityManager orcidSecurityManager = Mockito.mock(OrcidSecurityManagerImpl.class);
Mockito.when(orcidSecurityManager.getClientIdFromAPIRequest()).thenReturn(null);
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());
}
Aggregations