Search in sources :

Example 1 with ValidationException

use of com.fitpay.android.utils.ValidationException in project fitpay-android-sdk by fitpay.

the class Steps method login.

public void login() throws InterruptedException {
    final CountDownLatch latch = new CountDownLatch(1);
    final boolean[] isRequestSuccess = { false };
    LoginIdentity loginIdentity = null;
    try {
        loginIdentity = new LoginIdentity.Builder().setUsername(userName).setPassword(password).build();
    } catch (ValidationException ignored) {
    }
    Assert.assertNotNull(loginIdentity);
    ApiManager.getInstance().loginUser(loginIdentity, new ApiCallback<OAuthToken>() {

        @Override
        public void onSuccess(OAuthToken result) {
            Assert.assertNotNull("missing bearer token", result.getAccessToken());
            isRequestSuccess[0] = true;
            latch.countDown();
        }

        @Override
        public void onFailure(@ResultCode.Code int errorCode, String errorMessage) {
            fail("unable to login: " + errorMessage);
            latch.countDown();
        }
    });
    latch.await(TIMEOUT, TimeUnit.SECONDS);
    Assert.assertTrue(isRequestSuccess[0]);
}
Also used : OAuthToken(com.fitpay.android.api.models.security.OAuthToken) ValidationException(com.fitpay.android.utils.ValidationException) CountDownLatch(java.util.concurrent.CountDownLatch) LoginIdentity(com.fitpay.android.api.models.user.LoginIdentity)

Aggregations

OAuthToken (com.fitpay.android.api.models.security.OAuthToken)1 LoginIdentity (com.fitpay.android.api.models.user.LoginIdentity)1 ValidationException (com.fitpay.android.utils.ValidationException)1 CountDownLatch (java.util.concurrent.CountDownLatch)1