Skip to content

Instantly share code, notes, and snippets.

@edwardinubuntu
Created October 16, 2017 10:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edwardinubuntu/49fd71b29e0ae2adc158ec2b3518ac56 to your computer and use it in GitHub Desktop.
Save edwardinubuntu/49fd71b29e0ae2adc158ec2b3518ac56 to your computer and use it in GitHub Desktop.
AndroidTestCase Example
package tw.com.dynasafe.cix.service;
import android.test.AndroidTestCase;
import android.util.Log;
import com.google.gson.JsonObject;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import tw.com.dynasafe.cix.CIX;
import tw.com.dynasafe.cix.Demo;
import tw.com.dynasafe.cix.object.Contact;
/**
* Created by edwardchiang on 16/03/2017.
*/
public class ContactsAPITest extends AndroidTestCase {
public void testLoad() throws InterruptedException {
final CountDownLatch signal = new CountDownLatch(1);
JsonObject params = new JsonObject();
params.addProperty("id", Demo.ID);
ContactsAPI api = new ContactsAPI(getContext());
api.load(params, new OKAPICall.LoadObjectsHandler<Contact>() {
@Override
public void callback(List<Contact> objectList, Exception e) {
assertNotNull(objectList);
assertTrue("Must have data", objectList.size() > 0);
Log.d(CIX.TAG, "Data result: " + objectList);
signal.countDown();
}
});
signal.await();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment