@ -4,8 +4,10 @@ import com.gmeremit.online.gmeremittance_native.homeV2.presenter.HomeNotificatio
import org.junit.Test ;
import org.junit.runner.RunWith ;
import org.mockito.Mockito ;
import junitparams.JUnitParamsRunner ;
import junitparams.Parameters ;
import static com.gmeremit.online.gmeremittance_native.homeV2.presenter.HomeNotificationHandler.HomeNoticeViewTypeEnum.AUTO_DEBIT_FILLUP_REQUIRED ;
import static com.gmeremit.online.gmeremittance_native.homeV2.presenter.HomeNotificationHandler.HomeNoticeViewTypeEnum.KYC_NOT_SUBMITTED ;
@ -15,46 +17,50 @@ import static junitparams.JUnitParamsRunner.$;
import static org.junit.Assert.assertEquals ;
import static org.junit.Assert.assertNotEquals ;
import static org.junit.Assert.assertNull ;
import org.mockito.* ;
/ * *
* @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 > Registration Notification
*
*
* 1 ) Redirect Notification
* 2 ) Registration Notification
* Precedence Order
* Redirect Notification ( AUTO_DEBIT_REDIRECT ) > Registration Notification ( KYC_SUBMIT , KYC_VERIFIED , PENNY_TEST_STATUS )
* /
@RunWith ( JUnitParamsRunner . class )
public class HomeNotificationHandlerTest {
private static final String AUTO_DEBIT_ROUTE_STRING = "autoDebit" ;
private static final String AUTO_DEBIT_EMPTY_ROUTE_STRING = "" ;
private static final String AUTO_DEBIT__NULL_ROUTE_STRING = null ;
private static final String AUTO_DEBIT_ROUTE_STRING = "autoDebit" ;
private static final String AUTO_DEBIT_EMPTY_ROUTE_STRING = "" ;
private static final String AUTO_DEBIT__NULL_ROUTE_STRING = null ;
private static final String PENNY_TEST_NOT_STARTED = "0" ;
private static final String PENNY_TEST_ONLY_REQUESTED = "1" ;
private static final String PENNY_TEST_COMPLETED = "2" ;
private static final String PENNY_TEST_STATUS_UNDEFINED = null ;
private static final String PENNY_TEST_NOT_STARTED = "0" ;
private static final String PENNY_TEST_ONLY_REQUESTED = "1" ;
private static final String PENNY_TEST_COMPLETED = "2" ;
private static final String PENNY_TEST_STATUS_UNDEFINED = null ;
private static final boolean KYC_NOT_VERIFIED_FLAG = false ;
private static final boolean KYC_VERIFIED_FLAG = true ;
private static final boolean KYC_NOT_VERIFIED_FLAG = false ;
private static final boolean KYC_VERIFIED_FLAG = true ;
private static final boolean KYC_NOT_SUBMITTED_FLAG = false ;
private static final boolean KYC_SUBMITTED_FLAG = true ;
private static final boolean KYC_NOT_SUBMITTED_FLAG = false ;
private static final boolean KYC_SUBMITTED_FLAG = true ;
public static Object [ ] getRequiredFlags ( )
{
return $ ( $ ( false , false , "0" , "autodebit" ) ) ;
public static Object [ ] getRequiredFlags ( ) {
return $ ( $ ( false , false , "2" , "autodebit" ) ) ;
}
private static GmeApplication . StringExtractor dummyStringExtractor = Mockito . mock ( GmeApplication . StringExtractor . class ) ;
public static Object [ ] getInvalidPennyTestContructorParam ( ) {
return $ (
$ ( false , false , "" , "autodebit" ) , $ ( false , false , null , "autodebit" ) , $ ( false , false , "-1" , "autodebit" ) , $ ( false , false , "3" , "autodebit" )
) ;
}
private static GmeApplication . StringExtractor dummyStringExtractor = Mockito . mock ( GmeApplication . StringExtractor . class ) ;
/ /
@ -71,111 +77,104 @@ public class HomeNotificationHandlerTest {
/ /
/ / }
@Test
public void shouldShowAutoDebitRedirectPopup ( )
{
HomeNotificationHandler notificationHandler = new HomeNotificationHandler ( dummyStringExtractor , KYC_SUBMITTED_FLAG , KYC_VERIFIED_FLAG , PENNY_TEST_NOT_STARTED , AUTO_DEBIT_ROUTE_STRING ) ;
/ / @Test ( expected = IllegalArgumentException . class )
/ / @Parameters ( method = "getRequiredFlags" )
/ / public void throwIAEIFConstructorArgumentValueIsInvalid ( boolean kycSubmit , boolean isVerified , String pennyTestSTatus , String redirectTo ) {
/ / new HomeNotificationHandler ( dummyStringExtractor , kycSubmit , isVerified , pennyTestSTatus , redirectTo ) ;
/ / }
assertEquals ( "Should have shown auto debit route popup" , AUTO_DEBIT_FILLUP_REQUIRED , notificationHandler . generateAppropriateHomeNotificationViewDTO ( ) . getNoticeViewType ( ) ) ;
@Test
public void shouldShowAutoDebitRedirectPopup ( ) {
HomeNotificationHandler notificationHandler = new HomeNotificationHandler ( dummyStringExtractor , KYC_SUBMITTED_FLAG , KYC_VERIFIED_FLAG , PENNY_TEST_NOT_STARTED , AUTO_DEBIT_ROUTE_STRING ) ;
assertEquals ( "Should have shown auto debit route popup" , AUTO_DEBIT_FILLUP_REQUIRED , notificationHandler . generateAppropriateHomeNotificationViewDTO ( ) . getNoticeViewType ( ) ) ;
}
@Test
public void shouldNotShowAutoDebitRedirectPopupForEmptryRoute ( )
{
HomeNotificationHandler notificationHandler = new HomeNotificationHandler ( dummyStringExtractor , KYC_SUBMITTED_FLAG , KYC_VERIFIED_FLAG , PENNY_TEST_NOT_STARTED , AUTO_DEBIT_EMPTY_ROUTE_STRING ) ;
public void shouldNotShowAutoDebitRedirectPopupForEmptryRoute ( ) {
HomeNotificationHandler notificationHandler = new HomeNotificationHandler ( dummyStringExtractor , KYC_SUBMITTED_FLAG , KYC_VERIFIED_FLAG , PENNY_TEST_NOT_STARTED , AUTO_DEBIT_EMPTY_ROUTE_STRING ) ;
assertNotEquals ( "Should not have shown auto debit route popup" , AUTO_DEBIT_FILLUP_REQUIRED , notificationHandler . generateAppropriateHomeNotificationViewDTO ( ) . getNoticeViewType ( ) ) ;
assertNotEquals ( "Should not have shown auto debit route popup" , AUTO_DEBIT_FILLUP_REQUIRED , notificationHandler . generateAppropriateHomeNotificationViewDTO ( ) . getNoticeViewType ( ) ) ;
}
@Test
public void shouldNotShowAutoDebitRedirectPopupForNullRoute ( )
{
HomeNotificationHandler notificationHandler = new HomeNotificationHandler ( dummyStringExtractor , KYC_SUBMITTED_FLAG , KYC_VERIFIED_FLAG , PENNY_TEST_NOT_STARTED , AUTO_DEBIT__NULL_ROUTE_STRING ) ;
public void shouldNotShowAutoDebitRedirectPopupForNullRoute ( ) {
HomeNotificationHandler notificationHandler = new HomeNotificationHandler ( dummyStringExtractor , KYC_SUBMITTED_FLAG , KYC_VERIFIED_FLAG , PENNY_TEST_NOT_STARTED , AUTO_DEBIT__NULL_ROUTE_STRING ) ;
assertNotEquals ( "Should not have shown auto debit route popup" , AUTO_DEBIT_FILLUP_REQUIRED , notificationHandler . generateAppropriateHomeNotificationViewDTO ( ) . getNoticeViewType ( ) ) ;
assertNotEquals ( "Should not have shown auto debit route popup" , AUTO_DEBIT_FILLUP_REQUIRED , notificationHandler . generateAppropriateHomeNotificationViewDTO ( ) . getNoticeViewType ( ) ) ;
}
@Test
public void shouldShowKYCNotSubmittedPopUpForNotSubmittedStatus ( )
{
HomeNotificationHandler notificationHandler = new HomeNotificationHandler ( dummyStringExtractor , KYC_NOT_SUBMITTED_FLAG , KYC_VERIFIED_FLAG , PENNY_TEST_COMPLETED , AUTO_DEBIT__NULL_ROUTE_STRING ) ;
public void shouldShowKYCNotSubmittedPopUpForNotSubmittedStatus ( ) {
HomeNotificationHandler notificationHandler = new HomeNotificationHandler ( dummyStringExtractor , KYC_NOT_SUBMITTED_FLAG , KYC_VERIFIED_FLAG , PENNY_TEST_COMPLETED , AUTO_DEBIT__NULL_ROUTE_STRING ) ;
assertEquals ( "Should have shown kyc not submitted popup" , KYC_NOT_SUBMITTED , notificationHandler . generateAppropriateHomeNotificationViewDTO ( ) . getNoticeViewType ( ) ) ;
assertEquals ( "Should have shown kyc not submitted popup" , KYC_NOT_SUBMITTED , notificationHandler . generateAppropriateHomeNotificationViewDTO ( ) . getNoticeViewType ( ) ) ;
}
@Test
public void shouldNotShowKYCNotSubmittedPopUpForSubmittedStatus ( )
{
HomeNotificationHandler notificationHandler = new HomeNotificationHandler ( dummyStringExtractor , KYC_SUBMITTED_FLAG , KYC_NOT_VERIFIED_FLAG , PENNY_TEST_NOT_STARTED , AUTO_DEBIT__NULL_ROUTE_STRING ) ;
assertNotEquals ( "Should not have shown kyc not submitted popup" , KYC_NOT_SUBMITTED , notificationHandler . generateAppropriateHomeNotificationViewDTO ( ) . getNoticeViewType ( ) ) ;
public void shouldNotShowKYCNotSubmittedPopUpForSubmittedStatus ( ) {
HomeNotificationHandler notificationHandler = new HomeNotificationHandler ( dummyStringExtractor , KYC_SUBMITTED_FLAG , KYC_NOT_VERIFIED_FLAG , PENNY_TEST_NOT_STARTED , AUTO_DEBIT__NULL_ROUTE_STRING ) ;
assertNotEquals ( "Should not have shown kyc not submitted popup" , KYC_NOT_SUBMITTED , notificationHandler . generateAppropriateHomeNotificationViewDTO ( ) . getNoticeViewType ( ) ) ;
}
@Test
public void shouldShowKYCNotVerifiedPopUpForUnverifiedStatus ( )
{
HomeNotificationHandler notificationHandler = new HomeNotificationHandler ( dummyStringExtractor , KYC_SUBMITTED_FLAG , KYC_NOT_VERIFIED_FLAG , PENNY_TEST_COMPLETED , AUTO_DEBIT__NULL_ROUTE_STRING ) ;
public void shouldShowKYCNotVerifiedPopUpForUnverifiedStatus ( ) {
HomeNotificationHandler notificationHandler = new HomeNotificationHandler ( dummyStringExtractor , KYC_SUBMITTED_FLAG , KYC_NOT_VERIFIED_FLAG , PENNY_TEST_COMPLETED , AUTO_DEBIT__NULL_ROUTE_STRING ) ;
assertEquals ( "Should have shown kyc not verified popup" , KYC_NOT_VERIFIED , notificationHandler . generateAppropriateHomeNotificationViewDTO ( ) . getNoticeViewType ( ) ) ;
assertEquals ( "Should have shown kyc not verified popup" , KYC_NOT_VERIFIED , notificationHandler . generateAppropriateHomeNotificationViewDTO ( ) . getNoticeViewType ( ) ) ;
}
@Test
public void shouldNotShowKYCNotVerifiedPopUpForVerifiedStatus ( )
{
HomeNotificationHandler notificationHandler = new HomeNotificationHandler ( dummyStringExtractor , KYC_SUBMITTED_FLAG , KYC_VERIFIED_FLAG , PENNY_TEST_NOT_STARTED , AUTO_DEBIT__NULL_ROUTE_STRING ) ;
assertNotEquals ( "Should not have shown kyc not verified popup" , KYC_NOT_VERIFIED , notificationHandler . generateAppropriateHomeNotificationViewDTO ( ) . getNoticeViewType ( ) ) ;
public void shouldNotShowKYCNotVerifiedPopUpForVerifiedStatus ( ) {
HomeNotificationHandler notificationHandler = new HomeNotificationHandler ( dummyStringExtractor , KYC_SUBMITTED_FLAG , KYC_VERIFIED_FLAG , PENNY_TEST_NOT_STARTED , AUTO_DEBIT__NULL_ROUTE_STRING ) ;
assertNotEquals ( "Should not have shown kyc not verified popup" , KYC_NOT_VERIFIED , notificationHandler . generateAppropriateHomeNotificationViewDTO ( ) . getNoticeViewType ( ) ) ;
}
@Test
public void shouldShowPennyTestNotCompletedPopupForNotStartedStatus ( )
{
HomeNotificationHandler notificationHandler = new HomeNotificationHandler ( dummyStringExtractor , KYC_SUBMITTED_FLAG , KYC_VERIFIED_FLAG , PENNY_TEST_NOT_STARTED , AUTO_DEBIT_EMPTY_ROUTE_STRING ) ;
public void shouldShowPennyTestNotCompletedPopupForNotStartedStatus ( ) {
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 ( ) ) ;
assertEquals ( "Should have shown penny test popup" , PENNY_TEST_REQUIRED , notificationHandler . generateAppropriateHomeNotificationViewDTO ( ) . getNoticeViewType ( ) ) ;
}
@Test
public void shouldShowPennyTestNotCompletedPopupForUndefinedStatus ( )
{
HomeNotificationHandler notificationHandler = new HomeNotificationHandler ( dummyStringExtractor , KYC_SUBMITTED_FLAG , KYC_VERIFIED_FLAG , PENNY_TEST_STATUS_UNDEFINED , AUTO_DEBIT_EMPTY_ROUTE_STRING ) ;
public void shouldShowPennyTestNotCompletedPopupForUndefinedStatus ( ) {
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 ( ) ) ;
assertEquals ( "Should have shown penny test popup" , PENNY_TEST_REQUIRED , notificationHandler . generateAppropriateHomeNotificationViewDTO ( ) . getNoticeViewType ( ) ) ;
}
@Test
public void shouldShowPennyTestNotCompletedPopupForOnlyRequestedStatus ( )
{
HomeNotificationHandler notificationHandler = new HomeNotificationHandler ( dummyStringExtractor , KYC_SUBMITTED_FLAG , KYC_VERIFIED_FLAG , PENNY_TEST_ONLY_REQUESTED , AUTO_DEBIT_EMPTY_ROUTE_STRING ) ;
public void shouldShowPennyTestNotCompletedPopupForOnlyRequestedStatus ( ) {
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 ( ) ) ;
assertEquals ( "Should have shown penny test popup" , PENNY_TEST_REQUIRED , notificationHandler . generateAppropriateHomeNotificationViewDTO ( ) . getNoticeViewType ( ) ) ;
}
@Test
public void shouldNotShowPennyTestPopupForCompletedStatus ( )
{
HomeNotificationHandler notificationHandler = new HomeNotificationHandler ( dummyStringExtractor , KYC_SUBMITTED_FLAG , KYC_VERIFIED_FLAG , PENNY_TEST_COMPLETED , AUTO_DEBIT_EMPTY_ROUTE_STRING ) ;
public void shouldNotShowPennyTestPopupForCompletedStatus ( ) {
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 ( ) ) ;
assertNull ( "Should have return null for penny test completed status" , notificationHandler . generateAppropriateHomeNotificationViewDTO ( ) ) ;
}
private void stubStringExtractor ( )
{
Mockito . when ( dummyStringExtractor . getStringFromStringId ( Mockito . any ( ) ) ) . thenReturn ( "Dummy localized string" ) ;
private void stubStringExtractor ( ) {
Mockito . when ( dummyStringExtractor . getStringFromStringId ( Mockito . any ( ) ) ) . thenReturn ( "Dummy localized string" ) ;
}
}