Search in sources :

Example 1 with PublicV2ApiServiceVersionedDelegatorImpl

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

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 Response (javax.ws.rs.core.Response)1 Test (org.junit.Test)1 PublicV2ApiServiceDelegatorImpl (org.orcid.api.publicV2.server.delegator.impl.PublicV2ApiServiceDelegatorImpl)1 PublicV2ApiServiceVersionedDelegatorImpl (org.orcid.api.publicV2.server.delegator.impl.PublicV2ApiServiceVersionedDelegatorImpl)1 OrcidIdentifier (org.orcid.jaxb.model.common_v2.OrcidIdentifier)1 Result (org.orcid.jaxb.model.search_v2.Result)1 Search (org.orcid.jaxb.model.search_v2.Search)1 DBUnitTest (org.orcid.test.DBUnitTest)1