Search in sources :

Example 1 with UserAddress

use of com.google.android.gms.identity.intents.model.UserAddress in project braintree_android by braintree.

the class AndroidPayCardNonceUnitTest method fromFullWallet_withCart_createsAndroidPayCardNonce.

@Test
public void fromFullWallet_withCart_createsAndroidPayCardNonce() throws JSONException {
    UserAddress billingAddress = mock(UserAddress.class);
    UserAddress shippingAddress = mock(UserAddress.class);
    Cart cart = Cart.newBuilder().build();
    FullWallet wallet = getFullWallet(stringFromFixture("payment_methods/android_pay_card_response.json"), billingAddress, shippingAddress);
    AndroidPayCardNonce androidPayCardNonce = AndroidPayCardNonce.fromFullWallet(wallet, cart);
    assertEquals("Android Pay", androidPayCardNonce.getTypeLabel());
    assertEquals("fake-android-pay-nonce", androidPayCardNonce.getNonce());
    assertEquals("MasterCard 0276", androidPayCardNonce.getDescription());
    assertEquals("Visa", androidPayCardNonce.getCardType());
    assertEquals("11", androidPayCardNonce.getLastTwo());
    assertEquals("android-user@example.com", androidPayCardNonce.getEmail());
    assertEquals(billingAddress, androidPayCardNonce.getBillingAddress());
    assertEquals(shippingAddress, androidPayCardNonce.getShippingAddress());
    assertEquals("google-transaction-id", androidPayCardNonce.getGoogleTransactionId());
    assertEquals(cart, androidPayCardNonce.getCart());
}
Also used : FullWallet(com.google.android.gms.wallet.FullWallet) UserAddress(com.google.android.gms.identity.intents.model.UserAddress) Cart(com.google.android.gms.wallet.Cart) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with UserAddress

use of com.google.android.gms.identity.intents.model.UserAddress in project braintree_android by braintree.

the class AndroidPayCardNonceUnitTest method fromFullWallet_createsAndroidPayCardNonce.

@Test
public void fromFullWallet_createsAndroidPayCardNonce() throws JSONException {
    UserAddress billingAddress = mock(UserAddress.class);
    UserAddress shippingAddress = mock(UserAddress.class);
    FullWallet wallet = getFullWallet(stringFromFixture("payment_methods/android_pay_card_response.json"), billingAddress, shippingAddress);
    AndroidPayCardNonce androidPayCardNonce = AndroidPayCardNonce.fromFullWallet(wallet);
    assertEquals("Android Pay", androidPayCardNonce.getTypeLabel());
    assertEquals("fake-android-pay-nonce", androidPayCardNonce.getNonce());
    assertEquals("MasterCard 0276", androidPayCardNonce.getDescription());
    assertEquals("Visa", androidPayCardNonce.getCardType());
    assertEquals("11", androidPayCardNonce.getLastTwo());
    assertEquals("android-user@example.com", androidPayCardNonce.getEmail());
    assertEquals(billingAddress, androidPayCardNonce.getBillingAddress());
    assertEquals(shippingAddress, androidPayCardNonce.getShippingAddress());
    assertEquals("google-transaction-id", androidPayCardNonce.getGoogleTransactionId());
}
Also used : FullWallet(com.google.android.gms.wallet.FullWallet) UserAddress(com.google.android.gms.identity.intents.model.UserAddress) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 3 with UserAddress

use of com.google.android.gms.identity.intents.model.UserAddress in project braintree_android by braintree.

the class GooglePaymentCardNonceUnitTest method parcelsCorrectly.

@Test
public void parcelsCorrectly() throws Exception {
    UserAddress billingAddress = getAddressObject();
    UserAddress shippingAddress = getAddressObject();
    PaymentData paymentData = getPaymentData("android-user@example.com", billingAddress, shippingAddress, stringFromFixture("payment_methods/android_pay_card_response.json"));
    GooglePaymentCardNonce googlePaymentCardNonce = GooglePaymentCardNonce.fromPaymentData(paymentData);
    Parcel parcel = Parcel.obtain();
    googlePaymentCardNonce.writeToParcel(parcel, 0);
    parcel.setDataPosition(0);
    GooglePaymentCardNonce parceled = GooglePaymentCardNonce.CREATOR.createFromParcel(parcel);
    assertEquals("Google Pay", parceled.getTypeLabel());
    assertEquals("fake-android-pay-nonce", parceled.getNonce());
    assertEquals("MasterCard 0276", parceled.getDescription());
    assertEquals("Visa", parceled.getCardType());
    assertEquals("11", parceled.getLastTwo());
    assertEquals("1234", parceled.getLastFour());
    assertEquals("android-user@example.com", parceled.getEmail());
    assertNotNull(parceled.getBillingAddress());
    assertNotNull(parceled.getShippingAddress());
    assertBinDataEqual(googlePaymentCardNonce.getBinData(), parceled.getBinData());
}
Also used : PaymentData(com.google.android.gms.wallet.PaymentData) Parcel(android.os.Parcel) UserAddress(com.google.android.gms.identity.intents.model.UserAddress) Test(org.junit.Test)

