@ -16,6 +16,8 @@ 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
@ -39,6 +41,7 @@ public class HomeNotificationHandlerTest {
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 ;
@ -51,6 +54,9 @@ public class HomeNotificationHandlerTest {
return $ ( $ ( false , false , "0" , "autodebit" ) ) ;
}
private static GmeApplication . StringExtractor dummyStringExtractor = Mockito . mock ( GmeApplication . StringExtractor . class ) ;
/ /
/ / @Test
/ / @Parameters ( method = "getRequiredFlags" )
@ -68,7 +74,7 @@ public class HomeNotificationHandlerTest {
@Test
public void shouldShowAutoDebitRedirectPopup ( )
{
HomeNotificationHandler notificationHandler = new HomeNotificationHandler ( KYC_SUBMITTED_FLAG , KYC_VERIFIED_FLAG , PENNY_TEST_NOT_STARTED , AUTO_DEBIT_ROUTE_STRING ) ;
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 . getAppropriateHomeNotice ( ) . getNoticeViewType ( ) ) ;
@ -78,7 +84,7 @@ public class HomeNotificationHandlerTest {
@Test
public void shouldNotShowAutoDebitRedirectPopupForEmptryRoute ( )
{
HomeNotificationHandler notificationHandler = new HomeNotificationHandler ( KYC_SUBMITTED_FLAG , KYC_VERIFIED_FLAG , PENNY_TEST_NOT_STARTED , AUTO_DEBIT_EMPTY_ROUTE_STRING ) ;
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 . getAppropriateHomeNotice ( ) . getNoticeViewType ( ) ) ;
@ -87,7 +93,7 @@ public class HomeNotificationHandlerTest {
@Test
public void shouldNotShowAutoDebitRedirectPopupForNullRoute ( )
{
HomeNotificationHandler notificationHandler = new HomeNotificationHandler ( KYC_SUBMITTED_FLAG , KYC_VERIFIED_FLAG , PENNY_TEST_NOT_STARTED , AUTO_DEBIT__NULL_ROUTE_STRING ) ;
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 . getAppropriateHomeNotice ( ) . getNoticeViewType ( ) ) ;
@ -96,7 +102,7 @@ public class HomeNotificationHandlerTest {
@Test
public void shouldShowKYCNotSubmittedPopUpForNotSubmittedStatus ( )
{
HomeNotificationHandler notificationHandler = new HomeNotificationHandler ( KYC_NOT_SUBMITTED_FLAG , KYC_VERIFIED_FLAG , PENNY_TEST_COMPLETED , AUTO_DEBIT__NULL_ROUTE_STRING ) ;
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 . getAppropriateHomeNotice ( ) . getNoticeViewType ( ) ) ;
@ -106,7 +112,7 @@ public class HomeNotificationHandlerTest {
@Test
public void shouldNotShowKYCNotSubmittedPopUpForSubmittedStatus ( )
{
HomeNotificationHandler notificationHandler = new HomeNotificationHandler ( KYC_SUBMITTED_FLAG , KYC_NOT_VERIFIED_FLAG , PENNY_TEST_NOT_STARTED , AUTO_DEBIT__NULL_ROUTE_STRING ) ;
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 . getAppropriateHomeNotice ( ) . getNoticeViewType ( ) ) ;
}
@ -114,7 +120,7 @@ public class HomeNotificationHandlerTest {
@Test
public void shouldShowKYCNotVerifiedPopUpForUnverifiedStatus ( )
{
HomeNotificationHandler notificationHandler = new HomeNotificationHandler ( KYC_SUBMITTED_FLAG , KYC_NOT_VERIFIED_FLAG , PENNY_TEST_COMPLETED , AUTO_DEBIT__NULL_ROUTE_STRING ) ;
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 . getAppropriateHomeNotice ( ) . getNoticeViewType ( ) ) ;
@ -123,7 +129,7 @@ public class HomeNotificationHandlerTest {
@Test
public void shouldNotShowKYCNotVerifiedPopUpForVerifiedStatus ( )
{
HomeNotificationHandler notificationHandler = new HomeNotificationHandler ( KYC_SUBMITTED_FLAG , KYC_VERIFIED_FLAG , PENNY_TEST_NOT_STARTED , AUTO_DEBIT__NULL_ROUTE_STRING ) ;
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 . getAppropriateHomeNotice ( ) . getNoticeViewType ( ) ) ;
}
@ -132,7 +138,16 @@ public class HomeNotificationHandlerTest {
@Test
public void shouldShowPennyTestNotCompletedPopupForNotStartedStatus ( )
{
HomeNotificationHandler notificationHandler = new HomeNotificationHandler ( KYC_SUBMITTED_FLAG , KYC_VERIFIED_FLAG , PENNY_TEST_NOT_STARTED , AUTO_DEBIT_EMPTY_ROUTE_STRING ) ;
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 . getAppropriateHomeNotice ( ) . 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 ) ;
assertEquals ( "Should have shown penny test popup" , PENNY_TEST_REQUIRED , notificationHandler . getAppropriateHomeNotice ( ) . getNoticeViewType ( ) ) ;
@ -142,7 +157,7 @@ public class HomeNotificationHandlerTest {
@Test
public void shouldShowPennyTestNotCompletedPopupForOnlyRequestedStatus ( )
{
HomeNotificationHandler notificationHandler = new HomeNotificationHandler ( KYC_SUBMITTED_FLAG , KYC_VERIFIED_FLAG , PENNY_TEST_ONLY_REQUESTED , AUTO_DEBIT_EMPTY_ROUTE_STRING ) ;
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 . getAppropriateHomeNotice ( ) . getNoticeViewType ( ) ) ;
@ -152,10 +167,15 @@ public class HomeNotificationHandlerTest {
@Test
public void shouldNotShowPennyTestPopupForCompletedStatus ( )
{
HomeNotificationHandler notificationHandler = new HomeNotificationHandler ( KYC_SUBMITTED_FLAG , KYC_VERIFIED_FLAG , PENNY_TEST_COMPLETED , AUTO_DEBIT_EMPTY_ROUTE_STRING ) ;
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 . getAppropriateHomeNotice ( ) ) ;
}
private void stubStringExtractor ( )
{
Mockito . when ( dummyStringExtractor . getStringFromStringId ( Mockito . any ( ) ) ) . thenReturn ( "Dummy localized string" ) ;
}
}