use of com.fitpay.android.api.callbacks.ResultProvidingCallback in project fitpay-android-sdk by fitpay.
the class TestActions method getCommits.
protected Collections.CommitsCollection getCommits(Device device, String lastCommitId) throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
ResultProvidingCallback<Collections.CommitsCollection> callback = new ResultProvidingCallback<>(latch);
device.getCommits(lastCommitId, callback);
latch.await(TIMEOUT, TimeUnit.SECONDS);
assertEquals("get commits error code. (message: " + callback.getErrorMessage() + ")", -1, callback.getErrorCode());
return callback.getResult();
}
use of com.fitpay.android.api.callbacks.ResultProvidingCallback in project fitpay-android-sdk by fitpay.
the class UserTest2 method testCantGetDeletedUser.
@Test
@Ignore
public // TODO Comparing to edge tests, should not be able to get user after delete. Why can we here?
void testCantGetDeletedUser() throws Exception {
this.user = getUser();
assertNotNull(user);
final CountDownLatch latch = new CountDownLatch(1);
ResultProvidingCallback<Void> callback = new ResultProvidingCallback<>(latch);
this.user.deleteUser(callback);
latch.await(TIMEOUT, TimeUnit.SECONDS);
assertEquals("delete error code", -1, callback.getErrorCode());
User deletedUser = getUser();
assertNull("user should not exist", deletedUser);
this.user = null;
}
use of com.fitpay.android.api.callbacks.ResultProvidingCallback in project fitpay-android-sdk by fitpay.
the class UserTest2 method testCantLoginWithDifferentPassword.
@Test
// this test does not work in demo environment since does auto-login
@Ignore
public void testCantLoginWithDifferentPassword() throws Exception {
this.user = getUser();
assertNotNull(user);
LoginIdentity badCredentials = getTestLoginIdentity(userName, TestUtils.getRandomLengthNumber(4, 4));
final CountDownLatch latch = new CountDownLatch(1);
ResultProvidingCallback<OAuthToken> callback = new ResultProvidingCallback<>(latch);
ApiManager.getInstance().loginUser(badCredentials, callback);
boolean completed = latch.await(TIMEOUT, TimeUnit.SECONDS);
assertTrue("login did not complete successfully", completed);
assertEquals("login error code. (message: " + callback.getErrorMessage() + ")", 401, callback.getErrorCode());
}
use of com.fitpay.android.api.callbacks.ResultProvidingCallback in project fitpay-android-sdk by fitpay.
the class UserTest2 method testUserCanGetSelf.
@Test
public void testUserCanGetSelf() throws Exception {
this.user = getUser();
final CountDownLatch latch = new CountDownLatch(1);
ResultProvidingCallback<User> callback = new ResultProvidingCallback<>(latch);
user.self(callback);
latch.await(TIMEOUT, TimeUnit.SECONDS);
User user2 = callback.getResult();
assertEquals("user self had error code (message: " + callback.getErrorMessage() + ")", -1, callback.getErrorCode());
assertEquals("user id", user.getId(), user2.getId());
assertEquals("email", user.getEmail(), user2.getEmail());
assertEquals("user name", user.getUsername(), user2.getUsername());
assertEquals("build ts", user.getCreatedTsEpoch(), user2.getCreatedTsEpoch());
}
use of com.fitpay.android.api.callbacks.ResultProvidingCallback in project fitpay-android-sdk by fitpay.
the class CreditCardTest2 method testCantAddCreditCardWithNoDevice.
@Test
public void testCantAddCreditCardWithNoDevice() throws Exception {
String pan = "9999545454545454";
CreditCard creditCard = getTestCreditCard(pan);
final CountDownLatch latch = new CountDownLatch(1);
ResultProvidingCallback<CreditCard> callback = new ResultProvidingCallback<>(latch);
user.createCreditCard(creditCard, callback);
latch.await(TIMEOUT, TimeUnit.SECONDS);
CreditCard createdCard = callback.getResult();
assertNull("created card", createdCard);
assertEquals("error code", 400, callback.getErrorCode());
}
Aggregations