use of com.androidnetworking.model.User in project Fast-Android-Networking by amitshekhariitbhu.
the class GetObjectApiTest method testObjectListGetRequest.
public void testObjectListGetRequest() throws InterruptedException {
server.enqueue(new MockResponse().setBody("[{\"firstName\":\"Amit\", \"lastName\":\"Shekhar\"}]"));
final AtomicReference<String> firstNameRef = new AtomicReference<>();
final AtomicReference<String> lastNameRef = new AtomicReference<>();
final CountDownLatch latch = new CountDownLatch(1);
AndroidNetworking.get(server.url("/").toString()).build().getAsObjectList(User.class, new ParsedRequestListener<List<User>>() {
@Override
public void onResponse(List<User> userList) {
firstNameRef.set(userList.get(0).firstName);
lastNameRef.set(userList.get(0).lastName);
latch.countDown();
}
@Override
public void onError(ANError anError) {
assertTrue(false);
}
});
assertTrue(latch.await(2, SECONDS));
assertEquals("Amit", firstNameRef.get());
assertEquals("Shekhar", lastNameRef.get());
}
Aggregations