public void testApiAsyncGetCallsAddOnResponse() throws Throwable { final String endpoint = "foobar"; final String id = null; SocializeObject obj = new SocializeObject(); api.setResponseFactory(responseFactory); AndroidMock.expect(responseFactory.newEntityResponse()).andReturn(mockEntityResponse); AndroidMock.expect(provider.get(mockSession, endpoint, id)).andReturn(obj); mockEntityResponse.addResult(obj); AndroidMock.replay(responseFactory); AndroidMock.replay(provider); AndroidMock.replay(mockEntityResponse); runTestOnUiThread( new Runnable() { @Override public void run() { api.getAsync(mockSession, endpoint, id, listener); } }); assertTrue("Timeout waiting for countdown latch", signal.await(timeout, TimeUnit.SECONDS)); AndroidMock.verify(responseFactory); AndroidMock.verify(provider); AndroidMock.verify(mockEntityResponse); }
public void testApiAsyncListCallsSetResultsOnResponsePaginated() throws Throwable { final String endpoint = "foobar"; final String key = "foobar_key"; final String[] ids = null; final int start = 0, end = 10; final ListResult<SocializeObject> returned = new ListResult<SocializeObject>(new LinkedList<SocializeObject>()); api.setResponseFactory(responseFactory); AndroidMock.expect(responseFactory.newEntityResponse()).andReturn(mockEntityResponse); AndroidMock.expect(provider.list(mockSession, endpoint, key, ids, "id", start, end)) .andReturn(returned); mockEntityResponse.setResults(returned); AndroidMock.replay(responseFactory); AndroidMock.replay(provider); AndroidMock.replay(mockEntityResponse); runTestOnUiThread( new Runnable() { @Override public void run() { api.listAsync(mockSession, endpoint, key, ids, start, end, listener); } }); assertTrue("Timeout waiting for countdown latch", signal.await(timeout, TimeUnit.SECONDS)); AndroidMock.verify(responseFactory); AndroidMock.verify(provider); AndroidMock.verify(mockEntityResponse); }