Skip to content

Commit

Permalink
PayPal support (#17)
Browse files Browse the repository at this point in the history
Added PayPal as a Transfer method
  • Loading branch information
fmattos-hw authored May 15, 2019
1 parent bd12025 commit 2cf1e41
Show file tree
Hide file tree
Showing 41 changed files with 1,673 additions and 332 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ Changelog
-------------------
- Initial release
* UI components to create Bank Account and Bank Card for United States (USD)
* UI components to list and deactivate accounts
* UI components to list and deactivate accounts

1.0.0-beta02
-------------------
* Added PayPal as a Transfer method
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Note that this SDK is geared towards those who need both backend data and UI fea
To install Hyperwallet UI SDK, you just need to add the dependency into your build.gradle file in Android Studio (or Gradle). For example:

```bash
api 'com.hyperwallet.android:ui-sdk:1.0.0-beta01'
api 'com.hyperwallet.android:ui-sdk:1.0.0-beta02'
```

## Initialization
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ allprojects {

}

project.version = "1.0.0-beta01";
project.version = "1.0.0-beta02";
}

task clean(type: Delete) {
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
android.useAndroidX=true
android.enableJetifier=true
sonatypeUsername=user
sonatypePassword=password
sonatypeUsername=
sonatypePassword=
9 changes: 6 additions & 3 deletions ui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ android {
}

buildTypes {
dev {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
testCoverageEnabled true
}
}

lintOptions {
Expand All @@ -46,7 +49,7 @@ dependencies {
implementation "androidx.legacy:legacy-support-v4:1.0.0"
implementation "androidx.recyclerview:recyclerview:1.0.0"

api 'com.hyperwallet.android:core-sdk:1.0.0-beta01'
api 'com.hyperwallet.android:core-sdk:1.0.0-beta02'

androidTestImplementation "androidx.test.ext:junit:1.1.0"
androidTestImplementation "androidx.test:runner:1.1.1"
Expand Down Expand Up @@ -149,7 +152,7 @@ publishing {

tasks.withType(Sign) {
onlyIf {
isReleaseVersion
isReleaseVersion && sonatypeUsername?.trim() && sonatypePassword?.trim()
}
}

Expand Down
4 changes: 2 additions & 2 deletions ui/config/jacoco-settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def debugClassPaths = [

final def coverageSourceDirs = ["$project.projectDir/src/main/java/*"]

task jacocoTestReport(type: JacocoReport, dependsOn: 'testDevUnitTest') {
task jacocoTestReport(type: JacocoReport, dependsOn: 'testDebugUnitTest') {

group = 'Reporting'
description = 'Generate Jacoco coverage reports.'
Expand Down Expand Up @@ -68,7 +68,7 @@ task jacocoTestCoverageVerification(type: JacocoCoverageVerification, dependsOn:
)
additionalSourceDirs = files(coverageSourceDirs)
sourceDirectories = files(coverageSourceDirs)
executionData = files("${buildDir}/jacoco/testDevUnitTest.exec")
executionData = files("${buildDir}/jacoco/testDebugUnitTest.exec")

violationRules {
setFailOnViolation(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ protected Intent getActivityIntent() {
intent.putExtra("TRANSFER_METHOD_TYPE", "BANK_ACCOUNT");
intent.putExtra("TRANSFER_METHOD_COUNTRY", "US");
intent.putExtra("TRANSFER_METHOD_CURRENCY", "USD");
intent.putExtra("TRANSFER_METHOD_PROFILE_TYPE", "INDIVIDUAL");
return intent;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ protected Intent getActivityIntent() {
intent.putExtra("TRANSFER_METHOD_TYPE", "BANK_CARD");
intent.putExtra("TRANSFER_METHOD_COUNTRY", "US");
intent.putExtra("TRANSFER_METHOD_CURRENCY", "USD");
intent.putExtra("TRANSFER_METHOD_PROFILE_TYPE", "INDIVIDUAL");
return intent;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ public void testListTransferMethod_userHasMultipleTransferMethods() {
mActivityTestRule.launchActivity(null);

// assert
onView(withId(R.id.toolbar)).check(matches(isDisplayed()));
onView(allOf(instanceOf(TextView.class), withParent(withId(R.id.toolbar))))
.check(matches(withText(R.string.title_activity_list_transfer_method)));
onView(withId(R.id.fab)).check(matches(isDisplayed()));
Expand Down Expand Up @@ -146,7 +145,17 @@ public void testListTransferMethod_userHasMultipleTransferMethods() {
onView(withId(R.id.list_transfer_method_item)).check(
matches(atPosition(4, hasDescendant(withDrawable(R.drawable.ic_three_dots_16dp)))));

onView(withId(R.id.list_transfer_method_item)).check(new RecyclerViewCountAssertion(5));
onView(withId(R.id.list_transfer_method_item)).check(
matches(atPosition(5, hasDescendant(withText(R.string.paypal_account_font_icon)))));
onView(withId(R.id.list_transfer_method_item)).check(
matches(atPosition(5, hasDescendant(withText(R.string.paypal_account)))));
onView(withId(R.id.list_transfer_method_item)).check(
matches(atPosition(5, hasDescendant(withText("United States")))));
//TODO: Try to check for non existence of transfer_method_type_description_2
onView(withId(R.id.list_transfer_method_item)).check(
matches(atPosition(5, hasDescendant(withDrawable(R.drawable.ic_three_dots_16dp)))));

onView(withId(R.id.list_transfer_method_item)).check(new RecyclerViewCountAssertion(6));

}

Expand Down Expand Up @@ -337,6 +346,70 @@ public void onReceive(Context context, Intent intent) {

}

@Test
public void testListTransferMethod_removePayPalAccount() throws InterruptedException {
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager
.getResourceContent("transfer_method_list_single_paypal_account_response.json")).mock();
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager
.getResourceContent("transfer_method_deactivate_success.json")).mock();
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_NO_CONTENT).withBody("").mock();


final CountDownLatch gate = new CountDownLatch(1);
final BroadcastReceiver br = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
gate.countDown();

HyperwalletStatusTransition statusTransition = intent.getParcelableExtra(
"hyperwallet-local-broadcast-payload");
assertThat("Transition is not valid", statusTransition.getTransition(), is(DE_ACTIVATED));
}
};

// run test
mActivityTestRule.launchActivity(null);
LocalBroadcastManager.getInstance(mActivityTestRule.getActivity().getApplicationContext())
.registerReceiver(br, new IntentFilter("ACTION_HYPERWALLET_TRANSFER_METHOD_DEACTIVATED"));

// assert
onView(withId(R.id.toolbar)).check(matches(isDisplayed()));
onView(allOf(instanceOf(TextView.class), withParent(withId(R.id.toolbar))))
.check(matches(withText(R.string.title_activity_list_transfer_method)));
onView(withId(R.id.fab)).check(matches(isDisplayed()));

onView(withId(R.id.list_transfer_method_item)).check(
matches(atPosition(0, hasDescendant(withText(R.string.paypal_account_font_icon)))));
onView(withId(R.id.list_transfer_method_item)).check(
matches(atPosition(0, hasDescendant(withText(R.string.paypal_account)))));
onView(withId(R.id.list_transfer_method_item)).check(
matches(atPosition(0, hasDescendant(withText("United States")))));
onView(withId(R.id.list_transfer_method_item)).check(
matches(atPosition(0, hasDescendant(withDrawable(R.drawable.ic_three_dots_16dp)))));

onView(allOf(instanceOf(ImageButton.class), hasSibling(withText(R.string.paypal_account)))).perform(click())
.inRoot(Matchers.<Root>instanceOf(MenuItem.class));
onView(withDrawable(R.drawable.ic_trash)).check(matches(isDisplayed()));
onView(withText(R.string.menu_remove_account)).check(matches(isDisplayed())).perform(click());

// confirmation dialog is shown before deletion
onView(withText(R.string.transfer_method_remove_confirmation_title)).check(matches(isDisplayed()));
onView(withText(R.string.transfer_method_remove_confirmation)).check(matches(isDisplayed()));
onView(withId(android.R.id.button1)).check(matches(withText(R.string.remove_button_label)));
onView(withId(android.R.id.button2)).check(matches(withText(R.string.cancel_button_label)));

onView(withId(android.R.id.button1)).perform(click());

gate.await(5, SECONDS);
LocalBroadcastManager.getInstance(mActivityTestRule.getActivity().getApplicationContext()).unregisterReceiver(
br);
assertThat("Action is not broadcasted", gate.getCount(), is(0L));

onView(withId(R.id.empty_transfer_method_list_layout)).check(matches(isDisplayed()));
onView(withText(R.string.empty_list_transfer_method_information)).check(matches(isDisplayed()));

}

@Test
public void testListTransferMethod_removeBankAccountClickCancel() throws InterruptedException {
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager
Expand Down
Loading

0 comments on commit 2cf1e41

Please sign in to comment.