From 002a5bb03a7e2266bd8d4bf5799c0591b1f2c17d Mon Sep 17 00:00:00 2001 From: Preyea Regmi Date: Wed, 14 Aug 2019 16:59:46 +0900 Subject: [PATCH] Notfication precedence order fixes --- .../homeV2/model/HomeNotificationViewDTO.java | 8 +++ .../presenter/HomeNotificationHandler.java | 70 +++++++++++-------- .../homeV2/presenter/HomeV2Presenter.java | 4 +- .../HomeNotificationHandlerTest.java | 43 +++++++++--- 4 files changed, 81 insertions(+), 44 deletions(-) diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/model/HomeNotificationViewDTO.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/model/HomeNotificationViewDTO.java index 125a2e32..ee803146 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/model/HomeNotificationViewDTO.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/model/HomeNotificationViewDTO.java @@ -32,10 +32,18 @@ public class HomeNotificationViewDTO { return noticeViewType; } + /** + * Check if background of notification view needs to be made dimmer + * @return + */ public boolean isFocused() { return isFocused; } + /** + * Setting focused will make the background of notification view dimmer + * @param focused + */ public void setFocused(boolean focused) { isFocused = focused; } diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/presenter/HomeNotificationHandler.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/presenter/HomeNotificationHandler.java index eb0f4f4d..6aa9ae73 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/presenter/HomeNotificationHandler.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/presenter/HomeNotificationHandler.java @@ -6,7 +6,13 @@ import com.gmeremit.online.gmeremittance_native.homeV2.model.HomeNotificationVie /** * @author Preyea R. Regmi - * Inorder to understand the implementation of this class, consider reading the corresponding Unit Test : HomeNotificationHandlerTest + * This class is responsbile for generating appropriate notification related data that is shown in {@link com.gmeremit.online.gmeremittance_native.homeV2.view.HomeFragmentV2} + * Currently two set of Notifications are handled. + * 1) Redirect Notification + * 2) Registration Notification + * Precedence Order + *

Redirect Notification (AUTO_DEBIT_REDIRECT) >> Registration Notification (KYC_SUBMIT -> PENNY_TEST_STATUS -> KYC_VERIFIED). + * Inorder to understand the implementation of this class, consider reading the corresponding Unit Test : HomeNotificationHandlerTest

*/ public class HomeNotificationHandler { @@ -32,31 +38,31 @@ public class HomeNotificationHandler { } - private HomeNotificationHandler(GmeApplication.StringExtractor stringExtractor) - { - this.stringExtractor=stringExtractor; + private HomeNotificationHandler(GmeApplication.StringExtractor stringExtractor) { + this.stringExtractor = stringExtractor; } - public static HomeNotificationViewDTO generateNotificationFromType(GmeApplication.StringExtractor stringExtractor,HomeNoticeViewTypeEnum type) - { - return new HomeNotificationHandler(stringExtractor).generateHomeNotificaationViewExplicitlyFromType(type); + public static HomeNotificationViewDTO generateNotificationFromType(GmeApplication.StringExtractor stringExtractor, HomeNoticeViewTypeEnum type) { + return new HomeNotificationHandler(stringExtractor).generateHomeNotificaationViewExplicitlyFromType(type); } - private HomeNotificationViewDTO generateHomeNotificaationViewExplicitlyFromType(HomeNoticeViewTypeEnum type) - { - switch(type) - { + private HomeNotificationViewDTO generateHomeNotificaationViewExplicitlyFromType(HomeNoticeViewTypeEnum type) { + switch (type) { case KYC_NOT_SUBMITTED: - return new HomeNotificationViewDTO(stringExtractor.getStringFromStringId(R.string.kyc_fill_text), stringExtractor.getStringFromStringId(R.string.complete_your_registration_text), HomeNoticeViewTypeEnum.KYC_NOT_SUBMITTED); + HomeNotificationViewDTO kycNotSubmittedNotificationViewDTO = new HomeNotificationViewDTO(stringExtractor.getStringFromStringId(R.string.kyc_fill_text), stringExtractor.getStringFromStringId(R.string.complete_your_registration_text), HomeNoticeViewTypeEnum.KYC_NOT_SUBMITTED); + kycNotSubmittedNotificationViewDTO.setFocused(true); + return kycNotSubmittedNotificationViewDTO; case KYC_NOT_VERIFIED: return new HomeNotificationViewDTO(stringExtractor.getStringFromStringId(R.string.kyc_verify_pending_text), stringExtractor.getStringFromStringId(R.string.verification_in_aproval_process_text), HomeNoticeViewTypeEnum.KYC_NOT_VERIFIED); case PENNY_TEST_REQUIRED: - return new HomeNotificationViewDTO(stringExtractor.getStringFromStringId(R.string.penny_test_pending_text), stringExtractor.getStringFromStringId(R.string.complete_penny_test), HomeNoticeViewTypeEnum.PENNY_TEST_REQUIRED); + HomeNotificationViewDTO pennyTestRequiredNotificationViewDTO = new HomeNotificationViewDTO(stringExtractor.getStringFromStringId(R.string.penny_test_pending_text), stringExtractor.getStringFromStringId(R.string.complete_penny_test), HomeNoticeViewTypeEnum.PENNY_TEST_REQUIRED); + pennyTestRequiredNotificationViewDTO.setFocused(true); + return pennyTestRequiredNotificationViewDTO; case AUTO_DEBIT_FILLUP_REQUIRED: - HomeNotificationViewDTO notificationViewDTO = new HomeNotificationViewDTO(stringExtractor.getStringFromStringId(R.string.add_auto_debit_account_text), stringExtractor.getStringFromStringId(R.string.autodebit_account_required_message), HomeNoticeViewTypeEnum.AUTO_DEBIT_FILLUP_REQUIRED); - notificationViewDTO.setFocused(true); - return notificationViewDTO; + HomeNotificationViewDTO autoDebitFillUPRequiredNotificationViewDTO = new HomeNotificationViewDTO(stringExtractor.getStringFromStringId(R.string.add_auto_debit_account_text), stringExtractor.getStringFromStringId(R.string.autodebit_account_required_message), HomeNoticeViewTypeEnum.AUTO_DEBIT_FILLUP_REQUIRED); + autoDebitFillUPRequiredNotificationViewDTO.setFocused(true); + return autoDebitFillUPRequiredNotificationViewDTO; default: return null; @@ -66,21 +72,23 @@ public class HomeNotificationHandler { public HomeNotificationViewDTO generateAppropriateHomeNotificationViewDTO() { if ("autoDebit".equalsIgnoreCase(redirectTo)) { - return generateHomeNotificaationViewExplicitlyFromType(HomeNoticeViewTypeEnum.AUTO_DEBIT_FILLUP_REQUIRED); - } else { - { - if (!kycSubmit) - return generateHomeNotificaationViewExplicitlyFromType(HomeNoticeViewTypeEnum.KYC_NOT_SUBMITTED); - else { - if (!isVerified) - return generateHomeNotificaationViewExplicitlyFromType(HomeNoticeViewTypeEnum.KYC_NOT_VERIFIED); - else { - if (!"2".equalsIgnoreCase(pennyTestStatus)) - return generateHomeNotificaationViewExplicitlyFromType(HomeNoticeViewTypeEnum.PENNY_TEST_REQUIRED); - else - return null; - } - } + return generateHomeNotificaationViewExplicitlyFromType(HomeNoticeViewTypeEnum.AUTO_DEBIT_FILLUP_REQUIRED); + } else + return generateApproriateRegistrationRelatedNotification(); + + } + + private HomeNotificationViewDTO generateApproriateRegistrationRelatedNotification() { + if (!kycSubmit) + return generateHomeNotificaationViewExplicitlyFromType(HomeNoticeViewTypeEnum.KYC_NOT_SUBMITTED); + else { + if (!"2".equalsIgnoreCase(pennyTestStatus)) + return generateHomeNotificaationViewExplicitlyFromType(HomeNoticeViewTypeEnum.PENNY_TEST_REQUIRED); + else { + if (!isVerified) + return generateHomeNotificaationViewExplicitlyFromType(HomeNoticeViewTypeEnum.KYC_NOT_VERIFIED); + else + return null; } } } diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/presenter/HomeV2Presenter.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/presenter/HomeV2Presenter.java index c9eec38b..16e9ae38 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/presenter/HomeV2Presenter.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/presenter/HomeV2Presenter.java @@ -312,9 +312,9 @@ public class HomeV2Presenter extends BasePresenter implements HomeV2PresenterInt //TODO Mocking server response here userInfoModelV2.setRedirectTo(null); - userInfoModelV2.setKyc(true); + userInfoModelV2.setKyc(false); userInfoModelV2.setVerified(true); - userInfoModelV2.setPennyTestStatus("0"); + userInfoModelV2.setPennyTestStatus("2"); //TODO Mocking end diff --git a/app/src/test/java/com/gmeremit/online/gmeremittance_native/HomeNotificationHandlerTest.java b/app/src/test/java/com/gmeremit/online/gmeremittance_native/HomeNotificationHandlerTest.java index fa37a106..c06ebf52 100644 --- a/app/src/test/java/com/gmeremit/online/gmeremittance_native/HomeNotificationHandlerTest.java +++ b/app/src/test/java/com/gmeremit/online/gmeremittance_native/HomeNotificationHandlerTest.java @@ -21,13 +21,9 @@ import static org.junit.Assert.assertNull; /** * @author Preyea R. Regmi - *

- * This is unit test for notification generating process - * Currently two set of Notification shown. - * 1) Redirect Notification - * 2) Registration Notification - * Precedence Order - * Redirect Notification (AUTO_DEBIT_REDIRECT) > Registration Notification (KYC_SUBMIT, PENNY_TEST_STATUS,KYC_VERIFIED) + * This is unit test for notification generating process. + * It follows Test First Approach. @see