use of org.orcid.core.manager.OrcidSecurityManager 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.core.manager.OrcidSecurityManager in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_GeneralTest method testSearchByQueryBadScope.
@Test(expected = AccessControlException.class)
public void testSearchByQueryBadScope() {
OrcidSecurityManager orcidSecurityManager = Mockito.mock(OrcidSecurityManagerImpl.class);
Mockito.doThrow(new AccessControlException("some problem with scope")).when(orcidSecurityManager).checkScopes(Mockito.any(ScopePathType.class));
MemberV2ApiServiceDelegatorImpl delegator = new MemberV2ApiServiceDelegatorImpl();
ReflectionTestUtils.setField(delegator, "orcidSecurityManager", orcidSecurityManager);
delegator.searchByQuery(new HashMap<>());
}
Aggregations