diff --git a/CHANGELOG.md b/CHANGELOG.md index 0940888bb..8474b1a3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ Changelog ========= +[1.0.0-beta12](https://github.com/hyperwallet/hyperwallet-android-ui-sdk/releases/tag/1.0.0-beta12) +------------------- +* Bug fix + [1.0.0-beta11](https://github.com/hyperwallet/hyperwallet-android-ui-sdk/releases/tag/1.0.0-beta11) ------------------- * Fixed currency formatting issues diff --git a/README.md b/README.md index 7bfc7b356..ac8a5e819 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,9 @@ Note that this SDK is geared towards those who need both backend data and UI fea To install Hyperwallet UI SDK, you just need to add the dependencies into your build.gradle file in Android Studio (or Gradle). For example: ```bash -api 'com.hyperwallet.android.ui:transfermethodui:1.0.0-beta11' -api 'com.hyperwallet.android.ui:receiptui:1.0.0-beta11' -api 'com.hyperwallet.android.ui:transferui:1.0.0-beta11' +api 'com.hyperwallet.android.ui:transfermethodui:1.0.0-beta12' +api 'com.hyperwallet.android.ui:receiptui:1.0.0-beta12' +api 'com.hyperwallet.android.ui:transferui:1.0.0-beta12' ``` ### Proguard diff --git a/build.gradle b/build.gradle index 713fb33db..a60b5268a 100644 --- a/build.gradle +++ b/build.gradle @@ -24,7 +24,7 @@ allprojects { } - project.version = "1.0.0-beta11" + project.version = "1.0.0-beta12" } diff --git a/transfermethodui/src/main/java/com/hyperwallet/android/ui/transfermethod/view/SelectTransferMethodPresenter.java b/transfermethodui/src/main/java/com/hyperwallet/android/ui/transfermethod/view/SelectTransferMethodPresenter.java index 7e529c0c6..28583e43e 100644 --- a/transfermethodui/src/main/java/com/hyperwallet/android/ui/transfermethod/view/SelectTransferMethodPresenter.java +++ b/transfermethodui/src/main/java/com/hyperwallet/android/ui/transfermethod/view/SelectTransferMethodPresenter.java @@ -43,8 +43,6 @@ public class SelectTransferMethodPresenter implements SelectTransferMethodContract.Presenter { - private static final String DEFAULT_COUNTRY_CODE = "US"; - private final TransferMethodConfigurationRepository mTransferMethodConfigurationRepository; private final UserRepository mUserRepository; private final SelectTransferMethodContract.View mView; @@ -82,7 +80,7 @@ public void onKeysLoaded(@Nullable final HyperwalletTransferMethodConfigurationK : key.getCountry(countryCode); if (country == null) { // param and user country is null - country = key.getCountry(DEFAULT_COUNTRY_CODE); + country = key.getCountries().iterator().next(); } String currencyCodeString = currencyCode; diff --git a/transfermethodui/src/test/java/com/hyperwallet/android/ui/transfermethod/SelectTransferMethodPresenterTest.java b/transfermethodui/src/test/java/com/hyperwallet/android/ui/transfermethod/SelectTransferMethodPresenterTest.java index c179c48f7..7e941e228 100644 --- a/transfermethodui/src/test/java/com/hyperwallet/android/ui/transfermethod/SelectTransferMethodPresenterTest.java +++ b/transfermethodui/src/test/java/com/hyperwallet/android/ui/transfermethod/SelectTransferMethodPresenterTest.java @@ -31,6 +31,7 @@ import com.hyperwallet.android.ui.user.repository.UserRepositoryImpl; import org.hamcrest.Matchers; +import org.json.JSONException; import org.json.JSONObject; import org.junit.Before; import org.junit.Rule; @@ -1073,4 +1074,58 @@ public Object answer(InvocationOnMock invocation) { selectTransferMethodPresenter.loadTransferMethodTypes(false, "CA", "CAD"); verify(view).showErrorLoadTransferMethodTypes(ArgumentMatchers.anyList()); } + + @Test + public void loadTransferMethodConfigurationKeys_userWithCountryNotPresentInProgramCountries() throws JSONException { + // User's country is Albania which is not present in mResult successful_tmc_keys_response.json + String userResponseBody = externalResourceManager.getResourceContent("user_al_response.json"); + final JSONObject userJsonObject = new JSONObject(userResponseBody); + final User user = new User(userJsonObject); + + when(view.isActive()).thenReturn(true); + doAnswer(new Answer() { + @Override + public Object answer(InvocationOnMock invocation) { + TransferMethodConfigurationRepository.LoadKeysCallback callback = + (TransferMethodConfigurationRepository.LoadKeysCallback) invocation.getArguments()[0]; + callback.onKeysLoaded(mResult); + return callback; + } + }).when(mTransferMethodConfigurationRepository).getKeys(any( + TransferMethodConfigurationRepository.LoadKeysCallback.class)); + doAnswer(new Answer() { + @Override + public Object answer(InvocationOnMock invocation) { + TransferMethodConfigurationRepository.LoadKeysCallback callback = + (TransferMethodConfigurationRepository.LoadKeysCallback) invocation.getArguments()[2]; + callback.onKeysLoaded(mFeeAndProcessingTimeResult); + return callback; + } + }).when(mTransferMethodConfigurationRepository).getTransferMethodTypesFeeAndProcessingTime(anyString(), anyString(), any( + TransferMethodConfigurationRepository.LoadKeysCallback.class)); + doAnswer(new Answer() { + @Override + public Object answer(InvocationOnMock invocation) { + UserRepository.LoadUserCallback userCallback = + (UserRepository.LoadUserCallback) invocation.getArguments()[0]; + userCallback.onUserLoaded(user); + return userCallback; + } + }).when(mUserRepository).loadUser(any( + UserRepository.LoadUserCallback.class)); + + selectTransferMethodPresenter.loadTransferMethodConfigurationKeys(true, null, null); + + // Canada is first country in successful_tmc_keys_response.json + verify(view).showTransferMethodCountry("CA"); + verify(view).showTransferMethodCurrency("CAD"); + verify(view).showTransferMethodTypes(ArgumentMatchers.anyList()); + verify(view, never()).showErrorLoadTransferMethodConfigurationKeys( + ArgumentMatchers.anyList()); + verify(view, never()).showErrorLoadCurrency(ArgumentMatchers.anyList()); + 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(), anyString()); + } } diff --git a/transfermethodui/src/test/resources/user_al_response.json b/transfermethodui/src/test/resources/user_al_response.json new file mode 100644 index 000000000..a10d5a906 --- /dev/null +++ b/transfermethodui/src/test/resources/user_al_response.json @@ -0,0 +1,26 @@ +{ + "token": "usr-token-5", + "status": "PRE_ACTIVATED", + "createdOn": "2017-10-30T22:15:45", + "clientUserId": "123456", + "profileType": "INDIVIDUAL", + "firstName": "Person", + "lastName": "FromAlbania", + "dateOfBirth": "1991-01-01", + "email": "user+5satF1xV@hyperwallet.com", + "addressLine1": "950 Granville", + "city": "Gjirokaster", + "stateProvince": "Gjirokaster", + "country": "AL", + "postalCode": "443001", + "language": "en", + "programToken": "prg-token-2", + "links": [ + { + "params": { + "rel": "self" + }, + "href": "https://localhost/rest/v3/users/usr-token-5" + } + ] +} \ No newline at end of file