package com.braintreepayments.api;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;

@RunWith(RobolectricTestRunner.class)
public class PayPalVaultRequestUnitTest {

    @Test
    public void newPayPalVaultRequest_setsDefaultValues() {
        PayPalVaultRequest request = new PayPalVaultRequest();

        assertNull(request.getLocaleCode());
        assertFalse(request.isShippingAddressRequired());
        assertNull(request.getShippingAddressOverride());
        assertNull(request.getDisplayName());
        assertNull(request.getLandingPageType());
        assertFalse(request.getShouldOfferCredit());
    }

    @Test
    public void setsValuesCorrectly() {
        PostalAddress postalAddress = new PostalAddress();
        PayPalVaultRequest request = new PayPalVaultRequest();
        request.setLocaleCode("US");
        request.setBillingAgreementDescription("Billing Agreement Description");
        request.setShippingAddressRequired(true);
        request.setShippingAddressOverride(postalAddress);
        request.setDisplayName("Display Name");
        request.setLandingPageType(PayPalRequest.LANDING_PAGE_TYPE_LOGIN);
        request.setShouldOfferCredit(true);

        assertEquals("US", request.getLocaleCode());
        assertEquals("Billing Agreement Description", request.getBillingAgreementDescription());
        assertTrue(request.isShippingAddressRequired());
        assertEquals(postalAddress, request.getShippingAddressOverride());
        assertEquals("Display Name", request.getDisplayName());
        assertEquals(PayPalRequest.LANDING_PAGE_TYPE_LOGIN, request.getLandingPageType());
        assertTrue(request.getShouldOfferCredit());
    }
}

@@ -29,16 +29,43 @@
 s.api;%0A%0A
+import android.os.Parcel;%0A%0A
 import o
@@ -79,16 +79,16 @@
 t.Test;%0A
-
 import o
@@ -159,16 +159,45 @@
 unner;%0A%0A
+import java.util.ArrayList;%0A%0A
 import s
@@ -1916,32 +1916,32 @@
 ingPageType());%0A
-
         assertTr
@@ -1981,11 +1981,1962 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void parcelsCorrectly() %7B%0A        PayPalVaultRequest request = new PayPalVaultRequest();%0A        request.setLocaleCode(%22en-US%22);%0A        request.setBillingAgreementDescription(%22Billing Agreement Description%22);%0A        request.setShippingAddressRequired(true);%0A        request.setShippingAddressEditable(true);%0A        request.setShouldOfferCredit(true);%0A%0A        PostalAddress postalAddress = new PostalAddress();%0A        postalAddress.setRecipientName(%22Postal Address%22);%0A        request.setShippingAddressOverride(postalAddress);%0A%0A        request.setLandingPageType(PayPalRequest.LANDING_PAGE_TYPE_LOGIN);%0A        request.setDisplayName(%22Display Name%22);%0A        request.setMerchantAccountId(%22merchant_account_id%22);%0A%0A        ArrayList%3CPayPalLineItem%3E lineItems = new ArrayList%3C%3E();%0A        lineItems.add(new PayPalLineItem(PayPalLineItem.KIND_DEBIT, %22An Item%22, %221%22, %221%22));%0A        request.setLineItems(lineItems);%0A%0A        Parcel parcel = Parcel.obtain();%0A        request.writeToParcel(parcel, 0);%0A        parcel.setDataPosition(0);%0A        PayPalVaultRequest result = PayPalVaultRequest.CREATOR.createFromParcel(parcel);%0A%0A        assertEquals(%22en-US%22, result.getLocaleCode());%0A        assertEquals(%22Billing Agreement Description%22,%0A                result.getBillingAgreementDescription());%0A        assertTrue(result.getShouldOfferCredit());%0A        assertTrue(result.isShippingAddressRequired());%0A        assertTrue(result.isShippingAddressEditable());%0A        assertEquals(%22Postal Address%22, result.getShippingAddressOverride()%0A                .getRecipientName());%0A        assertEquals(PayPalRequest.LANDING_PAGE_TYPE_LOGIN, result.getLandingPageType());%0A        assertEquals(%22Display Name%22, result.getDisplayName());%0A        assertEquals(%22merchant_account_id%22, result.getMerchantAccountId());%0A        assertEquals(1, result.getLineItems().size());%0A        assertEquals(%22An Item%22, result.getLineItems().get(0).getName());%0A    %7D
 %0A%7D%0A

Add parcels test for PayPalVaultRequest