package Ġcom . world pay . access . checkout . sample . card Ċ Ċ import Ġandroid . widget . ImageView Ċ import Ġandroidx . test . rule . Activity Test Rule Ċ import Ġcom . world pay . access . checkout . client . session . model . Session Type . CARD Ċ import Ġcom . world pay . access . checkout . sample . MainActivity Ċ import Ġcom . world pay . access . checkout . sample . R Ċ import Ġcom . world pay . access . checkout . sample . card . standard . testutil . Card Brand . MASTER CARD Ċ import Ġcom . world pay . access . checkout . sample . card . standard . testutil . Card Fragment TestUtils Ċ import Ġcom . world pay . access . checkout . sample . stub . Card Configuration Mock Stub . stub Card Configuration Ċ import Ġcom . world pay . access . checkout . sample . stub . Card Configuration Mock Stub . stub Card Configuration With Delay Ċ import Ġjava . util . concurrent . TimeUnit . MILLISECONDS Ċ import Ġkotlin . test . assertEquals Ċ import Ġorg . await ility . Await ility Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ Ċ class ĠCard Configuration Long Delay IntegrationTest Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġtimeout In Millis Ġ= Ġ 1 0 0 0 0 L ĊĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġvar Ġcard Config Rule Ġ= ĠCard Configuration Long Delay Rule ( timeout In Millis , ĠMainActivity :: class . java ) ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġcard Fragment TestUtils : ĠCard Fragment TestUtils ĊĊĠĠĠ Ġprivate Ġval Ġlu hn Valid Master card Card Ġ= Ġ" 5 5 5 5 5 5 5 5 5 5 5 5 4 4 4 4 " ĊĠĠĠ Ġprivate Ġval Ġlu hn Invalid Master card Card Ġ= Ġ" 5 5 5 5 5 5 5 5 5 5 5 1 1 1 " ĊĠĠĠ Ġprivate Ġval Ġlu hn Invalid Master card Card With Spaces Ġ= Ġ" 5 5 5 5 Ġ 5 5 5 5 Ġ 5 5 5 1 Ġ 1 1 " ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun Ġsetup () Ġ{ ĊĠĠĠĠĠĠĠ Ġcard Fragment TestUtils Ġ= ĠCard Fragment TestUtils ( card Config Rule ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ After ĊĠĠĠ Ġfun ĠtearDown () Ġ{ ĊĠĠĠĠĠĠĠ Ġstub Card Configuration ( card Config Rule . activity ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġgiven Card Configuration Call Is Delayed _ And Valid Known Card Data Is Inserted And User P resses Submit _ Then Successful Response Is Received () Ġ{ ĊĠĠĠĠĠĠĠ Ġ// ĠAssert Ġthat Ġwith Ġno Ġconfiguration Ġthat Ġthe Ġvery Ġbasic Ġvalidation Ġis Ġdone Ġon Ġlu hn Ġof Ġthe Ġcard ĊĠĠĠĠĠĠĠ Ġ// Ġand Ġthe Ġdate Ġcheck Ġand Ġthat Ġthe Ġcard Ġstill Ġcannot Ġbe Ġverified Ġ( no Ġcard Ġconfiguration ) ĊĠĠĠĠĠĠĠ Ġcard Fragment TestUtils ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. isIn InitialState () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. has No Brand () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. enter Card Details ( pan Ġ= Ġlu hn Invalid Master card Card , Ġc vc Ġ= Ġ" 1 2 3 4 ", Ġexpiry Date Ġ= Ġ" 0 1 9 9 ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. validation State Is ( pan Ġ= Ġfalse , Ġc vc Ġ= Ġtrue , Ġexpiry Date Ġ= Ġtrue ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. enabled State Is ( submit Button Ġ= Ġfalse ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. has No Brand () ĊĊĠĠĠĠĠĠĠ Ġ// ĠWait Ġuntil Ġthe Ġserver Ġreplies Ġso Ġwe Ġcan Ġsuccessfully Ġidentify Ġthe Ġcard Ġas Ġmaster card Ġbased Ġon Ġcurrent Ġinput ĊĠĠĠĠĠĠĠ ĠAwait ility . await (). at Most ( timeout In Millis , ĠMIL LI SECONDS ). until Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġassert Expected Logo ( MASTER CARD . card Brand Name ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġtrue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġcatch Ġ( ex : ĠAssertionError ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġfalse ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġ// ĠAssert Ġthat Ġwith Ġnow Ġconfiguration Ġhas Ġcome Ġback Ġthat Ġthe ĠC VC Ġis Ġinvalid Ġfor Ġmaster card ĊĠĠĠĠĠĠĠ Ġcard Fragment TestUtils ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. card Details Are ( pan Ġ= Ġlu hn Invalid Master card Card With Spaces , Ġc vc Ġ= Ġ" 1 2 3 ", Ġexpiry Date Ġ= Ġ" 0 1 / 9 9 ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. validation State Is ( pan Ġ= Ġfalse , Ġc vc Ġ= Ġtrue , Ġexpiry Date Ġ= Ġtrue ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. enabled State Is ( submit Button Ġ= Ġfalse ) ĊĊĠĠĠĠĠĠĠ Ġ// ĠRe - enter Ġa Ġlu hn Ġvalid , Ġmaster card Ġidentified Ġcard Ġand Ġvalid Ġdate Ġand Ġsubmit ĊĠĠĠĠĠĠĠ Ġcard Fragment TestUtils ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. enter Card Details ( pan Ġ= Ġlu hn Valid Master card Card , Ġexpiry Date Ġ= Ġ" 1 2 9 9 ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. validation State Is ( pan Ġ= Ġtrue , Ġc vc Ġ= Ġtrue , Ġexpiry Date Ġ= Ġtrue ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. enter Card Details ( cv c Ġ= Ġ" 1 2 3 4 5 ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. card Details Are ( cv c Ġ= Ġ" 1 2 3 ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. validation State Is ( pan Ġ= Ġtrue , Ġc vc Ġ= Ġtrue , Ġexpiry Date Ġ= Ġtrue ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. enabled State Is ( submit Button Ġ= Ġtrue ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. click Submit Button () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. request IsIn Progress () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. has Response Dialog With Message ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmap Of ( CARD Ġto Ġcard Config Rule . activity . getString ( R . string . verified _ token _ session _ reference )). toString () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġassert Expected Logo ( logo Res Name : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġlogo View Ġ= Ġcard Config Rule . activity . findViewById < ImageView >( R . id . card _ flow _ brand _ logo ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( logo Res Name , Ġlogo View . getTag ( R . integer . card _ tag )) ĊĠĠĠ Ġ} Ċ } Ċ Ċ class ĠCard Configuration Long Delay Rule ( ĊĠĠĠ Ġprivate Ġval Ġtimeout Millis : ĠLong , ĊĠĠĠ Ġactivity Class : ĠClass < MainActivity > Ċ ) Ġ: ĠActivity Test Rule < MainActivity >( activity Class ) Ġ{ ĊĊĠĠĠ Ġoverride Ġfun Ġbefore Activity La unched () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . before Activity La unched () ĊĠĠĠĠĠĠĠ Ġ// ĠThis Ġcard Ġconfiguration Ġrule Ġadds Ġstub s Ġto Ġmock Ġserver Ġto Ġsimulate Ġa Ġlong Ġdelay Ġcondition Ġon Ġthe Ġcard Ġconfiguration Ġendpoint . ĊĠĠĠĠĠĠĠ Ġ// ĠOn Ġinitial isation Ġof Ġour ĠSDK , Ġthe ĠSDK Ġwill Ġtrigger Ġa Ġcard Ġconfiguration Ġcall Ġwhich Ġwill Ġget Ġback Ġthis Ġdelayed Ġresponse . ĊĠĠĠĠĠĠĠ Ġstub Card Configuration With Delay ( timeout Millis . toInt ()) ĊĠĠĠ Ġ} Ċ } Ċ