use of org.orcid.api.publicV2.server.delegator.impl.PublicV2ApiServiceDelegatorImpl in project ORCID-Source by ORCID.
the class PublicV2ApiServiceDelegatorTest method testSearchByQueryTooManyRows.
@Test(expected = OrcidBadRequestException.class)
public void testSearchByQueryTooManyRows() {
Map<String, List<String>> params = new HashMap<>();
params.put("rows", Arrays.asList(Integer.toString(OrcidSearchManager.MAX_SEARCH_ROWS + 20)));
LocaleManager localeManager = Mockito.mock(LocaleManagerImpl.class);
Mockito.when(localeManager.resolveMessage(Mockito.anyString())).thenReturn("a message");
PublicV2ApiServiceDelegatorImpl delegator = new PublicV2ApiServiceDelegatorImpl();
ReflectionTestUtils.setField(delegator, "localeManager", localeManager);
delegator.searchByQuery(params);
}
use of org.orcid.api.publicV2.server.delegator.impl.PublicV2ApiServiceDelegatorImpl in project ORCID-Source by ORCID.
the class PublicV2ApiServiceDelegatorTest 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);
PublicV2ApiServiceDelegatorImpl delegator = new PublicV2ApiServiceDelegatorImpl();
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());
}
use of org.orcid.api.publicV2.server.delegator.impl.PublicV2ApiServiceDelegatorImpl in project ORCID-Source by ORCID.
the class PublicV2ApiServiceDelegatorTest method testSearchByQueryIllegalStart.
@Test(expected = SearchStartParameterLimitExceededException.class)
public void testSearchByQueryIllegalStart() {
Map<String, List<String>> params = new HashMap<>();
params.put("start", Arrays.asList(Integer.toString(OrcidSearchManager.MAX_SEARCH_START + 20)));
LocaleManager localeManager = Mockito.mock(LocaleManagerImpl.class);
Mockito.when(localeManager.resolveMessage(Mockito.anyString())).thenReturn("a message");
OrcidSecurityManager orcidSecurityManager = Mockito.mock(OrcidSecurityManagerImpl.class);
Mockito.when(orcidSecurityManager.getClientIdFromAPIRequest()).thenReturn(null);
PublicV2ApiServiceDelegatorImpl delegator = new PublicV2ApiServiceDelegatorImpl();
ReflectionTestUtils.setField(delegator, "localeManager", localeManager);
ReflectionTestUtils.setField(delegator, "orcidSecurityManager", orcidSecurityManager);
delegator.searchByQuery(params);
}
use of org.orcid.api.publicV2.server.delegator.impl.PublicV2ApiServiceDelegatorImpl in project ORCID-Source by ORCID.
the class PublicV2ApiServiceDelegatorTest 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);
PublicV2ApiServiceDelegatorImpl delegator = new PublicV2ApiServiceDelegatorImpl();
ReflectionTestUtils.setField(delegator, "localeManager", localeManager);
ReflectionTestUtils.setField(delegator, "orcidSearchManager", orcidSearchManager);
ReflectionTestUtils.setField(delegator, "orcidSecurityManager", orcidSecurityManager);
Response response = delegator.searchByQuery(params);
assertNotNull(response);
}
Aggregations