Browse Source

Notfication precedence order fixes

master
Preyea Regmi 5 years ago
parent
commit
002a5bb03a
  1. 8
      app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/model/HomeNotificationViewDTO.java
  2. 70
      app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/presenter/HomeNotificationHandler.java
  3. 4
      app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/presenter/HomeV2Presenter.java
  4. 43
      app/src/test/java/com/gmeremit/online/gmeremittance_native/HomeNotificationHandlerTest.java

8
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;
}

70
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
* <bold>Precedence Order</bold>
* <p>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</p>
*/
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;
}
}
}

4
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

43
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
* <p>
* 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 <a href="https://martinfowler.com/bliki/TestDrivenDevelopment.html</a>
* So before adding implementation for more cases, makes sure test case are updated and passed correspondingly.
*/
@RunWith(JUnitParamsRunner.class)
@ -140,7 +136,7 @@ public class HomeNotificationHandlerTest {
@Test
public void shouldShowPennyTestNotCompletedPopupForNotStartedStatus() {
public void shouldShowPennyTestNotCompletedPopupForNotStartedStatusAndKYCVerified() {
HomeNotificationHandler notificationHandler = new HomeNotificationHandler(dummyStringExtractor, KYC_SUBMITTED_FLAG, KYC_VERIFIED_FLAG, PENNY_TEST_NOT_STARTED, AUTO_DEBIT_EMPTY_ROUTE_STRING);
assertEquals("Should have shown penny test popup", PENNY_TEST_REQUIRED, notificationHandler.generateAppropriateHomeNotificationViewDTO().getNoticeViewType());
@ -148,7 +144,7 @@ public class HomeNotificationHandlerTest {
}
@Test
public void shouldShowPennyTestNotCompletedPopupForUndefinedStatus() {
public void shouldShowPennyTestNotCompletedPopupForUndefinedStatusAndKYCVerified() {
HomeNotificationHandler notificationHandler = new HomeNotificationHandler(dummyStringExtractor, KYC_SUBMITTED_FLAG, KYC_VERIFIED_FLAG, PENNY_TEST_STATUS_UNDEFINED, AUTO_DEBIT_EMPTY_ROUTE_STRING);
assertEquals("Should have shown penny test popup", PENNY_TEST_REQUIRED, notificationHandler.generateAppropriateHomeNotificationViewDTO().getNoticeViewType());
@ -157,16 +153,41 @@ public class HomeNotificationHandlerTest {
@Test
public void shouldShowPennyTestNotCompletedPopupForOnlyRequestedStatus() {
public void shouldShowPennyTestNotCompletedPopupForOnlyRequestedStatusAndKYCVerified() {
HomeNotificationHandler notificationHandler = new HomeNotificationHandler(dummyStringExtractor, KYC_SUBMITTED_FLAG, KYC_VERIFIED_FLAG, PENNY_TEST_ONLY_REQUESTED, AUTO_DEBIT_EMPTY_ROUTE_STRING);
assertEquals("Should have shown penny test popup", PENNY_TEST_REQUIRED, notificationHandler.generateAppropriateHomeNotificationViewDTO().getNoticeViewType());
}
@Test
public void shouldShowPennyTestNotCompletedPopupForNotStartedStatusAndNotKYCVerified() {
HomeNotificationHandler notificationHandler = new HomeNotificationHandler(dummyStringExtractor, KYC_SUBMITTED_FLAG, KYC_NOT_VERIFIED_FLAG, PENNY_TEST_NOT_STARTED, AUTO_DEBIT_EMPTY_ROUTE_STRING);
assertEquals("Should have shown penny test popup", PENNY_TEST_REQUIRED, notificationHandler.generateAppropriateHomeNotificationViewDTO().getNoticeViewType());
}
@Test
public void shouldShowPennyTestNotCompletedPopupForUndefinedStatusAndNotKYCVerified() {
HomeNotificationHandler notificationHandler = new HomeNotificationHandler(dummyStringExtractor, KYC_SUBMITTED_FLAG, KYC_NOT_VERIFIED_FLAG, PENNY_TEST_STATUS_UNDEFINED, AUTO_DEBIT_EMPTY_ROUTE_STRING);
assertEquals("Should have shown penny test popup", PENNY_TEST_REQUIRED, notificationHandler.generateAppropriateHomeNotificationViewDTO().getNoticeViewType());
}
@Test
public void shouldShowPennyTestNotCompletedPopupForOnlyRequestedStatusAndNotKYCVerified() {
HomeNotificationHandler notificationHandler = new HomeNotificationHandler(dummyStringExtractor, KYC_SUBMITTED_FLAG, KYC_NOT_VERIFIED_FLAG, PENNY_TEST_ONLY_REQUESTED, AUTO_DEBIT_EMPTY_ROUTE_STRING);
assertEquals("Should have shown penny test popup", PENNY_TEST_REQUIRED, notificationHandler.generateAppropriateHomeNotificationViewDTO().getNoticeViewType());
}
@Test
public void shouldNotShowPennyTestPopupForCompletedStatus() {
public void shouldNotShowNotVerifiedPopupForKYCVerifiedStatus() {
HomeNotificationHandler notificationHandler = new HomeNotificationHandler(dummyStringExtractor, KYC_SUBMITTED_FLAG, KYC_VERIFIED_FLAG, PENNY_TEST_COMPLETED, AUTO_DEBIT_EMPTY_ROUTE_STRING);
assertNull("Should have return null for penny test completed status", notificationHandler.generateAppropriateHomeNotificationViewDTO());

Loading…
Cancel
Save