Skip to content

Commit 3f28326

Browse files
fmattos-hwskoong
authored andcommitted
Feature/hw 52030 user repository (#12)
* HW-52030 Added User Repository
1 parent 049526a commit 3f28326

25 files changed

+832
-184
lines changed

ui/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ android {
2222
}
2323

2424
buildTypes {
25-
dev {
25+
release {
2626
minifyEnabled false
2727
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
2828
}
29+
debug {
30+
testCoverageEnabled true
31+
}
2932
}
3033

3134
lintOptions {

ui/config/jacoco-settings.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def debugClassPaths = [
3535

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

38-
task jacocoTestReport(type: JacocoReport, dependsOn: 'testDevUnitTest') {
38+
task jacocoTestReport(type: JacocoReport, dependsOn: 'testDebugUnitTest') {
3939

4040
group = 'Reporting'
4141
description = 'Generate Jacoco coverage reports.'
@@ -68,7 +68,7 @@ task jacocoTestCoverageVerification(type: JacocoCoverageVerification, dependsOn:
6868
)
6969
additionalSourceDirs = files(coverageSourceDirs)
7070
sourceDirectories = files(coverageSourceDirs)
71-
executionData = files("${buildDir}/jacoco/testDevUnitTest.exec")
71+
executionData = files("${buildDir}/jacoco/testDebugUnitTest.exec")
7272

7373
violationRules {
7474
setFailOnViolation(true)

ui/src/androidTest/java/com/hyperwallet/android/transfermethod/ui/BankAccountTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ protected Intent getActivityIntent() {
8484
intent.putExtra("TRANSFER_METHOD_TYPE", "BANK_ACCOUNT");
8585
intent.putExtra("TRANSFER_METHOD_COUNTRY", "US");
8686
intent.putExtra("TRANSFER_METHOD_CURRENCY", "USD");
87+
intent.putExtra("TRANSFER_METHOD_PROFILE_TYPE", "INDIVIDUAL");
8788
return intent;
8889
}
8990
};

ui/src/androidTest/java/com/hyperwallet/android/transfermethod/ui/BankCardTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ protected Intent getActivityIntent() {
8686
intent.putExtra("TRANSFER_METHOD_TYPE", "BANK_CARD");
8787
intent.putExtra("TRANSFER_METHOD_COUNTRY", "US");
8888
intent.putExtra("TRANSFER_METHOD_CURRENCY", "USD");
89+
intent.putExtra("TRANSFER_METHOD_PROFILE_TYPE", "INDIVIDUAL");
8990
return intent;
9091
}
9192
};

ui/src/androidTest/java/com/hyperwallet/android/transfermethod/ui/PayPalTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ protected Intent getActivityIntent() {
7676
intent.putExtra("TRANSFER_METHOD_TYPE", "PAYPAL_ACCOUNT");
7777
intent.putExtra("TRANSFER_METHOD_COUNTRY", "US");
7878
intent.putExtra("TRANSFER_METHOD_CURRENCY", "USD");
79+
intent.putExtra("TRANSFER_METHOD_PROFILE_TYPE", "INDIVIDUAL");
7980
return intent;
8081
}
8182
};

ui/src/androidTest/java/com/hyperwallet/android/transfermethod/ui/SelectTransferMethodTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ public void unregisterIdlingResource() {
8383

8484
@Test
8585
public void testSelectTransferMethod_verifyCorrectLabelsDisplayed() {
86+
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager
87+
.getResourceContent("user_response.json")).mock();
8688
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager
8789
.getResourceContent("successful_tmc_keys_response.json")).mock();
8890

@@ -108,6 +110,8 @@ public void testSelectTransferMethod_verifyCorrectLabelsDisplayed() {
108110

109111
@Test
110112
public void testSelectTransferMethod_verifyCountrySelectionList() {
113+
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager
114+
.getResourceContent("user_response.json")).mock();
111115
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager
112116
.getResourceContent("successful_tmc_keys_response.json")).mock();
113117

@@ -130,6 +134,8 @@ public void testSelectTransferMethod_verifyCountrySelectionList() {
130134

131135
@Test
132136
public void testSelectTransferMethod_verifyCountrySelectionSearch() {
137+
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager
138+
.getResourceContent("user_response.json")).mock();
133139
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager
134140
.getResourceContent("successful_tmc_keys_large_response.json")).mock();
135141

@@ -149,6 +155,9 @@ public void testSelectTransferMethod_verifyCountrySelectionSearch() {
149155

150156
@Test
151157
public void testSelectTransferMethod_verifyCurrencySelectionList() {
158+
159+
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager
160+
.getResourceContent("user_response.json")).mock();
152161
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager
153162
.getResourceContent("successful_tmc_keys_response.json")).mock();
154163

@@ -172,6 +181,8 @@ public void testSelectTransferMethod_verifyCurrencySelectionList() {
172181

173182
@Test
174183
public void testSelectTransferMethod_verifyTransferMethodsList() {
184+
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager
185+
.getResourceContent("user_response.json")).mock();
175186
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager
176187
.getResourceContent("successful_tmc_keys_response.json")).mock();
177188

@@ -201,6 +212,8 @@ public void testSelectTransferMethod_verifyTransferMethodsList() {
201212

202213
@Test
203214
public void testSelectTransferMethod_verifyTransferMethodsListEmptyFee() {
215+
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager
216+
.getResourceContent("user_response.json")).mock();
204217
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager
205218
.getResourceContent("successful_tmc_keys_empty_fee_response.json")).mock();
206219

@@ -223,6 +236,8 @@ public void testSelectTransferMethod_verifyTransferMethodsListEmptyFee() {
223236

224237
@Test
225238
public void testSelectTransferMethod_verifyTransferMethodsListEmptyProcessing() {
239+
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager
240+
.getResourceContent("user_response.json")).mock();
226241
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager
227242
.getResourceContent("successful_tmc_keys_empty_processing_response.json")).mock();
228243

@@ -245,6 +260,8 @@ public void testSelectTransferMethod_verifyTransferMethodsListEmptyProcessing()
245260

246261
@Test
247262
public void testSelectTransferMethod_verifyTransferMethodsListUpdatedOnSelectionChange() {
263+
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager
264+
.getResourceContent("user_response.json")).mock();
248265
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager
249266
.getResourceContent("successful_tmc_keys_response.json")).mock();
250267

@@ -271,6 +288,8 @@ public void testSelectTransferMethod_verifyTransferMethodsListUpdatedOnSelection
271288

272289
@Test
273290
public void testSelectTransferMethod_clickBankAccountOpensAddTransferMethodUi() {
291+
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager
292+
.getResourceContent("user_response.json")).mock();
274293
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager
275294
.getResourceContent("successful_tmc_keys_response.json")).mock();
276295
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager
@@ -286,6 +305,8 @@ public void testSelectTransferMethod_clickBankAccountOpensAddTransferMethodUi()
286305

287306
@Test
288307
public void testSelectTransferMethod_clickBankCardOpensAddTransferMethodUi() {
308+
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager
309+
.getResourceContent("user_response.json")).mock();
289310
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager
290311
.getResourceContent("successful_tmc_keys_response.json")).mock();
291312
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager

ui/src/main/java/com/hyperwallet/android/ui/HyperwalletUi.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import static com.hyperwallet.android.ui.transfermethod.AddTransferMethodActivity.EXTRA_TRANSFER_METHOD_COUNTRY;
2323
import static com.hyperwallet.android.ui.transfermethod.AddTransferMethodActivity.EXTRA_TRANSFER_METHOD_CURRENCY;
24+
import static com.hyperwallet.android.ui.transfermethod.AddTransferMethodActivity.EXTRA_TRANSFER_METHOD_PROFILE_TYPE;
2425
import static com.hyperwallet.android.ui.transfermethod.AddTransferMethodActivity.EXTRA_TRANSFER_METHOD_TYPE;
2526

2627
import android.content.Context;
@@ -84,14 +85,18 @@ public Intent getIntentSelectTransferMethodActivity(@NonNull final Context conte
8485
* @param currency The transfer method currency code. ISO 4217 format.
8586
* @param transferMethodType The type of transfer method. For a complete list of transfer methods, see {@link
8687
* com.hyperwallet.android.model.HyperwalletTransferMethod.TransferMethodTypes}
88+
* @param profileType The type of the account holder profile. For a complete list of options, see
89+
* {@link com.hyperwallet.android.model.HyperwalletUser.ProfileTypes}
8790
* @return an Intent with the data necessary to launch the {@link AddTransferMethodActivity}
8891
*/
8992
public Intent getIntentAddTransferMethodActivity(@NonNull final Context context, @NonNull final String country,
90-
@NonNull final String currency, @NonNull final String transferMethodType) {
93+
@NonNull final String currency, @NonNull final String transferMethodType,
94+
@NonNull final String profileType) {
9195
Intent intent = new Intent(context, AddTransferMethodActivity.class);
9296
intent.putExtra(EXTRA_TRANSFER_METHOD_COUNTRY, country);
9397
intent.putExtra(EXTRA_TRANSFER_METHOD_CURRENCY, currency);
9498
intent.putExtra(EXTRA_TRANSFER_METHOD_TYPE, transferMethodType);
99+
intent.putExtra(EXTRA_TRANSFER_METHOD_PROFILE_TYPE, profileType);
95100
return intent;
96101
}
97102

ui/src/main/java/com/hyperwallet/android/ui/repository/RepositoryFactory.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ public class RepositoryFactory {
3131
private static RepositoryFactory sInstance;
3232
private TransferMethodConfigurationRepository mTransferMethodConfigurationRepository;
3333
private TransferMethodRepository mTransferMethodRepository;
34+
private UserRepository mUserRepository;
3435

3536
private RepositoryFactory() {
3637
mTransferMethodConfigurationRepository = new TransferMethodConfigurationRepositoryImpl();
3738
mTransferMethodRepository = new TransferMethodRepositoryImpl();
39+
mUserRepository = new UserRepositoryImpl();
3840
}
3941

4042
public static synchronized RepositoryFactory getInstance() {
@@ -52,6 +54,10 @@ public TransferMethodRepository getTransferMethodRepository() {
5254
return mTransferMethodRepository;
5355
}
5456

57+
public UserRepository getUserRepository() {
58+
return mUserRepository;
59+
}
60+
5561
public static void clearInstance() {
5662
sInstance = null;
5763
}

ui/src/main/java/com/hyperwallet/android/ui/repository/TransferMethodConfigurationRepository.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ public interface TransferMethodConfigurationRepository {
3939
void getKeys(@NonNull final LoadKeysCallback loadKeysCallback);
4040

4141
void getFields(@NonNull final String country, @NonNull final String currency,
42-
@NonNull final String transferMethodType, @NonNull final LoadFieldsCallback loadFieldsCallback);
42+
@NonNull final String transferMethodType, @NonNull final String transferMethodProfileType,
43+
@NonNull final LoadFieldsCallback loadFieldsCallback);
4344

4445
void refreshKeys();
4546

ui/src/main/java/com/hyperwallet/android/ui/repository/TransferMethodConfigurationRepositoryImpl.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
import java.util.Objects;
4848

4949
public class TransferMethodConfigurationRepositoryImpl implements TransferMethodConfigurationRepository {
50-
private static final String INDIVIDUAL = "INDIVIDUAL";
5150
private HyperwalletTransferMethodConfigurationKeyResult mTransferMethodConfigurationKeyResult;
5251
private final Handler mHandler;
5352
private final Map<FieldMapKey, HyperwalletTransferMethodConfigurationFieldResult> mFieldMap;
@@ -104,9 +103,11 @@ public Handler getHandler() {
104103
void getTransferMethodConfigurationFieldResult(@NonNull final String country,
105104
@NonNull final String currency,
106105
@NonNull final String transferMethodType,
106+
@NonNull final String transferMethodProfileType,
107107
@NonNull final LoadFieldsCallback loadFieldsCallback) {
108108
HyperwalletTransferMethodConfigurationFieldQuery query =
109-
new HyperwalletTransferMethodConfigurationFieldQuery(country, currency, transferMethodType, INDIVIDUAL);
109+
new HyperwalletTransferMethodConfigurationFieldQuery(country, currency, transferMethodType,
110+
transferMethodProfileType);
110111
EspressoIdlingResource.increment();
111112

112113
getHyperwallet().retrieveTransferMethodConfigurationFields(
@@ -146,14 +147,15 @@ public synchronized void getKeys(@NonNull final LoadKeysCallback loadKeysCallbac
146147
@Override
147148
public synchronized void getFields(@NonNull final String country, @NonNull final String currency,
148149
@NonNull final String transferMethodType,
150+
@NonNull final String transferMethodProfileType,
149151
@NonNull final LoadFieldsCallback loadFieldsCallback) {
150152
FieldMapKey fieldMapKey = new FieldMapKey(country, currency, transferMethodType);
151153
HyperwalletTransferMethodConfigurationFieldResult transferMethodConfigurationFieldResult = mFieldMap.get(
152154
fieldMapKey);
153155
// if there is no value for country-currency-type combination,
154156
// it means api call was never made or this combination or it was refreshed
155157
if (transferMethodConfigurationFieldResult == null) {
156-
getTransferMethodConfigurationFieldResult(country, currency, transferMethodType, loadFieldsCallback);
158+
getTransferMethodConfigurationFieldResult(country, currency, transferMethodType, transferMethodProfileType, loadFieldsCallback);
157159
} else {
158160
loadFieldsCallback.onFieldsLoaded(transferMethodConfigurationFieldResult);
159161
}

0 commit comments

Comments
 (0)