Example 4 with UserAddress

use of com.google.android.gms.identity.intents.model.UserAddress in project braintree_android by braintree.

the class GooglePaymentCardNonceUnitTest method fromPaymentData_createsGooglePaymentCardNonce.

@Test
public void fromPaymentData_createsGooglePaymentCardNonce() throws Exception {
    UserAddress billingAddress = getAddressObject();
    UserAddress shippingAddress = getAddressObject();
    PaymentData paymentData = getPaymentData("android-user@example.com", billingAddress, shippingAddress, stringFromFixture("payment_methods/android_pay_card_response.json"));
    GooglePaymentCardNonce googlePaymentCardNonce = GooglePaymentCardNonce.fromPaymentData(paymentData);
    assertEquals("Google Pay", googlePaymentCardNonce.getTypeLabel());
    assertEquals("fake-android-pay-nonce", googlePaymentCardNonce.getNonce());
    assertEquals("MasterCard 0276", googlePaymentCardNonce.getDescription());
    assertEquals("Visa", googlePaymentCardNonce.getCardType());
    assertEquals("11", googlePaymentCardNonce.getLastTwo());
    assertEquals("1234", googlePaymentCardNonce.getLastFour());
    assertEquals("android-user@example.com", googlePaymentCardNonce.getEmail());
    assertEquals(billingAddress, googlePaymentCardNonce.getBillingAddress());
    assertEquals(shippingAddress, googlePaymentCardNonce.getShippingAddress());
}
Also used : PaymentData(com.google.android.gms.wallet.PaymentData) UserAddress(com.google.android.gms.identity.intents.model.UserAddress) Test(org.junit.Test)

Example 5 with UserAddress

use of com.google.android.gms.identity.intents.model.UserAddress in project braintree_android by braintree.

the class AndroidPayCardNonceUnitTest method parcelsCorrectly.

@Test
public void parcelsCorrectly() throws Exception {
    UserAddress billingAddress = getAddressObject();
    UserAddress shippingAddress = getAddressObject();
    Cart cart = Cart.newBuilder().build();
    FullWallet wallet = getFullWallet(stringFromFixture("payment_methods/android_pay_card_response.json"), billingAddress, shippingAddress);
    AndroidPayCardNonce androidPayCardNonce = AndroidPayCardNonce.fromFullWallet(wallet, cart);
    Parcel parcel = Parcel.obtain();
    androidPayCardNonce.writeToParcel(parcel, 0);
    parcel.setDataPosition(0);
    AndroidPayCardNonce parceled = AndroidPayCardNonce.CREATOR.createFromParcel(parcel);
    assertEquals("Android Pay", parceled.getTypeLabel());
    assertEquals("fake-android-pay-nonce", parceled.getNonce());
    assertEquals("MasterCard 0276", parceled.getDescription());
    assertEquals("Visa", parceled.getCardType());
    assertEquals("11", parceled.getLastTwo());
    assertEquals("android-user@example.com", parceled.getEmail());
    assertNotNull(parceled.getBillingAddress());
    assertNotNull(parceled.getShippingAddress());
    assertEquals("google-transaction-id", parceled.getGoogleTransactionId());
    assertNotNull(parceled.getCart());
    assertBinDataEqual(androidPayCardNonce.getBinData(), parceled.getBinData());
}
Also used : FullWallet(com.google.android.gms.wallet.FullWallet) Parcel(android.os.Parcel) UserAddress(com.google.android.gms.identity.intents.model.UserAddress) Cart(com.google.android.gms.wallet.Cart) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

UserAddress (com.google.android.gms.identity.intents.model.UserAddress)5 Test (org.junit.Test)5 FullWallet (com.google.android.gms.wallet.FullWallet)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 Parcel (android.os.Parcel)2 Cart (com.google.android.gms.wallet.Cart)2 PaymentData (com.google.android.gms.wallet.PaymentData)2