diff --git a/ui/build.gradle b/ui/build.gradle index f7328be25..b31b0e293 100644 --- a/ui/build.gradle +++ b/ui/build.gradle @@ -22,10 +22,13 @@ android { } buildTypes { - dev { + release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } + debug { + testCoverageEnabled true + } } lintOptions { diff --git a/ui/config/jacoco-settings.gradle b/ui/config/jacoco-settings.gradle index 1a29fbfa8..c810d1d89 100644 --- a/ui/config/jacoco-settings.gradle +++ b/ui/config/jacoco-settings.gradle @@ -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.' @@ -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) diff --git a/ui/src/androidTest/java/com/hyperwallet/android/transfermethod/ui/BankAccountTest.java b/ui/src/androidTest/java/com/hyperwallet/android/transfermethod/ui/BankAccountTest.java index 72594174c..3a48ac15e 100644 --- a/ui/src/androidTest/java/com/hyperwallet/android/transfermethod/ui/BankAccountTest.java +++ b/ui/src/androidTest/java/com/hyperwallet/android/transfermethod/ui/BankAccountTest.java @@ -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; } }; diff --git a/ui/src/androidTest/java/com/hyperwallet/android/transfermethod/ui/BankCardTest.java b/ui/src/androidTest/java/com/hyperwallet/android/transfermethod/ui/BankCardTest.java index b3cfa405e..8f05f330d 100644 --- a/ui/src/androidTest/java/com/hyperwallet/android/transfermethod/ui/BankCardTest.java +++ b/ui/src/androidTest/java/com/hyperwallet/android/transfermethod/ui/BankCardTest.java @@ -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; } }; diff --git a/ui/src/androidTest/java/com/hyperwallet/android/transfermethod/ui/PayPalTest.java b/ui/src/androidTest/java/com/hyperwallet/android/transfermethod/ui/PayPalTest.java index 40574449f..6bf0ec8bd 100644 --- a/ui/src/androidTest/java/com/hyperwallet/android/transfermethod/ui/PayPalTest.java +++ b/ui/src/androidTest/java/com/hyperwallet/android/transfermethod/ui/PayPalTest.java @@ -76,6 +76,7 @@ protected Intent getActivityIntent() { intent.putExtra("TRANSFER_METHOD_TYPE", "PAYPAL_ACCOUNT"); intent.putExtra("TRANSFER_METHOD_COUNTRY", "US"); intent.putExtra("TRANSFER_METHOD_CURRENCY", "USD"); + intent.putExtra("TRANSFER_METHOD_PROFILE_TYPE", "INDIVIDUAL"); return intent; } }; diff --git a/ui/src/androidTest/java/com/hyperwallet/android/transfermethod/ui/SelectTransferMethodTest.java b/ui/src/androidTest/java/com/hyperwallet/android/transfermethod/ui/SelectTransferMethodTest.java index 45ab1f01f..74ac12220 100644 --- a/ui/src/androidTest/java/com/hyperwallet/android/transfermethod/ui/SelectTransferMethodTest.java +++ b/ui/src/androidTest/java/com/hyperwallet/android/transfermethod/ui/SelectTransferMethodTest.java @@ -83,6 +83,8 @@ public void unregisterIdlingResource() { @Test public void testSelectTransferMethod_verifyCorrectLabelsDisplayed() { + mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager + .getResourceContent("user_response.json")).mock(); mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager .getResourceContent("successful_tmc_keys_response.json")).mock(); @@ -108,6 +110,8 @@ public void testSelectTransferMethod_verifyCorrectLabelsDisplayed() { @Test public void testSelectTransferMethod_verifyCountrySelectionList() { + mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager + .getResourceContent("user_response.json")).mock(); mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager .getResourceContent("successful_tmc_keys_response.json")).mock(); @@ -130,6 +134,8 @@ public void testSelectTransferMethod_verifyCountrySelectionList() { @Test public void testSelectTransferMethod_verifyCountrySelectionSearch() { + mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager + .getResourceContent("user_response.json")).mock(); mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager .getResourceContent("successful_tmc_keys_large_response.json")).mock(); @@ -149,6 +155,9 @@ public void testSelectTransferMethod_verifyCountrySelectionSearch() { @Test public void testSelectTransferMethod_verifyCurrencySelectionList() { + + mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager + .getResourceContent("user_response.json")).mock(); mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager .getResourceContent("successful_tmc_keys_response.json")).mock(); @@ -172,6 +181,8 @@ public void testSelectTransferMethod_verifyCurrencySelectionList() { @Test public void testSelectTransferMethod_verifyTransferMethodsList() { + mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager + .getResourceContent("user_response.json")).mock(); mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager .getResourceContent("successful_tmc_keys_response.json")).mock(); @@ -201,6 +212,8 @@ public void testSelectTransferMethod_verifyTransferMethodsList() { @Test public void testSelectTransferMethod_verifyTransferMethodsListEmptyFee() { + mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager + .getResourceContent("user_response.json")).mock(); mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager .getResourceContent("successful_tmc_keys_empty_fee_response.json")).mock(); @@ -223,6 +236,8 @@ public void testSelectTransferMethod_verifyTransferMethodsListEmptyFee() { @Test public void testSelectTransferMethod_verifyTransferMethodsListEmptyProcessing() { + mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager + .getResourceContent("user_response.json")).mock(); mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager .getResourceContent("successful_tmc_keys_empty_processing_response.json")).mock(); @@ -245,6 +260,8 @@ public void testSelectTransferMethod_verifyTransferMethodsListEmptyProcessing() @Test public void testSelectTransferMethod_verifyTransferMethodsListUpdatedOnSelectionChange() { + mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager + .getResourceContent("user_response.json")).mock(); mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager .getResourceContent("successful_tmc_keys_response.json")).mock(); @@ -271,6 +288,8 @@ public void testSelectTransferMethod_verifyTransferMethodsListUpdatedOnSelection @Test public void testSelectTransferMethod_clickBankAccountOpensAddTransferMethodUi() { + mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager + .getResourceContent("user_response.json")).mock(); mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager .getResourceContent("successful_tmc_keys_response.json")).mock(); mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager @@ -286,6 +305,8 @@ public void testSelectTransferMethod_clickBankAccountOpensAddTransferMethodUi() @Test public void testSelectTransferMethod_clickBankCardOpensAddTransferMethodUi() { + mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager + .getResourceContent("user_response.json")).mock(); mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager .getResourceContent("successful_tmc_keys_response.json")).mock(); mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager diff --git a/ui/src/main/java/com/hyperwallet/android/ui/HyperwalletUi.java b/ui/src/main/java/com/hyperwallet/android/ui/HyperwalletUi.java index 666a2ef6c..4c5759831 100644 --- a/ui/src/main/java/com/hyperwallet/android/ui/HyperwalletUi.java +++ b/ui/src/main/java/com/hyperwallet/android/ui/HyperwalletUi.java @@ -21,6 +21,7 @@ import static com.hyperwallet.android.ui.transfermethod.AddTransferMethodActivity.EXTRA_TRANSFER_METHOD_COUNTRY; import static com.hyperwallet.android.ui.transfermethod.AddTransferMethodActivity.EXTRA_TRANSFER_METHOD_CURRENCY; +import static com.hyperwallet.android.ui.transfermethod.AddTransferMethodActivity.EXTRA_TRANSFER_METHOD_PROFILE_TYPE; import static com.hyperwallet.android.ui.transfermethod.AddTransferMethodActivity.EXTRA_TRANSFER_METHOD_TYPE; import android.content.Context; @@ -84,14 +85,18 @@ public Intent getIntentSelectTransferMethodActivity(@NonNull final Context conte * @param currency The transfer method currency code. ISO 4217 format. * @param transferMethodType The type of transfer method. For a complete list of transfer methods, see {@link * com.hyperwallet.android.model.HyperwalletTransferMethod.TransferMethodTypes} + * @param profileType The type of the account holder profile. For a complete list of options, see + * {@link com.hyperwallet.android.model.HyperwalletUser.ProfileTypes} * @return an Intent with the data necessary to launch the {@link AddTransferMethodActivity} */ public Intent getIntentAddTransferMethodActivity(@NonNull final Context context, @NonNull final String country, - @NonNull final String currency, @NonNull final String transferMethodType) { + @NonNull final String currency, @NonNull final String transferMethodType, + @NonNull final String profileType) { Intent intent = new Intent(context, AddTransferMethodActivity.class); intent.putExtra(EXTRA_TRANSFER_METHOD_COUNTRY, country); intent.putExtra(EXTRA_TRANSFER_METHOD_CURRENCY, currency); intent.putExtra(EXTRA_TRANSFER_METHOD_TYPE, transferMethodType); + intent.putExtra(EXTRA_TRANSFER_METHOD_PROFILE_TYPE, profileType); return intent; } diff --git a/ui/src/main/java/com/hyperwallet/android/ui/repository/RepositoryFactory.java b/ui/src/main/java/com/hyperwallet/android/ui/repository/RepositoryFactory.java index ee5b44ea3..ec2a3a935 100644 --- a/ui/src/main/java/com/hyperwallet/android/ui/repository/RepositoryFactory.java +++ b/ui/src/main/java/com/hyperwallet/android/ui/repository/RepositoryFactory.java @@ -31,10 +31,12 @@ public class RepositoryFactory { private static RepositoryFactory sInstance; private TransferMethodConfigurationRepository mTransferMethodConfigurationRepository; private TransferMethodRepository mTransferMethodRepository; + private UserRepository mUserRepository; private RepositoryFactory() { mTransferMethodConfigurationRepository = new TransferMethodConfigurationRepositoryImpl(); mTransferMethodRepository = new TransferMethodRepositoryImpl(); + mUserRepository = new UserRepositoryImpl(); } public static synchronized RepositoryFactory getInstance() { @@ -52,6 +54,10 @@ public TransferMethodRepository getTransferMethodRepository() { return mTransferMethodRepository; } + public UserRepository getUserRepository() { + return mUserRepository; + } + public static void clearInstance() { sInstance = null; } diff --git a/ui/src/main/java/com/hyperwallet/android/ui/repository/TransferMethodConfigurationRepository.java b/ui/src/main/java/com/hyperwallet/android/ui/repository/TransferMethodConfigurationRepository.java index e89c8bab5..bea52cb18 100644 --- a/ui/src/main/java/com/hyperwallet/android/ui/repository/TransferMethodConfigurationRepository.java +++ b/ui/src/main/java/com/hyperwallet/android/ui/repository/TransferMethodConfigurationRepository.java @@ -39,7 +39,8 @@ public interface TransferMethodConfigurationRepository { void getKeys(@NonNull final LoadKeysCallback loadKeysCallback); void getFields(@NonNull final String country, @NonNull final String currency, - @NonNull final String transferMethodType, @NonNull final LoadFieldsCallback loadFieldsCallback); + @NonNull final String transferMethodType, @NonNull final String transferMethodProfileType, + @NonNull final LoadFieldsCallback loadFieldsCallback); void refreshKeys(); diff --git a/ui/src/main/java/com/hyperwallet/android/ui/repository/TransferMethodConfigurationRepositoryImpl.java b/ui/src/main/java/com/hyperwallet/android/ui/repository/TransferMethodConfigurationRepositoryImpl.java index 008c87176..89aa23f59 100644 --- a/ui/src/main/java/com/hyperwallet/android/ui/repository/TransferMethodConfigurationRepositoryImpl.java +++ b/ui/src/main/java/com/hyperwallet/android/ui/repository/TransferMethodConfigurationRepositoryImpl.java @@ -47,7 +47,6 @@ import java.util.Objects; public class TransferMethodConfigurationRepositoryImpl implements TransferMethodConfigurationRepository { - private static final String INDIVIDUAL = "INDIVIDUAL"; private HyperwalletTransferMethodConfigurationKeyResult mTransferMethodConfigurationKeyResult; private final Handler mHandler; private final Map mFieldMap; @@ -104,9 +103,11 @@ public Handler getHandler() { void getTransferMethodConfigurationFieldResult(@NonNull final String country, @NonNull final String currency, @NonNull final String transferMethodType, + @NonNull final String transferMethodProfileType, @NonNull final LoadFieldsCallback loadFieldsCallback) { HyperwalletTransferMethodConfigurationFieldQuery query = - new HyperwalletTransferMethodConfigurationFieldQuery(country, currency, transferMethodType, INDIVIDUAL); + new HyperwalletTransferMethodConfigurationFieldQuery(country, currency, transferMethodType, + transferMethodProfileType); EspressoIdlingResource.increment(); getHyperwallet().retrieveTransferMethodConfigurationFields( @@ -146,6 +147,7 @@ public synchronized void getKeys(@NonNull final LoadKeysCallback loadKeysCallbac @Override public synchronized void getFields(@NonNull final String country, @NonNull final String currency, @NonNull final String transferMethodType, + @NonNull final String transferMethodProfileType, @NonNull final LoadFieldsCallback loadFieldsCallback) { FieldMapKey fieldMapKey = new FieldMapKey(country, currency, transferMethodType); HyperwalletTransferMethodConfigurationFieldResult transferMethodConfigurationFieldResult = mFieldMap.get( @@ -153,7 +155,7 @@ public synchronized void getFields(@NonNull final String country, @NonNull final // if there is no value for country-currency-type combination, // it means api call was never made or this combination or it was refreshed if (transferMethodConfigurationFieldResult == null) { - getTransferMethodConfigurationFieldResult(country, currency, transferMethodType, loadFieldsCallback); + getTransferMethodConfigurationFieldResult(country, currency, transferMethodType, transferMethodProfileType, loadFieldsCallback); } else { loadFieldsCallback.onFieldsLoaded(transferMethodConfigurationFieldResult); } diff --git a/ui/src/main/java/com/hyperwallet/android/ui/repository/UserRepository.java b/ui/src/main/java/com/hyperwallet/android/ui/repository/UserRepository.java new file mode 100644 index 000000000..902a8d13b --- /dev/null +++ b/ui/src/main/java/com/hyperwallet/android/ui/repository/UserRepository.java @@ -0,0 +1,57 @@ +/* + * Copyright 2018 Hyperwallet + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO + * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.hyperwallet.android.ui.repository; + +import androidx.annotation.NonNull; + +import com.hyperwallet.android.model.HyperwalletErrors; +import com.hyperwallet.android.model.HyperwalletUser; + +/** + * User Repository Contract + */ +public interface UserRepository { + /** + * Load user information + * + * @param callback @see {@link UserRepository.LoadUserCallback} + */ + void loadUser(@NonNull final LoadUserCallback callback); + + /** + * Set user to null + */ + void refreshUser(); + + /** + * Callback interface that responses to action when invoked to + * Load User information + *

+ * When User is properly loaded + * {@link UserRepository.LoadUserCallback#onUserLoaded(HyperwalletUser)} + * is invoked otherwise {@link UserRepository.LoadUserCallback#onError(HyperwalletErrors)} + * is called to further log or show error information + */ + interface LoadUserCallback { + + void onUserLoaded(@NonNull final HyperwalletUser user); + + void onError(@NonNull final HyperwalletErrors errors); + } +} diff --git a/ui/src/main/java/com/hyperwallet/android/ui/repository/UserRepositoryImpl.java b/ui/src/main/java/com/hyperwallet/android/ui/repository/UserRepositoryImpl.java new file mode 100644 index 000000000..561d4cf85 --- /dev/null +++ b/ui/src/main/java/com/hyperwallet/android/ui/repository/UserRepositoryImpl.java @@ -0,0 +1,71 @@ +/* + * Copyright 2018 Hyperwallet + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO + * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.hyperwallet.android.ui.repository; + +import android.os.Handler; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.annotation.VisibleForTesting; + +import com.hyperwallet.android.Hyperwallet; +import com.hyperwallet.android.exception.HyperwalletException; +import com.hyperwallet.android.listener.HyperwalletListener; +import com.hyperwallet.android.model.HyperwalletUser; + +public class UserRepositoryImpl implements UserRepository { + + private Handler mHandler = new Handler(); + private HyperwalletUser mUser; + + @VisibleForTesting + Hyperwallet getHyperwallet() { + return Hyperwallet.getDefault(); + } + + @Override + public void loadUser(@NonNull final LoadUserCallback callback) { + if (mUser == null) { + getHyperwallet().getUser(new HyperwalletListener() { + @Override + public void onSuccess(@Nullable HyperwalletUser result) { + mUser = result; + callback.onUserLoaded(mUser); + } + + @Override + public void onFailure(HyperwalletException exception) { + callback.onError(exception.getHyperwalletErrors()); + } + + @Override + public Handler getHandler() { + return mHandler; + } + }); + } else { + callback.onUserLoaded(mUser); + } + } + + @Override + public void refreshUser() { + mUser = null; + } +} diff --git a/ui/src/main/java/com/hyperwallet/android/ui/transfermethod/AddTransferMethodActivity.java b/ui/src/main/java/com/hyperwallet/android/ui/transfermethod/AddTransferMethodActivity.java index 5e6fcba75..381446c7a 100644 --- a/ui/src/main/java/com/hyperwallet/android/ui/transfermethod/AddTransferMethodActivity.java +++ b/ui/src/main/java/com/hyperwallet/android/ui/transfermethod/AddTransferMethodActivity.java @@ -45,6 +45,7 @@ public class AddTransferMethodActivity extends AppCompatActivity implements public static final String EXTRA_TRANSFER_METHOD_COUNTRY = "TRANSFER_METHOD_COUNTRY"; public static final String EXTRA_TRANSFER_METHOD_CURRENCY = "TRANSFER_METHOD_CURRENCY"; public static final String EXTRA_TRANSFER_METHOD_TYPE = "TRANSFER_METHOD_TYPE"; + public static final String EXTRA_TRANSFER_METHOD_PROFILE_TYPE = "TRANSFER_METHOD_PROFILE_TYPE"; public static final int REQUEST_CODE = 100; private static final String ARGUMENT_RETRY_ACTION = "ARGUMENT_RETRY_ACTION"; private static final short RETRY_SHOW_ERROR_ADD_TRANSFER_METHOD = 100; @@ -75,7 +76,9 @@ public void onClick(View v) { initFragment(AddTransferMethodFragment.newInstance( getIntent().getStringExtra(EXTRA_TRANSFER_METHOD_COUNTRY), getIntent().getStringExtra(EXTRA_TRANSFER_METHOD_CURRENCY), - getIntent().getStringExtra(EXTRA_TRANSFER_METHOD_TYPE))); + getIntent().getStringExtra(EXTRA_TRANSFER_METHOD_TYPE), + getIntent().getStringExtra(EXTRA_TRANSFER_METHOD_PROFILE_TYPE) + )); } else { mRetryCode = savedInstanceState.getShort(ARGUMENT_RETRY_ACTION); } @@ -181,7 +184,9 @@ private AddTransferMethodFragment getAddTransferMethodFragment() { fragment = AddTransferMethodFragment.newInstance( getIntent().getStringExtra(EXTRA_TRANSFER_METHOD_COUNTRY), getIntent().getStringExtra(EXTRA_TRANSFER_METHOD_CURRENCY), - getIntent().getStringExtra(EXTRA_TRANSFER_METHOD_TYPE)); + getIntent().getStringExtra(EXTRA_TRANSFER_METHOD_TYPE), + getIntent().getStringExtra(EXTRA_TRANSFER_METHOD_PROFILE_TYPE) + ); } return fragment; } diff --git a/ui/src/main/java/com/hyperwallet/android/ui/transfermethod/AddTransferMethodContract.java b/ui/src/main/java/com/hyperwallet/android/ui/transfermethod/AddTransferMethodContract.java index 6b2d136ba..93f3aa9da 100644 --- a/ui/src/main/java/com/hyperwallet/android/ui/transfermethod/AddTransferMethodContract.java +++ b/ui/src/main/java/com/hyperwallet/android/ui/transfermethod/AddTransferMethodContract.java @@ -71,6 +71,7 @@ interface Presenter { void loadTransferMethodConfigurationFields(boolean forceUpdate, @NonNull String country, @NonNull String currency, - @NonNull String transferMethodType); + @NonNull String transferMethodType, + @NonNull String transferMethodProfileType); } } diff --git a/ui/src/main/java/com/hyperwallet/android/ui/transfermethod/AddTransferMethodFragment.java b/ui/src/main/java/com/hyperwallet/android/ui/transfermethod/AddTransferMethodFragment.java index 28d977e7a..2507c3eed 100644 --- a/ui/src/main/java/com/hyperwallet/android/ui/transfermethod/AddTransferMethodFragment.java +++ b/ui/src/main/java/com/hyperwallet/android/ui/transfermethod/AddTransferMethodFragment.java @@ -71,6 +71,7 @@ public class AddTransferMethodFragment extends Fragment implements WidgetEventLi private static final String ARGUMENT_TRANSFER_METHOD_COUNTRY = "ARGUMENT_TRANSFER_METHOD_COUNTRY"; private static final String ARGUMENT_TRANSFER_METHOD_CURRENCY = "ARGUMENT_TRANSFER_METHOD_CURRENCY"; private static final String ARGUMENT_TRANSFER_METHOD_TYPE = "ARGUMENT_TRANSFER_METHOD_TYPE"; + private static final String ARGUMENT_TRANSFER_METHOD_PROFILE_TYPE = "ARGUMENT_TRANSFER_METHOD_PROFILE_TYPE"; private static final String ARGUMENT_SHOW_CREATE_PROGRESS_BAR = "ARGUMENT_SHOW_CREATE_PROGRESS_BAR"; private static final String ARGUMENT_TRANSFER_METHOD = "ARGUMENT_TRANSFER_METHOD"; private static final String ARGUMENT_WIDGET_STATE_MAP = "ARGUMENT_WIDGET_STATE_MAP"; @@ -89,6 +90,7 @@ public class AddTransferMethodFragment extends Fragment implements WidgetEventLi private boolean mShowCreateProgressBar; private String mTransferMethodType; private HyperwalletTransferMethod mTransferMethod; + private String mTransferMethodProfileType; private HashMap mWidgetInputStateHashMap; private TextView sectionHeaderTextView; @@ -101,28 +103,33 @@ public AddTransferMethodFragment() { /** * Creates new instance of AddTransferMethodFragment this is the proper initialization of this class * since the default constructor is reserved for android framework when lifecycle is triggered. - * The parameters in {@link AddTransferMethodFragment#newInstance(String, String, String)} is mandatory + * The parameters in {@link AddTransferMethodFragment#newInstance(String, String, String, String)} is mandatory * and should be supplied with correct data or this fragment will not initialize properly. * - * @param transferMethodCountry the country selected when creating transfer method - * @param transferMethodCurrency the currency selected when creating transfer method - * @param transferMethodType the type of transfer method needed to create transfer method + * @param transferMethodCountry the country selected when creating transfer method + * @param transferMethodCurrency the currency selected when creating transfer method + * @param transferMethodType the type of transfer method needed to create transfer method + * @param transferMethodProfileType the type of transfer method profile needed to create transfer method */ public static AddTransferMethodFragment newInstance(@NonNull String transferMethodCountry, @NonNull String transferMethodCurrency, - @NonNull String transferMethodType) { + @NonNull String transferMethodType, + @NonNull String transferMethodProfileType) { AddTransferMethodFragment addTransferMethodFragment = new AddTransferMethodFragment(); Bundle arguments = new Bundle(); addTransferMethodFragment.mCountry = transferMethodCountry; addTransferMethodFragment.mTransferMethodType = transferMethodType; addTransferMethodFragment.mCurrency = transferMethodCurrency; + addTransferMethodFragment.mTransferMethodProfileType = transferMethodProfileType; addTransferMethodFragment.mWidgetInputStateHashMap = new HashMap<>(1); addTransferMethodFragment.mTransferMethod = null; arguments.putString(ARGUMENT_TRANSFER_METHOD_COUNTRY, addTransferMethodFragment.mCountry); arguments.putString(ARGUMENT_TRANSFER_METHOD_CURRENCY, addTransferMethodFragment.mCurrency); arguments.putString(ARGUMENT_TRANSFER_METHOD_TYPE, addTransferMethodFragment.mTransferMethodType); + arguments.putString(ARGUMENT_TRANSFER_METHOD_PROFILE_TYPE, + addTransferMethodFragment.mTransferMethodProfileType); arguments.putParcelable(ARGUMENT_TRANSFER_METHOD, addTransferMethodFragment.mTransferMethod); arguments.putSerializable(ARGUMENT_WIDGET_STATE_MAP, addTransferMethodFragment.mWidgetInputStateHashMap); addTransferMethodFragment.setArguments(arguments); @@ -222,7 +229,8 @@ public void onViewStateRestored(@Nullable Bundle savedInstanceState) { @Override public void onResume() { super.onResume(); - mPresenter.loadTransferMethodConfigurationFields(FORCE_UPDATE, mCountry, mCurrency, mTransferMethodType); + mPresenter.loadTransferMethodConfigurationFields(FORCE_UPDATE, mCountry, mCurrency, mTransferMethodType, + mTransferMethodProfileType); } @Override @@ -254,7 +262,8 @@ public void retryAddTransferMethod() { @Override public void reloadTransferMethodConfigurationFields() { - mPresenter.loadTransferMethodConfigurationFields(FORCE_UPDATE, mCountry, mCurrency, mTransferMethodType); + mPresenter.loadTransferMethodConfigurationFields(FORCE_UPDATE, mCountry, mCurrency, mTransferMethodType, + mTransferMethodProfileType); } @Override diff --git a/ui/src/main/java/com/hyperwallet/android/ui/transfermethod/AddTransferMethodPresenter.java b/ui/src/main/java/com/hyperwallet/android/ui/transfermethod/AddTransferMethodPresenter.java index dc048c1d1..73b10717d 100644 --- a/ui/src/main/java/com/hyperwallet/android/ui/transfermethod/AddTransferMethodPresenter.java +++ b/ui/src/main/java/com/hyperwallet/android/ui/transfermethod/AddTransferMethodPresenter.java @@ -75,7 +75,8 @@ public void onError(HyperwalletErrors errors) { @Override public void loadTransferMethodConfigurationFields(final boolean forceUpdate, @NonNull final String country, - @NonNull final String currency, @NonNull final String transferMethodType) { + @NonNull final String currency, @NonNull final String transferMethodType, + @NonNull final String transferMethodProfileType) { mView.showProgressBar(); if (forceUpdate) { @@ -83,7 +84,8 @@ public void loadTransferMethodConfigurationFields(final boolean forceUpdate, @No } mTransferMethodConfigurationRepository.getFields( - country, currency, transferMethodType, new TransferMethodConfigurationRepository.LoadFieldsCallback() { + country, currency, transferMethodType, transferMethodProfileType, + new TransferMethodConfigurationRepository.LoadFieldsCallback() { @Override public void onFieldsLoaded( HyperwalletTransferMethodConfigurationFieldResult transferMethodConfigurationFieldResult) { @@ -95,10 +97,11 @@ public void onFieldsLoaded( mView.showTransferMethodFields(transferMethodConfigurationFieldResult.getFields()); // there can be multiple fees when we have flat fee + percentage fees List fees = transferMethodConfigurationFieldResult - .getFees(country, currency, transferMethodType, "INDIVIDUAL"); + .getFees(country, currency, transferMethodType, transferMethodProfileType); mView.showTransactionInformation(fees, transferMethodConfigurationFieldResult - .getProcessingTime(country, currency, transferMethodType, "INDIVIDUAL")); + .getProcessingTime(country, currency, transferMethodType, + transferMethodProfileType)); } @Override diff --git a/ui/src/main/java/com/hyperwallet/android/ui/transfermethod/SelectTransferMethodContract.java b/ui/src/main/java/com/hyperwallet/android/ui/transfermethod/SelectTransferMethodContract.java index dc7538e82..ec4a747fb 100644 --- a/ui/src/main/java/com/hyperwallet/android/ui/transfermethod/SelectTransferMethodContract.java +++ b/ui/src/main/java/com/hyperwallet/android/ui/transfermethod/SelectTransferMethodContract.java @@ -38,7 +38,8 @@ public interface SelectTransferMethodContract { interface View { - void showAddTransferMethod(String country, String currency, String transferMethodType); + void showAddTransferMethod(@NonNull final String country, @NonNull final String currency, + @NonNull final String transferMethodType, @NonNull final String profileType); void showErrorLoadTransferMethodConfigurationKeys(@NonNull final List errors); @@ -95,7 +96,7 @@ void loadTransferMethodTypes(final boolean forceUpdate, @NonNull final String co @NonNull final String currencyCode); void openAddTransferMethod(@NonNull final String country, @NonNull final String currency, - @NonNull final String transferMethodType); + @NonNull final String transferMethodType, @NonNull final String profileType); void loadCountrySelection(@NonNull final String countryCode); diff --git a/ui/src/main/java/com/hyperwallet/android/ui/transfermethod/SelectTransferMethodFragment.java b/ui/src/main/java/com/hyperwallet/android/ui/transfermethod/SelectTransferMethodFragment.java index ec2f3c9ba..db873d8f7 100644 --- a/ui/src/main/java/com/hyperwallet/android/ui/transfermethod/SelectTransferMethodFragment.java +++ b/ui/src/main/java/com/hyperwallet/android/ui/transfermethod/SelectTransferMethodFragment.java @@ -174,8 +174,9 @@ public void onClick(View v) { new TransferMethodSelectionItemListener() { @Override public void onTransferMethodSelected(TransferMethodSelectionItem transferMethodType) { - mPresenter.openAddTransferMethod(mSelectedCountryCode, mSelectedCurrencyCode, - transferMethodType.getTransferMethodType()); + mPresenter.openAddTransferMethod(transferMethodType.getCountry(), + transferMethodType.getCurrency(), + transferMethodType.getTransferMethodType(), transferMethodType.getProfileType()); } }); @@ -190,7 +191,9 @@ public void onTransferMethodSelected(TransferMethodSelectionItem transferMethodT public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); RepositoryFactory factory = RepositoryFactory.getInstance(); - mPresenter = new SelectTransferMethodPresenter(this, factory.getTransferMethodConfigurationRepository()); + mPresenter = new SelectTransferMethodPresenter(this, + factory.getTransferMethodConfigurationRepository(), + factory.getUserRepository()); } @@ -286,11 +289,13 @@ public void showCurrencySelectionDialog(@NonNull final TreeMap c } @Override - public void showAddTransferMethod(String country, String currency, String transferMethodType) { + public void showAddTransferMethod(@NonNull final String country, @NonNull final String currency, + @NonNull final String transferMethodType, @NonNull final String profileType) { Intent intent = new Intent(getActivity(), AddTransferMethodActivity.class); intent.putExtra(AddTransferMethodActivity.EXTRA_TRANSFER_METHOD_COUNTRY, country); intent.putExtra(AddTransferMethodActivity.EXTRA_TRANSFER_METHOD_CURRENCY, currency); intent.putExtra(AddTransferMethodActivity.EXTRA_TRANSFER_METHOD_TYPE, transferMethodType); + intent.putExtra(AddTransferMethodActivity.EXTRA_TRANSFER_METHOD_PROFILE_TYPE, profileType); getActivity().startActivityForResult(intent, AddTransferMethodActivity.REQUEST_CODE); } diff --git a/ui/src/main/java/com/hyperwallet/android/ui/transfermethod/SelectTransferMethodPresenter.java b/ui/src/main/java/com/hyperwallet/android/ui/transfermethod/SelectTransferMethodPresenter.java index 8abdb1ce1..4524e8ff0 100644 --- a/ui/src/main/java/com/hyperwallet/android/ui/transfermethod/SelectTransferMethodPresenter.java +++ b/ui/src/main/java/com/hyperwallet/android/ui/transfermethod/SelectTransferMethodPresenter.java @@ -22,9 +22,11 @@ import androidx.annotation.Nullable; import com.hyperwallet.android.model.HyperwalletErrors; +import com.hyperwallet.android.model.HyperwalletUser; import com.hyperwallet.android.model.meta.Fee; import com.hyperwallet.android.model.meta.HyperwalletTransferMethodConfigurationKeyResult; import com.hyperwallet.android.ui.repository.TransferMethodConfigurationRepository; +import com.hyperwallet.android.ui.repository.UserRepository; import java.util.ArrayList; import java.util.Currency; @@ -33,16 +35,17 @@ import java.util.TreeMap; public class SelectTransferMethodPresenter implements SelectTransferMethodContract.Presenter { - private static final String TAG = SelectTransferMethodPresenter.class.getName(); - private static final String INDIVIDUAL = "INDIVIDUAL"; private final TransferMethodConfigurationRepository mTransferMethodConfigurationRepository; + private final UserRepository mUserRepository; private final SelectTransferMethodContract.View mView; SelectTransferMethodPresenter(SelectTransferMethodContract.View view, - TransferMethodConfigurationRepository transferMethodConfigurationRepository) { + @NonNull final TransferMethodConfigurationRepository transferMethodConfigurationRepository, + @NonNull final UserRepository userRepository) { this.mView = view; this.mTransferMethodConfigurationRepository = transferMethodConfigurationRepository; + this.mUserRepository = userRepository; } @Override @@ -55,35 +58,50 @@ public void loadTransferMethodConfigurationKeys(final boolean forceUpdate, @NonN mTransferMethodConfigurationRepository.refreshKeys(); } - mTransferMethodConfigurationRepository.getKeys(new TransferMethodConfigurationRepository.LoadKeysCallback() { + mUserRepository.loadUser(new UserRepository.LoadUserCallback() { @Override - public void onKeysLoaded( - @Nullable final HyperwalletTransferMethodConfigurationKeyResult transferMethodConfigurationKeyResult) { - if (!mView.isActive()) { - return; - } - - mView.hideProgressBar(); - List transferMethodTypes = - transferMethodConfigurationKeyResult.getTransferMethods(countryCode, currencyCode, INDIVIDUAL); - - mView.showTransferMethodCountry(countryCode); - mView.showTransferMethodCurrency(currencyCode); - mView.showTransferMethodTypes(getTransferMethodSelectionItems(countryCode, currencyCode, - transferMethodTypes, transferMethodConfigurationKeyResult)); + public void onUserLoaded(@NonNull final HyperwalletUser user) { + mTransferMethodConfigurationRepository.getKeys( + new TransferMethodConfigurationRepository.LoadKeysCallback() { + @Override + public void onKeysLoaded( + @Nullable final HyperwalletTransferMethodConfigurationKeyResult transferMethodConfigurationKeyResult) { + if (!mView.isActive()) { + return; + } + mView.hideProgressBar(); + List transferMethodTypes = + transferMethodConfigurationKeyResult.getTransferMethods(countryCode, + currencyCode, user.getProfileType()); + + mView.showTransferMethodCountry(countryCode); + mView.showTransferMethodCurrency(currencyCode); + mView.showTransferMethodTypes(getTransferMethodSelectionItems(countryCode, currencyCode, + user.getProfileType(), transferMethodTypes, transferMethodConfigurationKeyResult)); + } + + @Override + public void onError(@NonNull final HyperwalletErrors errors) { + showErrorLoadTransferMethods(errors); + } + }); } @Override - public void onError(@NonNull final HyperwalletErrors errors) { - if (!mView.isActive()) { - return; - } - mView.hideProgressBar(); - mView.showErrorLoadTransferMethodConfigurationKeys(errors.getErrors()); + public void onError(@NonNull HyperwalletErrors errors) { + showErrorLoadTransferMethods(errors); } }); } + private void showErrorLoadTransferMethods(@NonNull HyperwalletErrors errors) { + if (!mView.isActive()) { + return; + } + mView.hideProgressBar(); + mView.showErrorLoadTransferMethodConfigurationKeys(errors.getErrors()); + } + @Override public void loadCurrency(final boolean forceUpdate, @NonNull final String countryCode) { @@ -91,30 +109,47 @@ public void loadCurrency(final boolean forceUpdate, @NonNull final String countr mTransferMethodConfigurationRepository.refreshKeys(); } - mTransferMethodConfigurationRepository.getKeys(new TransferMethodConfigurationRepository.LoadKeysCallback() { + mUserRepository.loadUser(new UserRepository.LoadUserCallback() { @Override - public void onKeysLoaded(@Nullable final HyperwalletTransferMethodConfigurationKeyResult result) { - if (!mView.isActive()) { - return; - } - List transferMethodCurrencies = result.getCurrencies(countryCode); - List transferMethodTypes = result.getTransferMethods( - countryCode, transferMethodCurrencies.get(0), INDIVIDUAL); - - mView.showTransferMethodCountry(countryCode); - mView.showTransferMethodCurrency(transferMethodCurrencies.get(0)); - mView.showTransferMethodTypes(getTransferMethodSelectionItems(countryCode, - transferMethodCurrencies.get(0), transferMethodTypes, result)); + public void onUserLoaded(@NonNull final HyperwalletUser user) { + mTransferMethodConfigurationRepository.getKeys( + new TransferMethodConfigurationRepository.LoadKeysCallback() { + @Override + public void onKeysLoaded( + @Nullable final HyperwalletTransferMethodConfigurationKeyResult result) { + if (!mView.isActive()) { + return; + } + List transferMethodCurrencies = result.getCurrencies(countryCode); + List transferMethodTypes = result.getTransferMethods( + countryCode, transferMethodCurrencies.get(0), user.getProfileType()); + + mView.showTransferMethodCountry(countryCode); + mView.showTransferMethodCurrency(transferMethodCurrencies.get(0)); + mView.showTransferMethodTypes(getTransferMethodSelectionItems(countryCode, + transferMethodCurrencies.get(0), user.getProfileType(), transferMethodTypes, result)); + } + + @Override + public void onError(@NonNull final HyperwalletErrors errors) { + showErrorLoadCurrency(errors); + } + }); } @Override - public void onError(@NonNull final HyperwalletErrors errors) { - if (!mView.isActive()) { - return; - } - mView.showErrorLoadCurrency(errors.getErrors()); + public void onError(@NonNull HyperwalletErrors errors) { + showErrorLoadCurrency(errors); } }); + + } + + private void showErrorLoadCurrency(@NonNull HyperwalletErrors errors) { + if (!mView.isActive()) { + return; + } + mView.showErrorLoadCurrency(errors.getErrors()); } @Override @@ -124,37 +159,53 @@ public void loadTransferMethodTypes(final boolean forceUpdate, mTransferMethodConfigurationRepository.refreshKeys(); } - mTransferMethodConfigurationRepository.getKeys(new TransferMethodConfigurationRepository.LoadKeysCallback() { + mUserRepository.loadUser(new UserRepository.LoadUserCallback() { @Override - public void onKeysLoaded(@Nullable final HyperwalletTransferMethodConfigurationKeyResult - transferMethodConfigurationKeyResult) { - if (!mView.isActive()) { - return; - } - - List transferMethodTypes = transferMethodConfigurationKeyResult.getTransferMethods( - countryCode, currencyCode, INDIVIDUAL); - - mView.showTransferMethodCountry(countryCode); - mView.showTransferMethodCurrency(currencyCode); - mView.showTransferMethodTypes(getTransferMethodSelectionItems(countryCode, currencyCode, - transferMethodTypes, transferMethodConfigurationKeyResult)); + public void onUserLoaded(@NonNull final HyperwalletUser user) { + mTransferMethodConfigurationRepository.getKeys( + new TransferMethodConfigurationRepository.LoadKeysCallback() { + @Override + public void onKeysLoaded(@Nullable final HyperwalletTransferMethodConfigurationKeyResult + transferMethodConfigurationKeyResult) { + if (!mView.isActive()) { + return; + } + + List transferMethodTypes = + transferMethodConfigurationKeyResult.getTransferMethods( + countryCode, currencyCode, user.getProfileType()); + + mView.showTransferMethodCountry(countryCode); + mView.showTransferMethodCurrency(currencyCode); + mView.showTransferMethodTypes(getTransferMethodSelectionItems(countryCode, currencyCode, + user.getProfileType(), transferMethodTypes, transferMethodConfigurationKeyResult)); + } + + @Override + public void onError(@NonNull final HyperwalletErrors errors) { + if (!mView.isActive()) { + return; + } + mView.showErrorLoadTransferMethodTypes(errors.getErrors()); + } + }); } @Override - public void onError(@NonNull final HyperwalletErrors errors) { + public void onError(@NonNull HyperwalletErrors errors) { if (!mView.isActive()) { return; } mView.showErrorLoadTransferMethodTypes(errors.getErrors()); } }); + } @Override public void openAddTransferMethod(@NonNull final String country, @NonNull final String currency, - @NonNull final String transferMethodType) { - mView.showAddTransferMethod(country, currency, transferMethodType); + @NonNull final String transferMethodType, @NonNull final String profileType) { + mView.showAddTransferMethod(country, currency, transferMethodType, profileType); } @Override @@ -219,17 +270,19 @@ public void onError(@NonNull final HyperwalletErrors errors) { private List getTransferMethodSelectionItems( @NonNull final String country, @NonNull final String currency, + @NonNull final String userProfileType, @NonNull final List transferMethodTypes, @NonNull final HyperwalletTransferMethodConfigurationKeyResult result) { List selectionItems = new ArrayList<>(); for (String transferMethodType : transferMethodTypes) { - List fees = result.getFees(country, currency, transferMethodType, INDIVIDUAL); - String processingTime = result.getProcessingTime(country, currency, transferMethodType, INDIVIDUAL); - TransferMethodSelectionItem data = new TransferMethodSelectionItem(country, currency, INDIVIDUAL, + List fees = result.getFees(country, currency, transferMethodType, userProfileType); + String processingTime = result.getProcessingTime(country, currency, transferMethodType, userProfileType); + TransferMethodSelectionItem data = new TransferMethodSelectionItem(country, currency, userProfileType, transferMethodType, processingTime, fees); selectionItems.add(data); } return selectionItems; } + } diff --git a/ui/src/main/java/com/hyperwallet/android/ui/transfermethod/TransferMethodSelectionItem.java b/ui/src/main/java/com/hyperwallet/android/ui/transfermethod/TransferMethodSelectionItem.java index ca5e04c9e..d065d7ac1 100644 --- a/ui/src/main/java/com/hyperwallet/android/ui/transfermethod/TransferMethodSelectionItem.java +++ b/ui/src/main/java/com/hyperwallet/android/ui/transfermethod/TransferMethodSelectionItem.java @@ -16,6 +16,8 @@ */ package com.hyperwallet.android.ui.transfermethod; +import androidx.annotation.NonNull; + import com.hyperwallet.android.model.meta.Fee; import java.util.List; @@ -27,14 +29,15 @@ public class TransferMethodSelectionItem { private final String mCurrency; private final List mFees; private final String mProcessingTime; - private final String mProfile; + private final String mProfileType; private final String mTransferMethodType; - public TransferMethodSelectionItem(String country, String currency, String profile, String transferMethodType, - String processingTime, List fees) { + public TransferMethodSelectionItem(@NonNull final String country, @NonNull final String currency, + @NonNull final String profileType, @NonNull final String transferMethodType, + @NonNull final String processingTime, @NonNull final List fees) { mCountry = country; mCurrency = currency; - mProfile = profile; + mProfileType = profileType; mTransferMethodType = transferMethodType; mProcessingTime = processingTime; mFees = fees; @@ -48,8 +51,8 @@ public String getCurrency() { return mCurrency; } - public String getProfile() { - return mProfile; + public String getProfileType() { + return mProfileType; } public String getTransferMethodType() { @@ -71,12 +74,12 @@ public boolean equals(Object o) { TransferMethodSelectionItem that = (TransferMethodSelectionItem) o; return Objects.equals(mCountry, that.mCountry) && Objects.equals(mCurrency, that.mCurrency) && - Objects.equals(mProfile, that.mProfile) && + Objects.equals(mProfileType, that.mProfileType) && Objects.equals(mTransferMethodType, that.mTransferMethodType); } @Override public int hashCode() { - return Objects.hash(mCountry, mCurrency, mProfile, mTransferMethodType); + return Objects.hash(mCountry, mCurrency, mProfileType, mTransferMethodType); } } diff --git a/ui/src/test/java/com/hyperwallet/android/ui/repository/TransferMethodConfigurationRepositoryImplTest.java b/ui/src/test/java/com/hyperwallet/android/ui/repository/TransferMethodConfigurationRepositoryImplTest.java index c89e2d298..ee6bd294e 100644 --- a/ui/src/test/java/com/hyperwallet/android/ui/repository/TransferMethodConfigurationRepositoryImplTest.java +++ b/ui/src/test/java/com/hyperwallet/android/ui/repository/TransferMethodConfigurationRepositoryImplTest.java @@ -13,6 +13,8 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import static com.hyperwallet.android.model.HyperwalletUser.ProfileTypes.INDIVIDUAL; + import com.hyperwallet.android.Hyperwallet; import com.hyperwallet.android.exception.HyperwalletException; import com.hyperwallet.android.listener.HyperwalletListener; @@ -168,7 +170,7 @@ public Object answer(InvocationOnMock invocation) { ArgumentMatchers.any(), ArgumentMatchers.>any()); - mTransferMethodConfigurationRepositoryImplMock.getFields(COUNTRY, CURRENCY, TRANSFER_METHOD_TYPE, + mTransferMethodConfigurationRepositoryImplMock.getFields(COUNTRY, CURRENCY, TRANSFER_METHOD_TYPE, INDIVIDUAL, loadFieldsCallback); verify(loadFieldsCallback).onFieldsLoaded(fieldResultArgumentCaptor.capture()); @@ -204,7 +206,7 @@ public Object answer(InvocationOnMock invocation) { ArgumentMatchers.>any()); - mTransferMethodConfigurationRepositoryImplMock.getFields(COUNTRY, CURRENCY, TRANSFER_METHOD_TYPE, + mTransferMethodConfigurationRepositoryImplMock.getFields(COUNTRY, CURRENCY, TRANSFER_METHOD_TYPE, INDIVIDUAL, loadFieldsCallback); verify(loadFieldsCallback, never()).onFieldsLoaded( @@ -248,13 +250,14 @@ public void testGetFields_callsListenerWithFieldResultFromCacheWhenNotNull() thr FieldMapKey fieldMapKey = new FieldMapKey(COUNTRY, CURRENCY, TRANSFER_METHOD_TYPE); when(mFieldsMap.get(fieldMapKey)).thenReturn(result); - mTransferMethodConfigurationRepositoryImplMock.getFields(COUNTRY, CURRENCY, TRANSFER_METHOD_TYPE, + mTransferMethodConfigurationRepositoryImplMock.getFields(COUNTRY, CURRENCY, TRANSFER_METHOD_TYPE,INDIVIDUAL, loadFieldsCallback); verify(mTransferMethodConfigurationRepositoryImplMock, never()).getTransferMethodConfigurationFieldResult( any(String.class), any(String.class), any(String.class), + any(String.class), any(TransferMethodConfigurationRepository.LoadFieldsCallback.class)); verify(loadFieldsCallback).onFieldsLoaded(fieldResultArgumentCaptor.capture()); verify(loadFieldsCallback, never()).onError(any(HyperwalletErrors.class)); diff --git a/ui/src/test/java/com/hyperwallet/android/ui/repository/UserRepositoryImplTest.java b/ui/src/test/java/com/hyperwallet/android/ui/repository/UserRepositoryImplTest.java new file mode 100644 index 000000000..0f54ad10f --- /dev/null +++ b/ui/src/test/java/com/hyperwallet/android/ui/repository/UserRepositoryImplTest.java @@ -0,0 +1,197 @@ +package com.hyperwallet.android.ui.repository; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.hamcrest.Matchers.nullValue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import static com.hyperwallet.android.model.HyperwalletUser.ProfileTypes.INDIVIDUAL; +import static com.hyperwallet.android.model.HyperwalletUser.UserStatuses.PRE_ACTIVATED; +import static com.hyperwallet.android.model.HyperwalletUser.VerificationStatuses.NOT_REQUIRED; + +import com.hyperwallet.android.Hyperwallet; +import com.hyperwallet.android.exception.HyperwalletException; +import com.hyperwallet.android.listener.HyperwalletListener; +import com.hyperwallet.android.model.HyperwalletError; +import com.hyperwallet.android.model.HyperwalletErrors; +import com.hyperwallet.android.model.HyperwalletUser; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.ArgumentMatchers; +import org.mockito.Captor; +import org.mockito.Mock; +import org.mockito.Spy; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.junit.MockitoJUnit; +import org.mockito.junit.MockitoRule; +import org.mockito.stubbing.Answer; +import org.robolectric.RobolectricTestRunner; + +import java.util.ArrayList; +import java.util.List; + +@RunWith(RobolectricTestRunner.class) +public class UserRepositoryImplTest { + @Mock + private Hyperwallet mHyperwallet; + @Mock + UserRepository.LoadUserCallback mMockCallback; + @Captor + private ArgumentCaptor mErrorCaptor; + @Captor + private ArgumentCaptor mUserCaptor; + @Rule + public MockitoRule mMockito = MockitoJUnit.rule(); + @Spy + UserRepositoryImpl mUserRepository; + + @Before + public void setup() { + doReturn(mHyperwallet).when(mUserRepository).getHyperwallet(); + } + + @Test + public void testLoadUser_returnsUser() { + HyperwalletUser.Builder builder = new HyperwalletUser.Builder(); + final HyperwalletUser user = builder + .token("usr-f9154016-94e8-4686-a840-075688ac07b5") + .status(PRE_ACTIVATED) + .verificationStatus(NOT_REQUIRED) + .createdOn("2017-10-30T22:15:45") + .clientUserId("123456") + .profileType(INDIVIDUAL) + .firstName("Some") + .lastName("Guy") + .dateOfBirth("1991-01-01") + .email("testUser@hyperwallet.com") + .addressLine1("575 Market Street") + .city("San Francisco") + .stateProvince("CA") + .country("US") + .postalCode("94105") + .language("en") + .programToken("prg-83836cdf-2ce2-4696-8bc5-f1b86077238c") + .build(); + + doAnswer(new Answer() { + @Override + public Object answer(InvocationOnMock invocation) { + HyperwalletListener listener = (HyperwalletListener) invocation.getArguments()[0]; + listener.onSuccess(user); + return listener; + } + }).when(mHyperwallet).getUser(ArgumentMatchers.>any()); + + mUserRepository.loadUser(mMockCallback); + + verify(mMockCallback).onUserLoaded(mUserCaptor.capture()); + verify(mMockCallback, never()).onError(any(HyperwalletErrors.class)); + + HyperwalletUser resultUser = mUserCaptor.getValue(); + assertThat(resultUser.getToken(), is("usr-f9154016-94e8-4686-a840-075688ac07b5")); + assertThat(resultUser.getStatus(), is(PRE_ACTIVATED)); + assertThat(resultUser.getVerificationStatus(), is(NOT_REQUIRED)); + assertThat(resultUser.getCreatedOn(), is("2017-10-30T22:15:45")); + assertThat(resultUser.getClientUserId(), is("123456")); + assertThat(resultUser.getProfileType(), is(INDIVIDUAL)); + assertThat(resultUser.getFirstName(), is("Some")); + assertThat(resultUser.getLastName(), is("Guy")); + assertThat(resultUser.getDateOfBirth(), is("1991-01-01")); + assertThat(resultUser.getEmail(), is("testUser@hyperwallet.com")); + assertThat(resultUser.getAddressLine1(), is("575 Market Street")); + assertThat(resultUser.getCity(), is("San Francisco")); + assertThat(resultUser.getStateProvince(), is("CA")); + assertThat(resultUser.getCountry(), is("US")); + assertThat(resultUser.getPostalCode(), is("94105")); + assertThat(resultUser.getLanguage(), is("en")); + assertThat(resultUser.getProgramToken(), is("prg-83836cdf-2ce2-4696-8bc5-f1b86077238c")); + } + + @Test + public void testLoadUser_returnsNoUser() { + + doAnswer(new Answer() { + @Override + public Object answer(InvocationOnMock invocation) { + HyperwalletListener listener = (HyperwalletListener) invocation.getArguments()[0]; + listener.onSuccess(null); + return listener; + } + }).when(mHyperwallet).getUser(ArgumentMatchers.>any()); + + mUserRepository.loadUser(mMockCallback); + + verify(mMockCallback).onUserLoaded(mUserCaptor.capture()); + verify(mMockCallback, never()).onError(any(HyperwalletErrors.class)); + + HyperwalletUser user = mUserCaptor.getValue(); + assertThat(user, is(nullValue())); + } + + + @Test + public void testLoadUser_withError() { + + final HyperwalletError error = new HyperwalletError("test message", "TEST_CODE"); + + doAnswer(new Answer() { + @Override + public Object answer(InvocationOnMock invocation) { + HyperwalletListener listener = (HyperwalletListener) invocation.getArguments()[0]; + List errorList = new ArrayList<>(); + errorList.add(error); + HyperwalletErrors errors = new HyperwalletErrors(errorList); + listener.onFailure(new HyperwalletException(errors)); + return listener; + } + }).when(mHyperwallet).getUser(ArgumentMatchers.>any()); + + mUserRepository.loadUser(mMockCallback); + + verify(mMockCallback, never()).onUserLoaded(ArgumentMatchers.any()); + verify(mMockCallback).onError(mErrorCaptor.capture()); + + assertThat(mErrorCaptor.getValue().getErrors(), hasItem(error)); + } + + @Test + public void testRefreshUser_verifyHyperwalletCallGetUser() { + HyperwalletUser.Builder builder = new HyperwalletUser.Builder(); + final HyperwalletUser user = builder + .token("usr-f9154016-94e8-4686-a840-075688ac07b5") + .profileType(INDIVIDUAL) + .build(); + + doAnswer(new Answer() { + @Override + public Object answer(InvocationOnMock invocation) { + HyperwalletListener listener = (HyperwalletListener) invocation.getArguments()[0]; + listener.onSuccess(user); + return listener; + } + }).when(mHyperwallet).getUser(ArgumentMatchers.>any()); + + mUserRepository.loadUser(mMockCallback); + + verify(mHyperwallet).getUser(ArgumentMatchers.>any()); + + mUserRepository.loadUser(mMockCallback); + verify(mHyperwallet).getUser(ArgumentMatchers.>any()); + + mUserRepository.refreshUser(); + mUserRepository.loadUser(mMockCallback); + verify(mHyperwallet, times(2)).getUser(ArgumentMatchers.>any()); + + } +} diff --git a/ui/src/test/java/com/hyperwallet/android/ui/transfermethod/AddTransferMethodPresenterTest.java b/ui/src/test/java/com/hyperwallet/android/ui/transfermethod/AddTransferMethodPresenterTest.java index 4169726f8..a0f809ee0 100644 --- a/ui/src/test/java/com/hyperwallet/android/ui/transfermethod/AddTransferMethodPresenterTest.java +++ b/ui/src/test/java/com/hyperwallet/android/ui/transfermethod/AddTransferMethodPresenterTest.java @@ -13,6 +13,8 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import static com.hyperwallet.android.model.HyperwalletUser.ProfileTypes.INDIVIDUAL; + import com.hyperwallet.android.model.HyperwalletBankAccount; import com.hyperwallet.android.model.HyperwalletError; import com.hyperwallet.android.model.HyperwalletErrors; @@ -149,15 +151,15 @@ public void testLoadTransferMethodConfigurationFields_loadsTransferMethodFieldsI @Override public Object answer(InvocationOnMock invocation) { TransferMethodConfigurationRepository.LoadFieldsCallback callback = - (TransferMethodConfigurationRepository.LoadFieldsCallback) invocation.getArguments()[3]; + (TransferMethodConfigurationRepository.LoadFieldsCallback) invocation.getArguments()[4]; callback.onFieldsLoaded(result); return callback; } - }).when(tmcRepository).getFields(anyString(), anyString(), anyString(), + }).when(tmcRepository).getFields(anyString(), anyString(), anyString(), anyString(), any(TransferMethodConfigurationRepository.LoadFieldsCallback.class)); // Then - presenter.loadTransferMethodConfigurationFields(false, "CA", "CAD", "BANK_ACCOUNT"); + presenter.loadTransferMethodConfigurationFields(false, "CA", "CAD", "BANK_ACCOUNT", INDIVIDUAL); LATCH.await(AWAIT_TIME_MS, TimeUnit.MILLISECONDS); verify(view).showTransferMethodFields(fieldArgumentCaptor.capture()); @@ -177,15 +179,15 @@ public void testLoadTransferMethodConfigurationFields_showsErrorOnFailure() thro @Override public Object answer(InvocationOnMock invocation) { TransferMethodConfigurationRepository.LoadFieldsCallback callback = - (TransferMethodConfigurationRepository.LoadFieldsCallback) invocation.getArguments()[3]; + (TransferMethodConfigurationRepository.LoadFieldsCallback) invocation.getArguments()[4]; callback.onError(errors); return callback; } - }).when(tmcRepository).getFields(anyString(), anyString(), anyString(), + }).when(tmcRepository).getFields(anyString(), anyString(), anyString(),anyString(), any(TransferMethodConfigurationRepository.LoadFieldsCallback.class)); // Then - presenter.loadTransferMethodConfigurationFields(false, "CA", "CAD", "BANK_ACCOUNT"); + presenter.loadTransferMethodConfigurationFields(false, "CA", "CAD", "BANK_ACCOUNT", INDIVIDUAL); LATCH.await(AWAIT_TIME_MS, TimeUnit.MILLISECONDS); verify(view, never()).showTransferMethodFields(ArgumentMatchers.anyList()); @@ -195,10 +197,10 @@ public Object answer(InvocationOnMock invocation) { @Test public void testLoadTransferMethodConfigurationFields_updatesFieldsWhenForceUpdateIsTrue() { - presenter.loadTransferMethodConfigurationFields(true, "CA", "CAD", "BANK_ACCOUNT"); + presenter.loadTransferMethodConfigurationFields(true, "CA", "CAD", "BANK_ACCOUNT", INDIVIDUAL); verify(tmcRepository, atLeastOnce()).refreshFields(); - verify(tmcRepository, atLeastOnce()).getFields(anyString(), anyString(), anyString(), + verify(tmcRepository, atLeastOnce()).getFields(anyString(), anyString(), anyString(), anyString(), any(TransferMethodConfigurationRepository.LoadFieldsCallback.class)); verify(view, never()).showTransferMethodFields(ArgumentMatchers.anyList()); verify(view, never()).showErrorLoadTransferMethodConfigurationFields( @@ -212,10 +214,10 @@ public void testLoadTransferMethodConfigurationFields_loadsTransferMethodFieldsI when(view.isActive()).thenReturn(false); // Then - presenter.loadTransferMethodConfigurationFields(true, "CA", "CAD", "BANK_ACCOUNT"); + presenter.loadTransferMethodConfigurationFields(true, "CA", "CAD", "BANK_ACCOUNT", INDIVIDUAL); verify(tmcRepository, atLeastOnce()).refreshFields(); - verify(tmcRepository, atLeastOnce()).getFields(anyString(), anyString(), anyString(), + verify(tmcRepository, atLeastOnce()).getFields(anyString(), anyString(), anyString(), anyString(), any(TransferMethodConfigurationRepository.LoadFieldsCallback.class)); verify(view, never()).hideProgressBar(); verify(view, never()).showTransferMethodFields(ArgumentMatchers.anyList()); @@ -232,15 +234,15 @@ public void testLoadTransferMethodConfigurationFields_loadsTransferMethodFieldsE @Override public Object answer(InvocationOnMock invocation) { TransferMethodConfigurationRepository.LoadFieldsCallback callback = - (TransferMethodConfigurationRepository.LoadFieldsCallback) invocation.getArguments()[3]; + (TransferMethodConfigurationRepository.LoadFieldsCallback) invocation.getArguments()[4]; callback.onError(errors); return callback; } - }).when(tmcRepository).getFields(anyString(), anyString(), anyString(), + }).when(tmcRepository).getFields(anyString(), anyString(), anyString(), anyString(), any(TransferMethodConfigurationRepository.LoadFieldsCallback.class)); // Then - presenter.loadTransferMethodConfigurationFields(false, "CA", "CAD", "BANK_ACCOUNT"); + presenter.loadTransferMethodConfigurationFields(false, "CA", "CAD", "BANK_ACCOUNT", INDIVIDUAL); LATCH.await(AWAIT_TIME_MS, TimeUnit.MILLISECONDS); verify(view, never()).hideProgressBar(); diff --git a/ui/src/test/java/com/hyperwallet/android/ui/transfermethod/SelectTransferMethodPresenterTest.java b/ui/src/test/java/com/hyperwallet/android/ui/transfermethod/SelectTransferMethodPresenterTest.java index 5a666ec6e..6d1346ffd 100644 --- a/ui/src/test/java/com/hyperwallet/android/ui/transfermethod/SelectTransferMethodPresenterTest.java +++ b/ui/src/test/java/com/hyperwallet/android/ui/transfermethod/SelectTransferMethodPresenterTest.java @@ -13,9 +13,13 @@ import com.hyperwallet.android.model.HyperwalletError; import com.hyperwallet.android.model.HyperwalletErrors; +import com.hyperwallet.android.model.HyperwalletTransferMethod; +import com.hyperwallet.android.model.HyperwalletUser; import com.hyperwallet.android.model.meta.TransferMethodConfigurationResult; import com.hyperwallet.android.ui.repository.TransferMethodConfigurationRepository; import com.hyperwallet.android.ui.repository.TransferMethodConfigurationRepositoryImpl; +import com.hyperwallet.android.ui.repository.UserRepository; +import com.hyperwallet.android.ui.repository.UserRepositoryImpl; import com.hyperwallet.android.ui.rule.HyperwalletExternalResourceManager; import org.json.JSONObject; @@ -35,28 +39,36 @@ @RunWith(RobolectricTestRunner.class) public class SelectTransferMethodPresenterTest { - private static final String COUNTRY = "CA"; - private static final String CURRENCY = "CAD"; - private static final String BANK_ACCOUNT = "BANK_ACCOUNT"; + @Mock private SelectTransferMethodContract.View view; @Mock - private TransferMethodConfigurationRepositoryImpl transferMethodConfigurationRepository; + private TransferMethodConfigurationRepositoryImpl mTransferMethodConfigurationRepository; + @Mock + private UserRepositoryImpl mUserRepository; @Rule public HyperwalletExternalResourceManager externalResourceManager = new HyperwalletExternalResourceManager(); - private TransferMethodConfigurationResult result; + private TransferMethodConfigurationResult mResult; + private HyperwalletUser mUser; private SelectTransferMethodPresenter selectTransferMethodPresenter; private final HyperwalletErrors errors = createErrors(); @Before public void initialize() throws Exception { initMocks(this); - String responseBody = externalResourceManager.getResourceContent("successful_tmc_keys_response.json"); - final JSONObject jsonObject = new JSONObject(responseBody); - result = new TransferMethodConfigurationResult(jsonObject); - selectTransferMethodPresenter = new SelectTransferMethodPresenter(view, transferMethodConfigurationRepository); + + String methodsResponseBody = externalResourceManager.getResourceContent("successful_tmc_keys_response.json"); + final JSONObject methodsJsonObject = new JSONObject(methodsResponseBody); + mResult = new TransferMethodConfigurationResult(methodsJsonObject); + + String userResponseBody = externalResourceManager.getResourceContent("user_response.json"); + final JSONObject userJsonObject = new JSONObject(userResponseBody); + mUser = new HyperwalletUser(userJsonObject); + + selectTransferMethodPresenter = new SelectTransferMethodPresenter(view, mTransferMethodConfigurationRepository, + mUserRepository); } @Test @@ -69,12 +81,23 @@ public void testLoadTransferMethodConfigurationKeys_loadsKeysIntoViewOnSuccess() public Object answer(InvocationOnMock invocation) { TransferMethodConfigurationRepository.LoadKeysCallback callback = (TransferMethodConfigurationRepository.LoadKeysCallback) invocation.getArguments()[0]; - callback.onKeysLoaded(result); + callback.onKeysLoaded(mResult); return callback; } - }).when(transferMethodConfigurationRepository).getKeys(any( + }).when(mTransferMethodConfigurationRepository).getKeys(any( TransferMethodConfigurationRepository.LoadKeysCallback.class)); + doAnswer(new Answer() { + @Override + public Object answer(InvocationOnMock invocation) { + UserRepository.LoadUserCallback userCallback = + (UserRepository.LoadUserCallback) invocation.getArguments()[0]; + userCallback.onUserLoaded(mUser); + return userCallback; + } + }).when(mUserRepository).loadUser(any( + UserRepository.LoadUserCallback.class)); + // Then selectTransferMethodPresenter.loadTransferMethodConfigurationKeys(false, "CA", "CAD"); @@ -87,7 +110,7 @@ public Object answer(InvocationOnMock invocation) { verify(view, never()).showErrorLoadTransferMethodTypes(ArgumentMatchers.anyList()); verify(view, never()).showErrorLoadCountrySelection(ArgumentMatchers.anyList()); verify(view, never()).showErrorLoadCurrencySelection(ArgumentMatchers.anyList()); - verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString()); + verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString(), anyString()); } @Test @@ -100,12 +123,23 @@ public void testLoadTransferMethodConfigurationKeys_loadsKeysIntoViewOnSuccessIn public Object answer(InvocationOnMock invocation) { TransferMethodConfigurationRepository.LoadKeysCallback callback = (TransferMethodConfigurationRepository.LoadKeysCallback) invocation.getArguments()[0]; - callback.onKeysLoaded(result); + callback.onKeysLoaded(mResult); return callback; } - }).when(transferMethodConfigurationRepository).getKeys(any( + }).when(mTransferMethodConfigurationRepository).getKeys(any( TransferMethodConfigurationRepository.LoadKeysCallback.class)); + doAnswer(new Answer() { + @Override + public Object answer(InvocationOnMock invocation) { + UserRepository.LoadUserCallback userCallback = + (UserRepository.LoadUserCallback) invocation.getArguments()[0]; + userCallback.onUserLoaded(mUser); + return userCallback; + } + }).when(mUserRepository).loadUser(any( + UserRepository.LoadUserCallback.class)); + // Then selectTransferMethodPresenter.loadTransferMethodConfigurationKeys(false, "CA", "CAD"); @@ -117,7 +151,7 @@ public Object answer(InvocationOnMock invocation) { verify(view, never()).showErrorLoadTransferMethodTypes(ArgumentMatchers.anyList()); verify(view, never()).showErrorLoadCountrySelection(ArgumentMatchers.anyList()); verify(view, never()).showErrorLoadCurrencySelection(ArgumentMatchers.anyList()); - verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString()); + verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString(), anyString()); } @Test @@ -133,15 +167,26 @@ public Object answer(InvocationOnMock invocation) { callback.onError(errors); return callback; } - }).when(transferMethodConfigurationRepository).getKeys(any( + }).when(mTransferMethodConfigurationRepository).getKeys(any( TransferMethodConfigurationRepository.LoadKeysCallback.class)); + doAnswer(new Answer() { + @Override + public Object answer(InvocationOnMock invocation) { + UserRepository.LoadUserCallback userCallback = + (UserRepository.LoadUserCallback) invocation.getArguments()[0]; + userCallback.onUserLoaded(mUser); + return userCallback; + } + }).when(mUserRepository).loadUser(any( + UserRepository.LoadUserCallback.class)); + // Then selectTransferMethodPresenter.loadTransferMethodConfigurationKeys(false, "CA", "CAD"); verify(view, never()).showTransferMethodTypes(ArgumentMatchers.anyList()); verify(view).showErrorLoadTransferMethodConfigurationKeys(eq(errors.getErrors())); - verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString()); + verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString(), anyString()); } @Test @@ -155,12 +200,23 @@ public Object answer(InvocationOnMock invocation) { TransferMethodConfigurationRepository.LoadKeysCallback callback = (TransferMethodConfigurationRepository.LoadKeysCallback) invocation.getArguments()[0]; - callback.onKeysLoaded(result); + callback.onKeysLoaded(mResult); return callback; } - }).when(transferMethodConfigurationRepository).getKeys(any( + }).when(mTransferMethodConfigurationRepository).getKeys(any( TransferMethodConfigurationRepository.LoadKeysCallback.class)); + doAnswer(new Answer() { + @Override + public Object answer(InvocationOnMock invocation) { + UserRepository.LoadUserCallback userCallback = + (UserRepository.LoadUserCallback) invocation.getArguments()[0]; + userCallback.onUserLoaded(mUser); + return userCallback; + } + }).when(mUserRepository).loadUser(any( + UserRepository.LoadUserCallback.class)); + // Then selectTransferMethodPresenter.loadCurrency(false, "CA"); @@ -172,7 +228,7 @@ public Object answer(InvocationOnMock invocation) { verify(view, never()).showErrorLoadTransferMethodTypes(ArgumentMatchers.anyList()); verify(view, never()).showErrorLoadCountrySelection(ArgumentMatchers.anyList()); verify(view, never()).showErrorLoadCurrencySelection(ArgumentMatchers.anyList()); - verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString()); + verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString(), anyString()); verify(view, atLeastOnce()).showTransferMethodCountry(anyString()); } @@ -187,11 +243,21 @@ public Object answer(InvocationOnMock invocation) { TransferMethodConfigurationRepository.LoadKeysCallback callback = (TransferMethodConfigurationRepository.LoadKeysCallback) invocation.getArguments()[0]; - callback.onKeysLoaded(result); + callback.onKeysLoaded(mResult); return callback; } - }).when(transferMethodConfigurationRepository).getKeys(any( + }).when(mTransferMethodConfigurationRepository).getKeys(any( TransferMethodConfigurationRepository.LoadKeysCallback.class)); + doAnswer(new Answer() { + @Override + public Object answer(InvocationOnMock invocation) { + UserRepository.LoadUserCallback userCallback = + (UserRepository.LoadUserCallback) invocation.getArguments()[0]; + userCallback.onUserLoaded(mUser); + return userCallback; + } + }).when(mUserRepository).loadUser(any( + UserRepository.LoadUserCallback.class)); // Then selectTransferMethodPresenter.loadCurrency(false, "CA"); @@ -203,13 +269,13 @@ public Object answer(InvocationOnMock invocation) { verify(view, never()).showErrorLoadTransferMethodTypes(ArgumentMatchers.anyList()); verify(view, never()).showErrorLoadCountrySelection(ArgumentMatchers.anyList()); verify(view, never()).showErrorLoadCurrencySelection(ArgumentMatchers.anyList()); - verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString()); + verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString(), anyString()); } @Test public void testLoadCurrency_loadsCurrenciesWhenRefreshingKeys() { selectTransferMethodPresenter.loadCurrency(true, "CA"); - verify(transferMethodConfigurationRepository, times(1)).refreshKeys(); + verify(mTransferMethodConfigurationRepository, times(1)).refreshKeys(); } @@ -227,15 +293,26 @@ public Object answer(InvocationOnMock invocation) { callback.onError(errors); return callback; } - }).when(transferMethodConfigurationRepository).getKeys(any( + }).when(mTransferMethodConfigurationRepository).getKeys(any( TransferMethodConfigurationRepository.LoadKeysCallback.class)); + doAnswer(new Answer() { + @Override + public Object answer(InvocationOnMock invocation) { + UserRepository.LoadUserCallback userCallback = + (UserRepository.LoadUserCallback) invocation.getArguments()[0]; + userCallback.onUserLoaded(mUser); + return userCallback; + } + }).when(mUserRepository).loadUser(any( + UserRepository.LoadUserCallback.class)); + // Then selectTransferMethodPresenter.loadCurrency(false, "CA"); verify(view, never()).showTransferMethodTypes(ArgumentMatchers.anyList()); verify(view).showErrorLoadCurrency(eq(errors.getErrors())); - verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString()); + verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString(), anyString()); } @Test @@ -249,14 +326,26 @@ public Object answer(InvocationOnMock invocation) { TransferMethodConfigurationRepository.LoadKeysCallback callback = (TransferMethodConfigurationRepository.LoadKeysCallback) invocation.getArguments()[0]; - callback.onKeysLoaded(result); + callback.onKeysLoaded(mResult); return callback; } - }).when(transferMethodConfigurationRepository).getKeys(any( + }).when(mTransferMethodConfigurationRepository).getKeys(any( TransferMethodConfigurationRepository.LoadKeysCallback.class)); + doAnswer(new Answer() { + @Override + public Object answer(InvocationOnMock invocation) { + UserRepository.LoadUserCallback userCallback = + (UserRepository.LoadUserCallback) invocation.getArguments()[0]; + userCallback.onUserLoaded(mUser); + return userCallback; + } + }).when(mUserRepository).loadUser(any( + UserRepository.LoadUserCallback.class)); + + // Then - selectTransferMethodPresenter.loadTransferMethodTypes(false, COUNTRY, CURRENCY); + selectTransferMethodPresenter.loadTransferMethodTypes(false, "CA", "CAD"); verify(view).showTransferMethodTypes(ArgumentMatchers.anyList()); verify(view, never()).showErrorLoadTransferMethodConfigurationKeys( @@ -265,7 +354,7 @@ public Object answer(InvocationOnMock invocation) { verify(view, never()).showErrorLoadTransferMethodTypes(ArgumentMatchers.anyList()); verify(view, never()).showErrorLoadCountrySelection(ArgumentMatchers.anyList()); verify(view, never()).showErrorLoadCurrencySelection(ArgumentMatchers.anyList()); - verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString()); + verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString(), anyString()); verify(view, atLeastOnce()).showTransferMethodCountry(anyString()); verify(view, atLeastOnce()).showTransferMethodCurrency(anyString()); } @@ -279,14 +368,26 @@ public Object answer(InvocationOnMock invocation) { TransferMethodConfigurationRepository.LoadKeysCallback callback = (TransferMethodConfigurationRepository.LoadKeysCallback) invocation.getArguments()[0]; - callback.onKeysLoaded(result); + callback.onKeysLoaded(mResult); return callback; } - }).when(transferMethodConfigurationRepository).getKeys(any( + }).when(mTransferMethodConfigurationRepository).getKeys(any( TransferMethodConfigurationRepository.LoadKeysCallback.class)); + doAnswer(new Answer() { + @Override + public Object answer(InvocationOnMock invocation) { + UserRepository.LoadUserCallback userCallback = + (UserRepository.LoadUserCallback) invocation.getArguments()[0]; + userCallback.onUserLoaded(mUser); + return userCallback; + } + }).when(mUserRepository).loadUser(any( + UserRepository.LoadUserCallback.class)); + + // Then - selectTransferMethodPresenter.loadTransferMethodTypes(false, COUNTRY, CURRENCY); + selectTransferMethodPresenter.loadTransferMethodTypes(false, "CA", "CAD"); verify(view, never()).showTransferMethodTypes(ArgumentMatchers.anyList()); verify(view, never()).showErrorLoadTransferMethodConfigurationKeys( @@ -295,7 +396,7 @@ public Object answer(InvocationOnMock invocation) { verify(view, never()).showErrorLoadTransferMethodTypes(ArgumentMatchers.anyList()); verify(view, never()).showErrorLoadCountrySelection(ArgumentMatchers.anyList()); verify(view, never()).showErrorLoadCurrencySelection(ArgumentMatchers.anyList()); - verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString()); + verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString(), anyString()); } @Test @@ -312,15 +413,26 @@ public Object answer(InvocationOnMock invocation) { callback.onError(errors); return callback; } - }).when(transferMethodConfigurationRepository).getKeys(any( + }).when(mTransferMethodConfigurationRepository).getKeys(any( TransferMethodConfigurationRepository.LoadKeysCallback.class)); + doAnswer(new Answer() { + @Override + public Object answer(InvocationOnMock invocation) { + UserRepository.LoadUserCallback userCallback = + (UserRepository.LoadUserCallback) invocation.getArguments()[0]; + userCallback.onUserLoaded(mUser); + return userCallback; + } + }).when(mUserRepository).loadUser(any( + UserRepository.LoadUserCallback.class)); + // Then selectTransferMethodPresenter.loadTransferMethodTypes(false, "CA", "CAD"); verify(view, never()).showTransferMethodTypes(ArgumentMatchers.anyList()); verify(view).showErrorLoadTransferMethodTypes(eq(errors.getErrors())); - verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString()); + verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString(), anyString()); } @Test @@ -335,15 +447,26 @@ public Object answer(InvocationOnMock invocation) { callback.onError(errors); return callback; } - }).when(transferMethodConfigurationRepository).getKeys(any( + }).when(mTransferMethodConfigurationRepository).getKeys(any( TransferMethodConfigurationRepository.LoadKeysCallback.class)); + doAnswer(new Answer() { + @Override + public Object answer(InvocationOnMock invocation) { + UserRepository.LoadUserCallback userCallback = + (UserRepository.LoadUserCallback) invocation.getArguments()[0]; + userCallback.onUserLoaded(mUser); + return userCallback; + } + }).when(mUserRepository).loadUser(any( + UserRepository.LoadUserCallback.class)); + // Then selectTransferMethodPresenter.loadTransferMethodTypes(false, "CA", "CAD"); verify(view, never()).showTransferMethodTypes(ArgumentMatchers.anyList()); verify(view, never()).showErrorLoadTransferMethodTypes(eq(errors.getErrors())); - verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString()); + verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString(), anyString()); } @Test @@ -355,16 +478,18 @@ public Object answer(InvocationOnMock invocation) { TransferMethodConfigurationRepository.LoadKeysCallback callback = (TransferMethodConfigurationRepository.LoadKeysCallback) invocation.getArguments()[0]; - callback.onKeysLoaded(result); + callback.onKeysLoaded(mResult); return callback; } - }).when(transferMethodConfigurationRepository).getKeys(any(TransferMethodConfigurationRepository. + }).when(mTransferMethodConfigurationRepository).getKeys(any(TransferMethodConfigurationRepository. LoadKeysCallback.class)); // Then - selectTransferMethodPresenter.openAddTransferMethod(COUNTRY, CURRENCY, BANK_ACCOUNT); + selectTransferMethodPresenter.openAddTransferMethod("CA", "CAD", HyperwalletTransferMethod.TransferMethodTypes.BANK_ACCOUNT, + HyperwalletUser.ProfileTypes.INDIVIDUAL); - verify(view).showAddTransferMethod(COUNTRY, CURRENCY, BANK_ACCOUNT); + verify(view).showAddTransferMethod("CA", "CAD", HyperwalletTransferMethod.TransferMethodTypes.BANK_ACCOUNT, + HyperwalletUser.ProfileTypes.INDIVIDUAL); verify(view, never()).showErrorLoadTransferMethodConfigurationKeys( ArgumentMatchers.anyList()); verify(view, never()).showErrorLoadCurrency(ArgumentMatchers.anyList()); @@ -387,14 +512,14 @@ public Object answer(InvocationOnMock invocation) { TransferMethodConfigurationRepository.LoadKeysCallback callback = (TransferMethodConfigurationRepository.LoadKeysCallback) invocation.getArguments()[0]; - callback.onKeysLoaded(result); + callback.onKeysLoaded(mResult); return callback; } - }).when(transferMethodConfigurationRepository).getKeys(any( + }).when(mTransferMethodConfigurationRepository).getKeys(any( TransferMethodConfigurationRepository.LoadKeysCallback.class)); // Then - selectTransferMethodPresenter.loadCountrySelection(COUNTRY); + selectTransferMethodPresenter.loadCountrySelection("CA"); verify(view).showCountrySelectionDialog(any(TreeMap.class), anyString()); verify(view, never()).showErrorLoadTransferMethodConfigurationKeys( @@ -403,7 +528,7 @@ public Object answer(InvocationOnMock invocation) { verify(view, never()).showErrorLoadTransferMethodTypes(ArgumentMatchers.anyList()); verify(view, never()).showErrorLoadCountrySelection(ArgumentMatchers.anyList()); verify(view, never()).showErrorLoadCurrencySelection(ArgumentMatchers.anyList()); - verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString()); + verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString(), anyString()); } @Test @@ -415,14 +540,14 @@ public Object answer(InvocationOnMock invocation) { TransferMethodConfigurationRepository.LoadKeysCallback callback = (TransferMethodConfigurationRepository.LoadKeysCallback) invocation.getArguments()[0]; - callback.onKeysLoaded(result); + callback.onKeysLoaded(mResult); return callback; } - }).when(transferMethodConfigurationRepository).getKeys(any( + }).when(mTransferMethodConfigurationRepository).getKeys(any( TransferMethodConfigurationRepository.LoadKeysCallback.class)); // Then - selectTransferMethodPresenter.loadCountrySelection(COUNTRY); + selectTransferMethodPresenter.loadCountrySelection("CA"); verify(view, never()).showCountrySelectionDialog(any(TreeMap.class), anyString()); verify(view, never()).showErrorLoadTransferMethodConfigurationKeys( @@ -431,7 +556,7 @@ public Object answer(InvocationOnMock invocation) { verify(view, never()).showErrorLoadTransferMethodTypes(ArgumentMatchers.anyList()); verify(view, never()).showErrorLoadCountrySelection(ArgumentMatchers.anyList()); verify(view, never()).showErrorLoadCurrencySelection(ArgumentMatchers.anyList()); - verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString()); + verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString(), anyString()); } @Test @@ -448,15 +573,15 @@ public Object answer(InvocationOnMock invocation) { callback.onError(errors); return callback; } - }).when(transferMethodConfigurationRepository).getKeys(any( + }).when(mTransferMethodConfigurationRepository).getKeys(any( TransferMethodConfigurationRepository.LoadKeysCallback.class)); // Then - selectTransferMethodPresenter.loadCountrySelection(COUNTRY); + selectTransferMethodPresenter.loadCountrySelection("CA"); verify(view, never()).showCountrySelectionDialog(any(TreeMap.class), anyString()); verify(view).showErrorLoadCountrySelection(eq(errors.getErrors())); - verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString()); + verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString(), anyString()); } @Test @@ -471,11 +596,11 @@ public Object answer(InvocationOnMock invocation) { callback.onError(errors); return callback; } - }).when(transferMethodConfigurationRepository).getKeys(any( + }).when(mTransferMethodConfigurationRepository).getKeys(any( TransferMethodConfigurationRepository.LoadKeysCallback.class)); // Then - selectTransferMethodPresenter.loadCountrySelection(COUNTRY); + selectTransferMethodPresenter.loadCountrySelection("CA"); verify(view, never()).showCountrySelectionDialog(any(TreeMap.class), anyString()); verify(view, never()).showErrorLoadTransferMethodConfigurationKeys( @@ -484,7 +609,7 @@ public Object answer(InvocationOnMock invocation) { verify(view, never()).showErrorLoadTransferMethodTypes(ArgumentMatchers.anyList()); verify(view, never()).showErrorLoadCountrySelection(ArgumentMatchers.anyList()); verify(view, never()).showErrorLoadCurrencySelection(ArgumentMatchers.anyList()); - verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString()); + verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString(), anyString()); } @Test @@ -498,14 +623,14 @@ public Object answer(InvocationOnMock invocation) { TransferMethodConfigurationRepository.LoadKeysCallback callback = (TransferMethodConfigurationRepository.LoadKeysCallback) invocation.getArguments()[0]; - callback.onKeysLoaded(result); + callback.onKeysLoaded(mResult); return callback; } - }).when(transferMethodConfigurationRepository).getKeys(any( + }).when(mTransferMethodConfigurationRepository).getKeys(any( TransferMethodConfigurationRepository.LoadKeysCallback.class)); // Then - selectTransferMethodPresenter.loadCurrencySelection(COUNTRY, CURRENCY); + selectTransferMethodPresenter.loadCurrencySelection("CA", "CAD"); verify(view).showCurrencySelectionDialog(any(TreeMap.class), anyString()); verify(view, never()).showErrorLoadTransferMethodConfigurationKeys( @@ -514,7 +639,7 @@ public Object answer(InvocationOnMock invocation) { verify(view, never()).showErrorLoadTransferMethodTypes(ArgumentMatchers.anyList()); verify(view, never()).showErrorLoadCountrySelection(ArgumentMatchers.anyList()); verify(view, never()).showErrorLoadCurrencySelection(ArgumentMatchers.anyList()); - verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString()); + verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString(), anyString()); } @Test @@ -526,14 +651,14 @@ public Object answer(InvocationOnMock invocation) { TransferMethodConfigurationRepository.LoadKeysCallback callback = (TransferMethodConfigurationRepository.LoadKeysCallback) invocation.getArguments()[0]; - callback.onKeysLoaded(result); + callback.onKeysLoaded(mResult); return callback; } - }).when(transferMethodConfigurationRepository).getKeys(any( + }).when(mTransferMethodConfigurationRepository).getKeys(any( TransferMethodConfigurationRepository.LoadKeysCallback.class)); // Then - selectTransferMethodPresenter.loadCurrencySelection(COUNTRY, CURRENCY); + selectTransferMethodPresenter.loadCurrencySelection("CA", "CAD"); verify(view, never()).showCurrencySelectionDialog(any(TreeMap.class), anyString()); verify(view, never()).showErrorLoadTransferMethodConfigurationKeys( @@ -542,7 +667,7 @@ public Object answer(InvocationOnMock invocation) { verify(view, never()).showErrorLoadTransferMethodTypes(ArgumentMatchers.anyList()); verify(view, never()).showErrorLoadCountrySelection(ArgumentMatchers.anyList()); verify(view, never()).showErrorLoadCurrencySelection(ArgumentMatchers.anyList()); - verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString()); + verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString(), anyString()); } @Test @@ -559,15 +684,15 @@ public Object answer(InvocationOnMock invocation) { callback.onError(errors); return callback; } - }).when(transferMethodConfigurationRepository).getKeys(any( + }).when(mTransferMethodConfigurationRepository).getKeys(any( TransferMethodConfigurationRepository.LoadKeysCallback.class)); // Then - selectTransferMethodPresenter.loadCurrencySelection(COUNTRY, CURRENCY); + selectTransferMethodPresenter.loadCurrencySelection("CA", "CAD"); verify(view, never()).showCurrencySelectionDialog(any(TreeMap.class), anyString()); verify(view).showErrorLoadCurrencySelection(eq(errors.getErrors())); - verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString()); + verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString(), anyString()); } @Test @@ -582,11 +707,11 @@ public Object answer(InvocationOnMock invocation) { callback.onError(errors); return callback; } - }).when(transferMethodConfigurationRepository).getKeys(any( + }).when(mTransferMethodConfigurationRepository).getKeys(any( TransferMethodConfigurationRepository.LoadKeysCallback.class)); // Then - selectTransferMethodPresenter.loadCurrencySelection(COUNTRY, CURRENCY); + selectTransferMethodPresenter.loadCurrencySelection("CA", "CAD"); verify(view, never()).showCurrencySelectionDialog(any(TreeMap.class), anyString()); verify(view, never()).showErrorLoadTransferMethodConfigurationKeys( @@ -595,7 +720,7 @@ public Object answer(InvocationOnMock invocation) { verify(view, never()).showErrorLoadTransferMethodTypes(ArgumentMatchers.anyList()); verify(view, never()).showErrorLoadCountrySelection(ArgumentMatchers.anyList()); verify(view, never()).showErrorLoadCurrencySelection(ArgumentMatchers.anyList()); - verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString()); + verify(view, never()).showAddTransferMethod(anyString(), anyString(), anyString(), anyString()); } private HyperwalletErrors createErrors() { @@ -604,4 +729,50 @@ private HyperwalletErrors createErrors() { errors.add(error); return new HyperwalletErrors(errors); } + + @Test + public void testLoadMethods_whenLoadUserWithError_checkShowingErrors() { + + final HyperwalletError error = new HyperwalletError("test message", "TEST_CODE"); + List errorList = new ArrayList<>(); + errorList.add(error); + final HyperwalletErrors errors = new HyperwalletErrors(errorList); + + doAnswer(new Answer() { + @Override + public Object answer(InvocationOnMock invocation) { + UserRepository.LoadUserCallback userCallback = + (UserRepository.LoadUserCallback) invocation.getArguments()[0]; + userCallback.onError(errors); + return userCallback; + } + }).when(mUserRepository).loadUser(any( + UserRepository.LoadUserCallback.class)); + when(view.isActive()).thenReturn(false); + // Then + selectTransferMethodPresenter.loadTransferMethodConfigurationKeys(false, "CA", "CAD"); + + verify(view, never()).showErrorLoadTransferMethodConfigurationKeys(ArgumentMatchers.anyList()); + + selectTransferMethodPresenter.loadCurrency(false, "CA"); + verify(view, never()).showErrorLoadCurrency(ArgumentMatchers.anyList()); + + selectTransferMethodPresenter.loadTransferMethodTypes(false, "CA", "CAD"); + verify(view, never()).showErrorLoadTransferMethodTypes(ArgumentMatchers.anyList()); + + + // When + when(view.isActive()).thenReturn(true); + + // Then + selectTransferMethodPresenter.loadTransferMethodConfigurationKeys(false, "CA", "CAD"); + + verify(view).showErrorLoadTransferMethodConfigurationKeys(ArgumentMatchers.anyList()); + + selectTransferMethodPresenter.loadCurrency(false, "CA"); + verify(view).showErrorLoadCurrency(ArgumentMatchers.anyList()); + + selectTransferMethodPresenter.loadTransferMethodTypes(false, "CA", "CAD"); + verify(view).showErrorLoadTransferMethodTypes(ArgumentMatchers.anyList()); + } } diff --git a/ui/src/test/resources/user_response.json b/ui/src/test/resources/user_response.json new file mode 100644 index 000000000..e65074bef --- /dev/null +++ b/ui/src/test/resources/user_response.json @@ -0,0 +1,26 @@ +{ + "token": "usr-f9154016-94e8-4686-a840-075688ac07b5", + "status": "PRE_ACTIVATED", + "createdOn": "2017-10-30T22:15:45", + "clientUserId": "123456", + "profileType": "INDIVIDUAL", + "firstName": "Some", + "lastName": "Guy", + "dateOfBirth": "1991-01-01", + "email": "user+4satF1xV@hyperwallet.com", + "addressLine1": "575 Market Street", + "city": "San Francisco", + "stateProvince": "CA", + "country": "US", + "postalCode": "94105", + "language": "en", + "programToken": "prg-83836cdf-2ce2-4696-8bc5-f1b86077238c", + "links": [ + { + "params": { + "rel": "self" + }, + "href": "https://api.sandbox.hyperwallet.com/rest/v3/users/usr-f9154016-94e8-4686-a840-075688ac07b5" + } + ] +} \ No newline at end of file