Search in sources :

Example 1 with Search

use of nl.knaw.huygens.timbuctoo.server.endpoints.v2.Search in project ORCID-Source by ORCID.

the class PublicV2ApiServiceDelegatorImpl method searchByQuery.

@Override
public Response searchByQuery(Map<String, List<String>> solrParams) {
    validateSearchParams(solrParams);
    Search search = orcidSearchManager.findOrcidIds(solrParams);
    return Response.ok(search).build();
}
Also used : Search(org.orcid.jaxb.model.search_v2.Search)

Example 2 with Search

use of nl.knaw.huygens.timbuctoo.server.endpoints.v2.Search in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegatorImpl method searchByQuery.

@Override
public Response searchByQuery(Map<String, List<String>> solrParams) {
    orcidSecurityManager.checkScopes(ScopePathType.READ_PUBLIC);
    validateSearchParams(solrParams);
    Search search = orcidSearchManager.findOrcidIds(solrParams);
    return Response.ok(search).build();
}
Also used : Search(org.orcid.jaxb.model.search_v2.Search)

Example 3 with Search

use of nl.knaw.huygens.timbuctoo.server.endpoints.v2.Search 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());
}
Also used : PublicV2ApiServiceDelegatorImpl(org.orcid.api.publicV2.server.delegator.impl.PublicV2ApiServiceDelegatorImpl) Response(javax.ws.rs.core.Response) OrcidIdentifier(org.orcid.jaxb.model.common_v2.OrcidIdentifier) Search(org.orcid.jaxb.model.search_v2.Search) OrcidSecurityManager(org.orcid.core.manager.OrcidSecurityManager) List(java.util.List) ArrayList(java.util.ArrayList) OrcidSearchManager(org.orcid.core.manager.OrcidSearchManager) Result(org.orcid.jaxb.model.search_v2.Result) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 4 with Search

use of nl.knaw.huygens.timbuctoo.server.endpoints.v2.Search 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);
}
Also used : PublicV2ApiServiceDelegatorImpl(org.orcid.api.publicV2.server.delegator.impl.PublicV2ApiServiceDelegatorImpl) Response(javax.ws.rs.core.Response) HashMap(java.util.HashMap) Search(org.orcid.jaxb.model.search_v2.Search) OrcidSecurityManager(org.orcid.core.manager.OrcidSecurityManager) List(java.util.List) ArrayList(java.util.ArrayList) LocaleManager(org.orcid.core.locale.LocaleManager) OrcidSearchManager(org.orcid.core.manager.OrcidSearchManager) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 5 with Search

use of nl.knaw.huygens.timbuctoo.server.endpoints.v2.Search in project ORCID-Source by ORCID.

the class MemberV2ApiServiceVersionedDelegatorTest method testSearchByQuery.

@Test
public void testSearchByQuery() {
    MockitoAnnotations.initMocks(this);
    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();
    Mockito.when(mockServiceDelegatorNonVersioned.searchByQuery(Matchers.<Map<String, List<String>>>any())).thenReturn(searchResponse);
    TargetProxyHelper.injectIntoProxy(serviceDelegator, "memberV2ApiServiceDelegator", mockServiceDelegatorNonVersioned);
    Response response = serviceDelegator.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());
    TargetProxyHelper.injectIntoProxy(serviceDelegator, "memberV2ApiServiceDelegator", serviceDelegatorNonVersioned);
}
Also used : Response(javax.ws.rs.core.Response) OrcidIdentifier(org.orcid.jaxb.model.common_v2.OrcidIdentifier) Search(org.orcid.jaxb.model.search_v2.Search) List(java.util.List) Result(org.orcid.jaxb.model.search_v2.Result) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Search (org.orcid.jaxb.model.search_v2.Search)10 List (java.util.List)9 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)6 Response (javax.ws.rs.core.Response)5 Result (org.orcid.jaxb.model.search_v2.Result)5 DBUnitTest (org.orcid.test.DBUnitTest)5 OrcidSearchManager (org.orcid.core.manager.OrcidSearchManager)4 OrcidSecurityManager (org.orcid.core.manager.OrcidSecurityManager)4 OrcidIdentifier (org.orcid.jaxb.model.common_v2.OrcidIdentifier)4 FundingList (org.orcid.jaxb.model.message.FundingList)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 IOException (java.io.IOException)2 URI (java.net.URI)2 Map (java.util.Map)2 Vres (nl.knaw.huygens.timbuctoo.model.vre.Vres)2 Autocomplete (nl.knaw.huygens.timbuctoo.server.endpoints.v2.domain.Autocomplete)2 PublicV2ApiServiceDelegatorImpl (org.orcid.api.publicV2.server.delegator.impl.PublicV2ApiServiceDelegatorImpl)2 BaseTest (org.orcid.core.BaseTest)2