use of com.braintreepayments.api.exceptions.InvalidArgumentException in project braintree_android by braintree.
the class BraintreeHttpClientTest method getRequestSslCertificateSuccessfulInProduction.
@Test(timeout = 5000)
public void getRequestSslCertificateSuccessfulInProduction() throws InterruptedException, InvalidArgumentException {
BraintreeHttpClient httpClient = new BraintreeHttpClient(TokenizationKey.fromString(TOKENIZATION_KEY));
httpClient.setBaseUrl("https://api.braintreegateway.com");
httpClient.get("/", new HttpResponseCallback() {
@Override
public void success(String responseBody) {
fail("Request failed");
}
@Override
public void failure(Exception exception) {
assertTrue(exception instanceof AuthorizationException);
mCountDownLatch.countDown();
}
});
mCountDownLatch.await();
}
use of com.braintreepayments.api.exceptions.InvalidArgumentException in project braintree_android by braintree.
the class BraintreeHttpClientTest method postsErrorWhenBaseUrlIsNotSet.
@Test(timeout = 1000)
public void postsErrorWhenBaseUrlIsNotSet() throws InterruptedException, IOException, InvalidArgumentException {
BraintreeHttpClient httpClient = new BraintreeHttpClient(TokenizationKey.fromString(TOKENIZATION_KEY));
final CountDownLatch countDownLatch = new CountDownLatch(2);
httpClient.get("/", new HttpResponseCallback() {
@Override
public void success(String responseBody) {
fail("Request was successful");
}
@Override
public void failure(Exception exception) {
assertEquals(MalformedURLException.class, exception.getClass());
countDownLatch.countDown();
}
});
httpClient.post("/", "{}", new HttpResponseCallback() {
@Override
public void success(String responseBody) {
fail("Request was successful");
}
@Override
public void failure(Exception exception) {
assertEquals(MalformedURLException.class, exception.getClass());
countDownLatch.countDown();
}
});
countDownLatch.await();
}
use of com.braintreepayments.api.exceptions.InvalidArgumentException in project braintree_android by braintree.
the class BraintreeHttpClientTest method postsErrorWhenClientTokenIsUsedAndInvalidJsonIsSent.
@Test(timeout = 1000)
public void postsErrorWhenClientTokenIsUsedAndInvalidJsonIsSent() throws InvalidArgumentException, InterruptedException {
BraintreeHttpClient httpClient = new BraintreeHttpClient(Authorization.fromString(stringFromFixture("client_token.json")));
httpClient.post("/", "not json", new HttpResponseCallback() {
@Override
public void success(String responseBody) {
fail("Request was successful");
}
@Override
public void failure(Exception exception) {
assertTrue(exception instanceof JSONException);
assertEquals("Value not of type java.lang.String cannot be converted to JSONObject", exception.getMessage());
mCountDownLatch.countDown();
}
});
mCountDownLatch.await();
}
use of com.braintreepayments.api.exceptions.InvalidArgumentException in project braintree_android by braintree.
the class BraintreeHttpClientTest method postsErrorWhenPathIsNull.
@Test(timeout = 1000)
public void postsErrorWhenPathIsNull() throws InterruptedException, InvalidArgumentException {
BraintreeHttpClient httpClient = new BraintreeHttpClient(TokenizationKey.fromString(TOKENIZATION_KEY));
final CountDownLatch countDownLatch = new CountDownLatch(2);
httpClient.get(null, new HttpResponseCallback() {
@Override
public void success(String responseBody) {
fail("Request was successful");
}
@Override
public void failure(Exception exception) {
assertEquals(IllegalArgumentException.class, exception.getClass());
assertEquals("Path cannot be null", exception.getMessage());
countDownLatch.countDown();
}
});
httpClient.post(null, "{}", new HttpResponseCallback() {
@Override
public void success(String responseBody) {
fail("Request was successful");
}
@Override
public void failure(Exception exception) {
assertEquals(IllegalArgumentException.class, exception.getClass());
assertEquals("Path cannot be null", exception.getMessage());
countDownLatch.countDown();
}
});
countDownLatch.await();
}
use of com.braintreepayments.api.exceptions.InvalidArgumentException in project braintree_android by braintree.
the class ThreeDSecureVerificationTest method getFragment.
private BraintreeFragment getFragment(String authorization, String configuration) {
try {
Authorization auth = Authorization.fromString(authorization);
writeMockConfiguration(getTargetContext(), auth.getConfigUrl(), auth.getBearer(), configuration);
BraintreeFragment fragment = BraintreeFragment.newInstance(mActivity, authorization);
while (!fragment.isAdded()) {
try {
Thread.sleep(10);
} catch (InterruptedException ignored) {
}
}
return fragment;
} catch (InvalidArgumentException e) {
fail(e.getMessage());
return new BraintreeFragment();
}
}
Aggregations