-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update paypal request #1211
Update paypal request #1211
Changes from 10 commits
9ae1c36
7218ed3
6617176
75f064b
4b7a910
2996708
a6eed87
ec85f3d
a6e7991
a68573b
2b44ff3
70b0296
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,11 +5,12 @@ | |
import com.braintreepayments.api.core.Authorization; | ||
import com.braintreepayments.api.core.Configuration; | ||
import com.braintreepayments.api.core.PostalAddress; | ||
import com.google.testing.junit.testparameterinjector.TestParameter; | ||
|
||
import org.json.JSONException; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.robolectric.RobolectricTestRunner; | ||
import org.robolectric.RobolectricTestParameterInjector; | ||
|
||
import java.util.ArrayList; | ||
|
||
|
@@ -20,7 +21,7 @@ | |
import static org.junit.Assert.assertNotNull; | ||
import static org.mockito.Mockito.mock; | ||
|
||
@RunWith(RobolectricTestRunner.class) | ||
@RunWith(RobolectricTestParameterInjector.class) | ||
public class PayPalCheckoutRequestUnitTest { | ||
|
||
@Test | ||
|
@@ -37,11 +38,13 @@ public void newPayPalCheckoutRequest_setsDefaultValues() { | |
assertNull(request.getLandingPageType()); | ||
assertNull(request.getBillingAgreementDescription()); | ||
assertFalse(request.getShouldOfferPayLater()); | ||
assertFalse(request.getEnablePayPalAppSwitch()); | ||
assertNull(request.getUserAuthenticationEmail()); | ||
assertFalse(request.getHasUserLocationConsent()); | ||
} | ||
|
||
@Test | ||
public void setsValuesCorrectly() { | ||
public void setsValuesCorrectly(@TestParameter boolean appSwitchEnabled) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not familiar with Robolectric's TestParameter. Will it run the test with a random value? Or run the test multiple times with different values? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You'd usually have to provide which values to run. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BTW, to be precise, |
||
PostalAddress postalAddress = new PostalAddress(); | ||
PayPalCheckoutRequest request = new PayPalCheckoutRequest("1.00", true); | ||
request.setCurrencyCode("USD"); | ||
|
@@ -56,6 +59,8 @@ public void setsValuesCorrectly() { | |
request.setUserAction(PayPalPaymentUserAction.USER_ACTION_COMMIT); | ||
request.setDisplayName("Display Name"); | ||
request.setRiskCorrelationId("123-correlation"); | ||
request.setEnablePayPalAppSwitch(appSwitchEnabled); | ||
request.setUserAuthenticationEmail("test-email"); | ||
request.setLandingPageType(PayPalLandingPageType.LANDING_PAGE_TYPE_LOGIN); | ||
|
||
assertEquals("1.00", request.getAmount()); | ||
|
@@ -69,13 +74,15 @@ public void setsValuesCorrectly() { | |
assertEquals(PayPalPaymentUserAction.USER_ACTION_COMMIT, request.getUserAction()); | ||
assertEquals("Display Name", request.getDisplayName()); | ||
assertEquals("123-correlation", request.getRiskCorrelationId()); | ||
assertEquals(appSwitchEnabled, request.getEnablePayPalAppSwitch()); | ||
assertEquals("test-email", request.getUserAuthenticationEmail()); | ||
assertEquals(PayPalLandingPageType.LANDING_PAGE_TYPE_LOGIN, request.getLandingPageType()); | ||
assertTrue(request.getShouldOfferPayLater()); | ||
assertTrue(request.getHasUserLocationConsent()); | ||
} | ||
|
||
@Test | ||
public void parcelsCorrectly() { | ||
public void parcelsCorrectly(@TestParameter boolean appSwitchEnabled) { | ||
PayPalCheckoutRequest request = new PayPalCheckoutRequest("12.34", true); | ||
request.setCurrencyCode("USD"); | ||
request.setLocaleCode("en-US"); | ||
|
@@ -93,6 +100,8 @@ public void parcelsCorrectly() { | |
request.setDisplayName("Display Name"); | ||
request.setRiskCorrelationId("123-correlation"); | ||
request.setMerchantAccountId("merchant_account_id"); | ||
request.setEnablePayPalAppSwitch(appSwitchEnabled); | ||
request.setUserAuthenticationEmail("test-email"); | ||
|
||
ArrayList<PayPalLineItem> lineItems = new ArrayList<>(); | ||
lineItems.add(new PayPalLineItem(PayPalLineItemKind.DEBIT, "An Item", "1", "1")); | ||
|
@@ -110,6 +119,8 @@ public void parcelsCorrectly() { | |
result.getBillingAgreementDescription()); | ||
assertTrue(result.isShippingAddressRequired()); | ||
assertTrue(result.isShippingAddressEditable()); | ||
assertEquals(appSwitchEnabled, result.getEnablePayPalAppSwitch()); | ||
assertEquals("test-email", result.getUserAuthenticationEmail()); | ||
assertEquals("Postal Address", result.getShippingAddressOverride().getRecipientName()); | ||
assertEquals(PayPalPaymentIntent.SALE, result.getIntent()); | ||
assertEquals(PayPalLandingPageType.LANDING_PAGE_TYPE_LOGIN, result.getLandingPageType()); | ||
|
@@ -171,4 +182,5 @@ public void createRequestBody_sets_userPhoneNumber_when_not_null() throws JSONEx | |
|
||
assertTrue(requestBody.contains("\"phone_number\":{\"country_code\":\"1\",\"national_number\":\"1231231234\"}")); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,8 @@ cardinal = "2.2.7-5" | |
navigationSafeArgsGradlePlugin = "2.5.0" | ||
playServices = "19.4.0" | ||
junit = "4.13.2" | ||
robolectric = "4.11.1" | ||
testParameterInjector = "1.18" | ||
robolectric = "4.14-beta-1" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. google/TestParameterInjector#5
|
||
mockito = "5.7.0" | ||
jsonAssert = "1.5.1" | ||
mockk = "1.13.8" | ||
|
@@ -73,6 +74,7 @@ robolectric = { group = "org.robolectric", name = "robolectric", version.ref = " | |
mockito-core = { group = "org.mockito", name = "mockito-core", version.ref = "mockito" } | ||
json-assert = { group = "org.skyscreamer", name = "jsonassert", version.ref = "jsonAssert" } | ||
junit = { group = "junit", name = "junit", version.ref = "junit" } | ||
test-parameter-injector = { group = "com.google.testparameterinjector", name = "test-parameter-injector", version.ref = "testParameterInjector" } | ||
mockk = { group = "io.mockk", name = "mockk", version.ref = "mockk" } | ||
detekt-rules-libraries = { module = "io.gitlab.arturbosch.detekt:detekt-rules-libraries", version.ref = "detekt" } | ||
detekt-formatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", version.ref = "detekt" } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add an entry similar to what exists in
5.0.0
? That way we can more easily indicate this is in beta for the checkout flow as well.