package Ġcom . jl ife . ab on . facade Ċ Ċ import Ġcom . jl ife . ab on . entity . Transaction Ċ import Ġcom . jl ife . ab on . service . SC Configuration Service Ċ import Ġorg . apache . commons . lang 3 . Random StringUtils Ċ import Ġorg . assertj . core . api . Assertions Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . junit . Test Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . data . domain . Page Request Ċ import Ġjava . math . BigDecimal Ċ Ċ class ĠSend Many Sms Messages Test Ġ: ĠService Base TestCase () Ġ{ ĊĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġlateinit Ġvar Ġbilling Facade : ĠBilling Facade ĊĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġlateinit Ġvar Ġcompany Sms Facade : ĠCompany Sms Facade ĊĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġlateinit Ġvar Ġsc Configuration Service : ĠSC Configuration Service ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest _ bill For Two Messages _ when Two Messages W ere Sent () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcompany Ġ= Ġcompany Facade . get Company ( DEFAULT _ COMP ANY _ ID ) ĊĠĠĠĠĠĠĠ Ġval Ġaccount Ġ= Ġbilling Facade . get Account By Company Id ( DEFAULT _ COMP ANY _ ID ) ĊĠĠĠĠĠĠĠ Ġbilling Facade . do Manual Repl en ish ment ( account , ĠBigDecimal ( 2 0 )) ĊĠĠĠĠĠĠĠ Ġval Ġcard UUID s Ġ= Ġarray ListOf ( DEFAULT _ CARD _ UUID , ĠAN OTHER _ CARD _ UUID ) ĊĠĠĠĠĠĠĠ Ġval Ġall E lems Page Ġ= ĠPage Request ( 0 , ĠInteger . MAX _ VALUE ) ĊĠĠĠĠĠĠĠ Ġval Ġtransactions Before Ġ= Ġbilling Facade . find Transactions ( DEFAULT _ COMP ANY _ ID , Ġall E lems Page ) ĊĠĠĠĠĠĠĠ Ġval ĠnumberOf Transactions Before Ġ= Ġtransactions Before . total Elements ĊĠĠĠĠĠĠĠ Ġval Ġbalance Before Ġ= Ġget Company Balance () ĊĠĠĠĠĠĠĠ Ġcompany Sms Facade . send Sms Message ( card UUID s , Ġ" test Ġmessage ", ĠDEFAULT _ COMP ANY _ ID ) ĊĠĠĠĠĠĠĠ Ġval Ġtransactions After Ġ= Ġbilling Facade . find Transactions ( DEFAULT _ COMP ANY _ ID , Ġall E lems Page ) ĊĠĠĠĠĠĠĠ Ġval ĠnumberOf Transactions After Ġ= Ġtransactions After . total Elements ĊĠĠĠĠĠĠĠ Ġval Ġbalance After Ġ= Ġget Company Balance () ĊĠĠĠĠĠĠĠ Ġval Ġsms Price Ġ= Ġsc Configuration Service . getS ms Price ( company . country ). value ĊĊĠĠĠĠĠĠĠ ĠAssertions . assertThat ( numberOf Transactions After ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. isEqual By Comp aring To ( numberOf Transactions Before Ġ+ Ġcard UUID s . size ) ĊĠĠĠĠĠĠĠ ĠAssertions . assertThat ( balance After ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. isEqual By Comp aring To ( balance Before Ġ- Ġsms Price Ġ* ĠBigDecimal ( card UUID s . size )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġget Company Balance (): ĠBigDecimal Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġbilling Facade . get Account By Company Id ( DEFAULT _ COMP ANY _ ID ). balance ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest _ bill For Two Message Tw ice _ when Message More Than 7 0 Symbols () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcompany Ġ= Ġcompany Facade . get Company ( DEFAULT _ COMP ANY _ ID ) ĊĠĠĠĠĠĠĠ Ġval Ġaccount Ġ= Ġbilling Facade . get Account By Company Id ( DEFAULT _ COMP ANY _ ID ) ĊĠĠĠĠĠĠĠ Ġbilling Facade . do Manual Repl en ish ment ( account , ĠBigDecimal ( 2 0 )) ĊĠĠĠĠĠĠĠ Ġclean Collections ( Transaction :: class . java ) ĊĊĠĠĠĠĠĠĠ Ġval Ġcard UUID s Ġ= Ġarray ListOf ( DEFAULT _ CARD _ UUID , ĠAN OTHER _ CARD _ UUID ) ĊĠĠĠĠĠĠĠ Ġval Ġbalance Before Ġ= Ġget Company Balance () ĊĠĠĠĠĠĠĠ Ġvar Ġtext Msg Ġ= ĠRandom StringUtils . random ( 7 5 ); ĊĠĠĠĠĠĠĠ Ġcompany Sms Facade . send Sms Message ( card UUID s , Ġtext Msg , ĠDEFAULT _ COMP ANY _ ID ) ĊĠĠĠĠĠĠĠ Ġval Ġtransactions After Ġ= Ġbilling Facade . find Transactions ( DEFAULT _ COMP ANY _ ID , ĠMAX _ PAGE _ REQUEST ) ĊĠĠĠĠĠĠĠ Ġval ĠnumberOf Transactions After Ġ= Ġtransactions After . total Elements ĊĠĠĠĠĠĠĠ Ġval Ġbalance After Ġ= Ġget Company Balance () ĊĠĠĠĠĠĠĠ Ġval Ġsms Price Ġ= Ġsc Configuration Service . getS ms Price ( company . country ). value ĊĊĠĠĠĠĠĠĠ ĠassertThat ( numberOf Transactions After ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. isEqual By Comp aring To ( 2 ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( balance After ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. isEqual By Comp aring To ( balance Before Ġ- Ġsms Price Ġ* ĠBigDecimal ( card UUID s . size ) Ġ* ĠBigDecimal ( 2 )) ĊĊĠĠĠĠĠĠĠ Ġval Ġtransaction Data Ġ= Ġtransactions After . content [ 0 ] ĊĠĠĠĠĠĠĠ ĠassertThat ( transaction Data . value ). isEqualTo ( sms Price Ġ* ĠBigDecimal ( 2 )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest _ bill Fo One Message Tw ice _ when Message More Than 7 0 Symbols () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcompany Ġ= Ġcompany Facade . get Company ( DEFAULT _ COMP ANY _ ID ) ĊĠĠĠĠĠĠĠ Ġval Ġaccount Ġ= Ġbilling Facade . get Account By Company Id ( DEFAULT _ COMP ANY _ ID ) ĊĠĠĠĠĠĠĠ Ġbilling Facade . do Manual Repl en ish ment ( account , ĠBigDecimal ( 2 0 )) ĊĠĠĠĠĠĠĠ Ġclean Collections ( Transaction :: class . java ) ĊĊĠĠĠĠĠĠĠ Ġval Ġbalance Before Ġ= Ġget Company Balance () ĊĠĠĠĠĠĠĠ Ġvar Ġtext Msg Ġ= ĠRandom StringUtils . random ( 7 5 ); ĊĠĠĠĠĠĠĠ Ġcompany Sms Facade . send Sms Message ( DEFAULT _ CARD _ UUID , Ġtext Msg , ĠDEFAULT _ COMP ANY _ ID ) ĊĠĠĠĠĠĠĠ Ġval Ġtransactions After Ġ= Ġbilling Facade . find Transactions ( DEFAULT _ COMP ANY _ ID , ĠMAX _ PAGE _ REQUEST ) ĊĠĠĠĠĠĠĠ Ġval ĠnumberOf Transactions After Ġ= Ġtransactions After . total Elements ĊĠĠĠĠĠĠĠ Ġval Ġbalance After Ġ= Ġget Company Balance () ĊĠĠĠĠĠĠĠ Ġval Ġsms Price Ġ= Ġsc Configuration Service . getS ms Price ( company . country ). value ĊĊĠĠĠĠĠĠĠ ĠassertThat ( numberOf Transactions After ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. isEqual By Comp aring To ( 1 ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( balance After ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. isEqual By Comp aring To ( balance Before Ġ- Ġsms Price Ġ* ĠBigDecimal ( 2 )) ĊĊĠĠĠĠĠĠĠ Ġval Ġtransaction Data Ġ= Ġtransactions After . content [ 0 ] ĊĠĠĠĠĠĠĠ ĠassertThat ( transaction Data . value ). isEqualTo ( sms Price Ġ* ĠBigDecimal ( 2 )) ĊĠĠĠ Ġ} Ċ } Ċ