package Ġcom . ady en . checkout . gift card Ċ Ċ import Ġcom . ady en . checkout . components . model . payments . Amount Ċ import Ġcom . ady en . checkout . gift card . util . Gift Card Balance Status Ċ import Ġcom . ady en . checkout . gift card . util . Gift Card Balance Utils Ċ import Ġorg . junit . Assert . assertEquals Ċ import Ġorg . junit . Test Ċ Ċ class ĠG ift Card Balance UtilsTest Ġ{ ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcheck Balance _ L arger Transaction Limit _ Expect Full Payment () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= ĠG ift Card Balance Utils . check Balance ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbalance Ġ= Ġcreate Amount ( 1 0 0 ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtransaction Limit Ġ= Ġcreate Amount ( 1 0 0 0 ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġamount ToBe Paid Ġ= Ġcreate Amount ( 1 0 ) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġassert ( result Ġis ĠG ift Card Balance Status . Full Payment ) ĊĠĠĠĠĠĠĠ Ġrequire ( result Ġis ĠG ift Card Balance Status . Full Payment ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 , Ġresult . amount Paid . value ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 9 0 , Ġresult . remaining Balance . value ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcheck Balance _ L arger Balance _ Expect Full Payment () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= ĠG ift Card Balance Utils . check Balance ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbalance Ġ= Ġcreate Amount ( 1 0 0 0 ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtransaction Limit Ġ= Ġcreate Amount ( 1 0 0 ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġamount ToBe Paid Ġ= Ġcreate Amount ( 1 0 ) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġassert ( result Ġis ĠG ift Card Balance Status . Full Payment ) ĊĠĠĠĠĠĠĠ Ġrequire ( result Ġis ĠG ift Card Balance Status . Full Payment ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 , Ġresult . amount Paid . value ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 9 9 0 , Ġresult . remaining Balance . value ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcheck Balance _ Null Transaction Limit _ Expect Full Payment () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= ĠG ift Card Balance Utils . check Balance ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbalance Ġ= Ġcreate Amount ( 1 0 0 ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtransaction Limit Ġ= Ġnull , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġamount ToBe Paid Ġ= Ġcreate Amount ( 1 0 ) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġassert ( result Ġis ĠG ift Card Balance Status . Full Payment ) ĊĠĠĠĠĠĠĠ Ġrequire ( result Ġis ĠG ift Card Balance Status . Full Payment ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 , Ġresult . amount Paid . value ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 9 0 , Ġresult . remaining Balance . value ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcheck Balance _ Zero Remaining Balance _ Expect Full Payment () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= ĠG ift Card Balance Utils . check Balance ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbalance Ġ= Ġcreate Amount ( 1 0 0 ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtransaction Limit Ġ= Ġcreate Amount ( 1 0 0 ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġamount ToBe Paid Ġ= Ġcreate Amount ( 1 0 0 ) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġassert ( result Ġis ĠG ift Card Balance Status . Full Payment ) ĊĠĠĠĠĠĠĠ Ġrequire ( result Ġis ĠG ift Card Balance Status . Full Payment ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 0 , Ġresult . amount Paid . value ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġresult . remaining Balance . value ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcheck Balance _ L arger Transaction Limit _ Expect Partial Payment () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= ĠG ift Card Balance Utils . check Balance ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbalance Ġ= Ġcreate Amount ( 1 0 0 ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtransaction Limit Ġ= Ġcreate Amount ( 2 0 0 ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġamount ToBe Paid Ġ= Ġcreate Amount ( 1 0 0 0 ) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġassert ( result Ġis ĠG ift Card Balance Status . Partial Payment ) ĊĠĠĠĠĠĠĠ Ġrequire ( result Ġis ĠG ift Card Balance Status . Partial Payment ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 0 , Ġresult . amount Paid . value ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġresult . remaining Balance . value ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcheck Balance _ L arger Balance _ Expect Partial Payment () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= ĠG ift Card Balance Utils . check Balance ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbalance Ġ= Ġcreate Amount ( 2 0 0 ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtransaction Limit Ġ= Ġcreate Amount ( 1 0 0 ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġamount ToBe Paid Ġ= Ġcreate Amount ( 1 0 0 0 ) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġassert ( result Ġis ĠG ift Card Balance Status . Partial Payment ) ĊĠĠĠĠĠĠĠ Ġrequire ( result Ġis ĠG ift Card Balance Status . Partial Payment ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 0 , Ġresult . amount Paid . value ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 0 , Ġresult . remaining Balance . value ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcheck Balance _ Null Transaction Limit _ Expect Partial Payment () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= ĠG ift Card Balance Utils . check Balance ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbalance Ġ= Ġcreate Amount ( 1 0 0 ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtransaction Limit Ġ= Ġnull , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġamount ToBe Paid Ġ= Ġcreate Amount ( 1 0 0 0 ) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġassert ( result Ġis ĠG ift Card Balance Status . Partial Payment ) ĊĠĠĠĠĠĠĠ Ġrequire ( result Ġis ĠG ift Card Balance Status . Partial Payment ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 0 , Ġresult . amount Paid . value ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġresult . remaining Balance . value ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcheck Balance _ Zero Remaining Balance _ Expect Partial Payment () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= ĠG ift Card Balance Utils . check Balance ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbalance Ġ= Ġcreate Amount ( 1 0 0 ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtransaction Limit Ġ= Ġcreate Amount ( 1 0 0 ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġamount ToBe Paid Ġ= Ġcreate Amount ( 2 0 0 ) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġassert ( result Ġis ĠG ift Card Balance Status . Partial Payment ) ĊĠĠĠĠĠĠĠ Ġrequire ( result Ġis ĠG ift Card Balance Status . Partial Payment ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 0 , Ġresult . amount Paid . value ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġresult . remaining Balance . value ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcheck Balance _ Balance USD _ Expect Non Matching C urrencies () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= ĠG ift Card Balance Utils . check Balance ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbalance Ġ= Ġcreate Amount ( 1 0 0 , Ġ" USD "), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtransaction Limit Ġ= Ġcreate Amount ( 5 0 0 ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġamount ToBe Paid Ġ= Ġcreate Amount ( 2 0 0 ) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġassert ( result Ġis ĠG ift Card Balance Status . Non Matching C urrencies ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcheck Balance _ Transaction Limit USD _ Expect Non Matching C urrencies () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= ĠG ift Card Balance Utils . check Balance ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbalance Ġ= Ġcreate Amount ( 1 0 0 ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtransaction Limit Ġ= Ġcreate Amount ( 5 0 0 , Ġ" USD "), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġamount ToBe Paid Ġ= Ġcreate Amount ( 2 0 0 ) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġassert ( result Ġis ĠG ift Card Balance Status . Non Matching C urrencies ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcheck Balance _ Amount USD _ Expect Non Matching C urrencies () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= ĠG ift Card Balance Utils . check Balance ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbalance Ġ= Ġcreate Amount ( 1 0 0 ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtransaction Limit Ġ= Ġnull , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġamount ToBe Paid Ġ= Ġcreate Amount ( 2 0 0 , Ġ" USD ") ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġassert ( result Ġis ĠG ift Card Balance Status . Non Matching C urrencies ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcheck Balance _ Empty Amount _ Expect Zero Amount ToBe Paid () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= ĠG ift Card Balance Utils . check Balance ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbalance Ġ= Ġcreate Amount ( 1 0 0 ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtransaction Limit Ġ= Ġcreate Amount ( 1 0 ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġamount ToBe Paid Ġ= ĠAmount . EMPTY ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġassert ( result Ġis ĠG ift Card Balance Status . Zero Amount ToBe Paid ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcheck Balance _ Zero Amount _ Expect Zero Amount ToBe Paid () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= ĠG ift Card Balance Utils . check Balance ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbalance Ġ= Ġcreate Amount ( 1 0 0 ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtransaction Limit Ġ= Ġcreate Amount ( 1 0 ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġamount ToBe Paid Ġ= Ġcreate Amount ( 0 ) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġassert ( result Ġis ĠG ift Card Balance Status . Zero Amount ToBe Paid ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcheck Balance _ Empty Balance _ Expect Zero Balance () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= ĠG ift Card Balance Utils . check Balance ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbalance Ġ= ĠAmount . EMPTY , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtransaction Limit Ġ= Ġcreate Amount ( 1 0 ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġamount ToBe Paid Ġ= Ġcreate Amount ( 1 0 0 ) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġassert ( result Ġis ĠG ift Card Balance Status . Zero Balance ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcheck Balance _ Zero Balance _ Expect Zero Balance () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= ĠG ift Card Balance Utils . check Balance ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbalance Ġ= Ġcreate Amount ( 0 ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtransaction Limit Ġ= Ġcreate Amount ( 1 0 ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġamount ToBe Paid Ġ= Ġcreate Amount ( 1 0 0 ) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġassert ( result Ġis ĠG ift Card Balance Status . Zero Balance ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġcreate Amount ( value : ĠInt , Ġcurrency : ĠString Ġ= Ġ" EUR "): ĠAmount Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠAmount (). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġthis . value Ġ= Ġvalue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġthis . currency Ġ= Ġcurrency ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