use of com.braintreepayments.api.models.AmericanExpressRewardsBalance in project braintree_android by braintree.
the class BraintreeFragmentUnitTest method addAndRemoveListenersAddAndRemoveAllListeners.
@Test
public void addAndRemoveListenersAddAndRemoveAllListeners() throws InvalidArgumentException {
BraintreeFragment fragment = BraintreeFragment.newInstance(mActivity, TOKENIZATION_KEY);
ConfigurationListener configurationListener = new ConfigurationListener() {
@Override
public void onConfigurationFetched(Configuration configuration) {
}
};
BraintreeErrorListener braintreeErrorListener = new BraintreeErrorListener() {
@Override
public void onError(Exception error) {
}
};
PaymentMethodNoncesUpdatedListener paymentMethodNoncesUpdatedListener = new PaymentMethodNoncesUpdatedListener() {
@Override
public void onPaymentMethodNoncesUpdated(List<PaymentMethodNonce> paymentMethodNonces) {
}
};
PaymentMethodNonceCreatedListener paymentMethodNonceCreatedListener = new PaymentMethodNonceCreatedListener() {
@Override
public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
}
};
BraintreeCancelListener braintreeCancelListener = new BraintreeCancelListener() {
@Override
public void onCancel(int requestCode) {
}
};
UnionPayListener unionPayListener = new UnionPayListener() {
@Override
public void onCapabilitiesFetched(UnionPayCapabilities capabilities) {
}
@Override
public void onSmsCodeSent(String enrollmentId, boolean smsCodeRequired) {
}
};
AmericanExpressListener americanExpressListener = new AmericanExpressListener() {
@Override
public void onRewardsBalanceFetched(AmericanExpressRewardsBalance rewardsBalance) {
}
};
BraintreePaymentResultListener braintreePaymentResultListener = new BraintreePaymentResultListener() {
@Override
public void onBraintreePaymentResult(BraintreePaymentResult result) {
}
};
fragment.addListener(configurationListener);
fragment.addListener(braintreeErrorListener);
fragment.addListener(paymentMethodNoncesUpdatedListener);
fragment.addListener(paymentMethodNonceCreatedListener);
fragment.addListener(braintreeCancelListener);
fragment.addListener(unionPayListener);
fragment.addListener(americanExpressListener);
fragment.addListener(braintreePaymentResultListener);
assertEquals(8, fragment.getListeners().size());
fragment.removeListener(configurationListener);
fragment.removeListener(braintreeErrorListener);
fragment.removeListener(paymentMethodNoncesUpdatedListener);
fragment.removeListener(paymentMethodNonceCreatedListener);
fragment.removeListener(braintreeCancelListener);
fragment.removeListener(unionPayListener);
fragment.removeListener(americanExpressListener);
fragment.removeListener(braintreePaymentResultListener);
assertEquals(0, fragment.getListeners().size());
}
use of com.braintreepayments.api.models.AmericanExpressRewardsBalance in project braintree_android by braintree.
the class AmericanExpressUnitTest method getRewardsBalance_callsListenerWithRewardsBalanceOnIneligibleCard.
@Test
public void getRewardsBalance_callsListenerWithRewardsBalanceOnIneligibleCard() throws JSONException {
BraintreeFragment fragment = new MockFragmentBuilder().configuration(mConfiguration).successResponse(stringFromFixture("response/amex_rewards_balance_ineligible_card.json")).build();
AmericanExpress.getRewardsBalance(fragment, "fake-nonce", "USD");
ArgumentCaptor<AmericanExpressRewardsBalance> argumentCaptor = ArgumentCaptor.forClass(AmericanExpressRewardsBalance.class);
verify(fragment).postAmericanExpressCallback(argumentCaptor.capture());
AmericanExpressRewardsBalance rewardsBalance = argumentCaptor.getValue();
assertNotNull(rewardsBalance);
assertNull(rewardsBalance.getConversionRate());
assertNull(rewardsBalance.getCurrencyAmount());
assertNull(rewardsBalance.getCurrencyIsoCode());
assertNull(rewardsBalance.getRequestId());
assertNull(rewardsBalance.getRewardsAmount());
assertNull(rewardsBalance.getRewardsUnit());
assertEquals("INQ2002", rewardsBalance.getErrorCode());
assertEquals("Card is ineligible", rewardsBalance.getErrorMessage());
}
use of com.braintreepayments.api.models.AmericanExpressRewardsBalance in project braintree_android by braintree.
the class AmericanExpressUnitTest method getRewardsBalance_callsListenerWithRewardsBalanceOnInsufficientPoints.
@Test
public void getRewardsBalance_callsListenerWithRewardsBalanceOnInsufficientPoints() throws JSONException {
BraintreeFragment fragment = new MockFragmentBuilder().configuration(mConfiguration).successResponse(stringFromFixture("response/amex_rewards_balance_insufficient_points.json")).build();
AmericanExpress.getRewardsBalance(fragment, "fake-nonce", "USD");
ArgumentCaptor<AmericanExpressRewardsBalance> argumentCaptor = ArgumentCaptor.forClass(AmericanExpressRewardsBalance.class);
verify(fragment).postAmericanExpressCallback(argumentCaptor.capture());
AmericanExpressRewardsBalance rewardsBalance = argumentCaptor.getValue();
assertNotNull(rewardsBalance);
assertNull(rewardsBalance.getConversionRate());
assertNull(rewardsBalance.getCurrencyAmount());
assertNull(rewardsBalance.getCurrencyIsoCode());
assertNull(rewardsBalance.getRequestId());
assertNull(rewardsBalance.getRewardsAmount());
assertNull(rewardsBalance.getRewardsUnit());
assertEquals("INQ2003", rewardsBalance.getErrorCode());
assertEquals("Insufficient points on card", rewardsBalance.getErrorMessage());
}
use of com.braintreepayments.api.models.AmericanExpressRewardsBalance in project braintree_android by braintree.
the class AmericanExpressUnitTest method getRewardsBalance_callsListenerWithRewardsBalanceOnSuccess.
@Test
public void getRewardsBalance_callsListenerWithRewardsBalanceOnSuccess() throws JSONException {
BraintreeFragment fragment = new MockFragmentBuilder().configuration(mConfiguration).successResponse(stringFromFixture("response/amex_rewards_balance_success.json")).build();
AmericanExpress.getRewardsBalance(fragment, "fake-nonce", "USD");
ArgumentCaptor<AmericanExpressRewardsBalance> argumentCaptor = ArgumentCaptor.forClass(AmericanExpressRewardsBalance.class);
verify(fragment).postAmericanExpressCallback(argumentCaptor.capture());
AmericanExpressRewardsBalance rewardsBalance = argumentCaptor.getValue();
assertNotNull(rewardsBalance);
assertEquals("0.0070", rewardsBalance.getConversionRate());
assertEquals("316795.03", rewardsBalance.getCurrencyAmount());
assertEquals("USD", rewardsBalance.getCurrencyIsoCode());
assertEquals("715f4712-8690-49ed-8cc5-d7fb1c2d", rewardsBalance.getRequestId());
assertEquals("45256433", rewardsBalance.getRewardsAmount());
assertEquals("Points", rewardsBalance.getRewardsUnit());
assertNull(rewardsBalance.getErrorCode());
assertNull(rewardsBalance.getErrorMessage());
}
Aggregations