/* Ċ Ġ* ĠCopyright Ġ 2 0 1 9 ĠF rol lo Ċ Ġ* Ċ Ġ* ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ Ġ* Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ Ġ* Ċ Ġ* ĠĠĠ Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* Ċ Ġ* ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ Ġ* Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ Ġ* ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ Ġ* ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ Ġ* Ġlimitations Ġunder Ġthe ĠLicense . Ċ Ġ*/ Ċ Ċ package Ġus . f rol lo . f rol lo sdk . database . dao Ċ Ċ import Ġandroid . app . Application Ċ import Ġandroidx . arch . core . executor . testing . Instant Task Executor Rule Ċ import Ġandroidx . test . platform . app . Instrumentation Registry Ċ import Ġcom . jak ew h art on . th reet en ab p . Android Three Ten Ċ import Ġcom . jr ask a . li ved ata . test Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Assert . assertEquals Ċ import Ġorg . junit . Assert . assertTrue Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġus . f rol lo . f rol lo sdk . database . SDK Database Ċ import Ġus . f rol lo . f rol lo sdk . extensions . sql For Existing Account Balance Reports Ċ import Ġus . f rol lo . f rol lo sdk . extensions . sql For Fetching Account Balance Reports Ċ import Ġus . f rol lo . f rol lo sdk . extensions . sql For St ale Ids Account Balance Reports Ċ import Ġus . f rol lo . f rol lo sdk . mapping . to Account Ċ import Ġus . f rol lo . f rol lo sdk . model . core data . aggregation . accounts . Account Type Ċ import Ġus . f rol lo . f rol lo sdk . model . core data . reports . Report Period Ċ import Ġus . f rol lo . f rol lo sdk . model . test Account ResponseData Ċ import Ġus . f rol lo . f rol lo sdk . model . test Report Account Balance Data Ċ import Ġjava . math . BigDecimal Ċ Ċ class ĠReport Account Balance Dao Test Ġ{ ĊĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġval Ġtest Rule Ġ= ĠInstant Task Executor Rule () ĊĊĠĠĠ Ġprivate Ġval Ġapp Ġ= ĠInstrument ation Registry . get Instrumentation (). target Context . application Context Ġas ĠApplication ĊĠĠĠ Ġprivate Ġval Ġdb Ġ= ĠSDK Database . getInstance ( app ) ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ ĠAndroid Three Ten . init ( app ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ After ĊĠĠĠ Ġfun ĠtearDown () Ġ{ ĊĠĠĠĠĠĠĠ Ġdb . clear All Tables () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Load With Relation () Ġ{ ĊĠĠĠĠĠĠĠ Ġdb . accounts (). insert ( test Account ResponseData ( accountId Ġ= Ġ 2 3 4 , Ġprovider AccountId Ġ= Ġ 3 4 5 , Ġaccount Type Ġ= ĠAccount Type . BANK ). to Account ()) ĊĠĠĠĠĠĠĠ Ġdb . accounts (). insert ( test Account ResponseData ( accountId Ġ= Ġ 2 3 5 , Ġprovider AccountId Ġ= Ġ 3 4 5 , Ġaccount Type Ġ= ĠAccount Type . CRED IT _ CARD ). to Account ()) ĊĊĠĠĠĠĠĠĠ Ġval Ġdata 1 Ġ= Ġtest Report Account Balance Data ( date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġperiod Ġ= ĠReport Period . MONTH , ĠaccountId Ġ= Ġ 2 3 4 ) ĊĠĠĠĠĠĠĠ Ġval Ġdata 2 Ġ= Ġtest Report Account Balance Data ( date Ġ= Ġ" 2 0 1 8 - 0 2 ", Ġperiod Ġ= ĠReport Period . MONTH , ĠaccountId Ġ= Ġ 2 3 5 ) ĊĠĠĠĠĠĠĠ Ġval Ġdata 3 Ġ= Ġtest Report Account Balance Data ( date Ġ= Ġ" 2 0 1 8 - 0 3 ", Ġperiod Ġ= ĠReport Period . MONTH , ĠaccountId Ġ= Ġ 2 3 4 ) ĊĠĠĠĠĠĠĠ Ġval Ġdata 4 Ġ= Ġtest Report Account Balance Data ( date Ġ= Ġ" 2 0 1 8 - 0 1 - 0 1 ", Ġperiod Ġ= ĠReport Period . DAY , ĠaccountId Ġ= Ġ 2 3 4 ) ĊĠĠĠĠĠĠĠ Ġval Ġdata 5 Ġ= Ġtest Report Account Balance Data ( date Ġ= Ġ" 2 0 1 8 - 0 1 - 0 2 ", Ġperiod Ġ= ĠReport Period . DAY , ĠaccountId Ġ= Ġ 2 3 4 ) ĊĠĠĠĠĠĠĠ Ġval Ġdata 6 Ġ= Ġtest Report Account Balance Data ( date Ġ= Ġ" 2 0 1 8 - 0 1 - 1 ", Ġperiod Ġ= ĠReport Period . WEEK , ĠaccountId Ġ= Ġ 2 3 4 ) ĊĠĠĠĠĠĠĠ Ġval Ġdata 7 Ġ= Ġtest Report Account Balance Data ( date Ġ= Ġ" 2 0 1 8 - 0 1 - 2 ", Ġperiod Ġ= ĠReport Period . WEEK , ĠaccountId Ġ= Ġ 2 3 4 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġlist Ġ= Ġmutable ListOf ( data 1 , Ġdata 2 , Ġdata 3 , Ġdata 4 , Ġdata 5 , Ġdata 6 , Ġdata 7 ) ĊĊĠĠĠĠĠĠĠ Ġdb . reports Account Balance (). insert (* list . to Typed Array ()) ĊĊĠĠĠĠĠĠĠ Ġvar Ġsql Ġ= Ġsql For Fetching Account Balance Reports ( from Date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġto Date Ġ= Ġ" 2 0 1 8 - 0 3 ", Ġperiod Ġ= ĠReport Period . MONTH ) ĊĠĠĠĠĠĠĠ Ġvar Ġtest Observer Ġ= Ġdb . reports Account Balance (). load With Relation ( sql ). test () ĊĠĠĠĠĠĠĠ Ġtest Observer . await Value () ĊĠĠĠĠĠĠĠ ĠassertTrue ( test Observer . value (). isNotEmpty ()) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 3 , Ġtest Observer . value (). size ) ĊĠĠĠĠĠĠĠ Ġvar Ġmodel Ġ= Ġtest Observer . value ()[ 0 ] ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 3 4 L , Ġmodel . account ?. account ?. accountId ) ĊĠĠĠĠĠĠĠ Ġmodel Ġ= Ġtest Observer . value ()[ 1 ] ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 3 5 L , Ġmodel . account ?. account ?. accountId ) ĊĊĠĠĠĠĠĠĠ Ġsql Ġ= Ġsql For Fetching Account Balance Reports ( from Date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġto Date Ġ= Ġ" 2 0 1 8 - 0 3 ", Ġperiod Ġ= ĠReport Period . MONTH , Ġaccount Type Ġ= ĠAccount Type . CRED IT _ CARD ) ĊĠĠĠĠĠĠĠ Ġtest Observer Ġ= Ġdb . reports Account Balance (). load With Relation ( sql ). test () ĊĠĠĠĠĠĠĠ Ġtest Observer . await Value () ĊĠĠĠĠĠĠĠ ĠassertTrue ( test Observer . value (). isNotEmpty ()) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġtest Observer . value (). size ) ĊĠĠĠĠĠĠĠ Ġmodel Ġ= Ġtest Observer . value ()[ 0 ] ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 3 5 L , Ġmodel . account ?. account ?. accountId ) ĊĊĠĠĠĠĠĠĠ Ġsql Ġ= Ġsql For Fetching Account Balance Reports ( from Date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġto Date Ġ= Ġ" 2 0 1 8 - 0 3 ", Ġperiod Ġ= ĠReport Period . MONTH , Ġaccount Type Ġ= ĠAccount Type . BANK ) ĊĠĠĠĠĠĠĠ Ġtest Observer Ġ= Ġdb . reports Account Balance (). load With Relation ( sql ). test () ĊĠĠĠĠĠĠĠ Ġtest Observer . await Value () ĊĠĠĠĠĠĠĠ ĠassertTrue ( test Observer . value (). isNotEmpty ()) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 , Ġtest Observer . value (). size ) ĊĠĠĠĠĠĠĠ Ġmodel Ġ= Ġtest Observer . value ()[ 0 ] ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 3 4 L , Ġmodel . account ?. account ?. accountId ) ĊĊĠĠĠĠĠĠĠ Ġsql Ġ= Ġsql For Fetching Account Balance Reports ( from Date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġto Date Ġ= Ġ" 2 0 1 8 - 0 3 ", Ġperiod Ġ= ĠReport Period . MONTH , ĠaccountId Ġ= Ġ 2 3 4 ) ĊĠĠĠĠĠĠĠ Ġtest Observer Ġ= Ġdb . reports Account Balance (). load With Relation ( sql ). test () ĊĠĠĠĠĠĠĠ Ġtest Observer . await Value () ĊĠĠĠĠĠĠĠ ĠassertTrue ( test Observer . value (). isNotEmpty ()) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 , Ġtest Observer . value (). size ) ĊĠĠĠĠĠĠĠ Ġmodel Ġ= Ġtest Observer . value ()[ 0 ] ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 3 4 L , Ġmodel . account ?. account ?. accountId ) ĊĊĠĠĠĠĠĠĠ Ġsql Ġ= Ġsql For Fetching Account Balance Reports ( from Date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġto Date Ġ= Ġ" 2 0 1 8 - 1 2 ", Ġperiod Ġ= ĠReport Period . MONTH , ĠaccountId Ġ= Ġ 2 3 6 ) ĊĠĠĠĠĠĠĠ Ġtest Observer Ġ= Ġdb . reports Account Balance (). load With Relation ( sql ). test () ĊĠĠĠĠĠĠĠ Ġtest Observer . await Value () ĊĠĠĠĠĠĠĠ ĠassertTrue ( test Observer . value (). isEmpty ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Find Reports () Ġ{ ĊĠĠĠĠĠĠĠ Ġdb . accounts (). insert ( test Account ResponseData ( accountId Ġ= Ġ 2 3 4 , Ġprovider AccountId Ġ= Ġ 3 4 5 , Ġaccount Type Ġ= ĠAccount Type . BANK ). to Account ()) ĊĠĠĠĠĠĠĠ Ġdb . accounts (). insert ( test Account ResponseData ( accountId Ġ= Ġ 2 3 5 , Ġprovider AccountId Ġ= Ġ 3 4 5 , Ġaccount Type Ġ= ĠAccount Type . CRED IT _ CARD ). to Account ()) ĊĠĠĠĠĠĠĠ Ġdb . accounts (). insert ( test Account ResponseData ( accountId Ġ= Ġ 2 3 6 , Ġprovider AccountId Ġ= Ġ 3 4 5 , Ġaccount Type Ġ= ĠAccount Type . BANK ). to Account ()) ĊĊĠĠĠĠĠĠĠ Ġval Ġdata 1 Ġ= Ġtest Report Account Balance Data ( date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġperiod Ġ= ĠReport Period . MONTH , ĠaccountId Ġ= Ġ 2 3 4 ) ĊĠĠĠĠĠĠĠ Ġval Ġdata 2 Ġ= Ġtest Report Account Balance Data ( date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġperiod Ġ= ĠReport Period . MONTH , ĠaccountId Ġ= Ġ 2 3 5 ) ĊĠĠĠĠĠĠĠ Ġval Ġdata 3 Ġ= Ġtest Report Account Balance Data ( date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġperiod Ġ= ĠReport Period . MONTH , ĠaccountId Ġ= Ġ 2 3 6 ) ĊĠĠĠĠĠĠĠ Ġval Ġdata 4 Ġ= Ġtest Report Account Balance Data ( date Ġ= Ġ" 2 0 1 8 - 0 2 ", Ġperiod Ġ= ĠReport Period . MONTH , ĠaccountId Ġ= Ġ 2 3 4 ) ĊĠĠĠĠĠĠĠ Ġval Ġdata 5 Ġ= Ġtest Report Account Balance Data ( date Ġ= Ġ" 2 0 1 8 - 0 2 ", Ġperiod Ġ= ĠReport Period . MONTH , ĠaccountId Ġ= Ġ 2 3 5 ) ĊĠĠĠĠĠĠĠ Ġval Ġdata 6 Ġ= Ġtest Report Account Balance Data ( date Ġ= Ġ" 2 0 1 8 - 0 2 ", Ġperiod Ġ= ĠReport Period . MONTH , ĠaccountId Ġ= Ġ 2 3 6 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġlist Ġ= Ġmutable ListOf ( data 1 , Ġdata 2 , Ġdata 3 , Ġdata 4 , Ġdata 5 , Ġdata 6 ) ĊĊĠĠĠĠĠĠĠ Ġdb . reports Account Balance (). insert (* list . to Typed Array ()) ĊĊĠĠĠĠĠĠĠ Ġvar Ġsql Ġ= Ġsql For Existing Account Balance Reports ( date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġperiod Ġ= ĠReport Period . MONTH , Ġreport Account Ids Ġ= Ġlong ArrayOf ( 2 3 4 , Ġ 2 3 5 )) ĊĠĠĠĠĠĠĠ Ġvar Ġmodels Ġ= Ġdb . reports Account Balance (). find ( sql ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 , Ġmodels . size ) ĊĊĠĠĠĠĠĠĠ Ġsql Ġ= Ġsql For Existing Account Balance Reports ( date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġperiod Ġ= ĠReport Period . MONTH , Ġreport Account Ids Ġ= Ġlong ArrayOf ( 2 3 4 , Ġ 2 3 5 , Ġ 2 3 6 ), Ġaccount Type Ġ= ĠAccount Type . CRED IT _ CARD ) ĊĠĠĠĠĠĠĠ Ġmodels Ġ= Ġdb . reports Account Balance (). find ( sql ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġmodels . size ) ĊĊĠĠĠĠĠĠĠ Ġsql Ġ= Ġsql For Existing Account Balance Reports ( date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġperiod Ġ= ĠReport Period . MONTH , Ġreport Account Ids Ġ= Ġlong ArrayOf ( 2 3 4 , Ġ 2 3 5 , Ġ 2 3 6 ), Ġaccount Type Ġ= ĠAccount Type . BANK ) ĊĠĠĠĠĠĠĠ Ġmodels Ġ= Ġdb . reports Account Balance (). find ( sql ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 , Ġmodels . size ) ĊĊĠĠĠĠĠĠĠ Ġsql Ġ= Ġsql For Existing Account Balance Reports ( date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġperiod Ġ= ĠReport Period . MONTH , Ġreport Account Ids Ġ= Ġlong ArrayOf ( 2 3 4 , Ġ 2 3 5 ), ĠaccountId Ġ= Ġ 2 3 4 ) ĊĠĠĠĠĠĠĠ Ġmodels Ġ= Ġdb . reports Account Balance (). find ( sql ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġmodels . size ) ĊĊĠĠĠĠĠĠĠ Ġsql Ġ= Ġsql For Existing Account Balance Reports ( date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġperiod Ġ= ĠReport Period . MONTH , Ġreport Account Ids Ġ= Ġlong ArrayOf (), ĠaccountId Ġ= Ġ 2 3 8 ) ĊĠĠĠĠĠĠĠ Ġmodels Ġ= Ġdb . reports Account Balance (). find ( sql ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġmodels . size ) ĊĊĠĠĠĠĠĠĠ Ġsql Ġ= Ġsql For Existing Account Balance Reports ( date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġperiod Ġ= ĠReport Period . MONTH , Ġreport Account Ids Ġ= Ġlong ArrayOf ( 2 3 4 , Ġ 2 3 5 , Ġ 2 3 6 ), Ġaccount Type Ġ= ĠAccount Type . B ILL ) ĊĠĠĠĠĠĠĠ Ġmodels Ġ= Ġdb . reports Account Balance (). find ( sql ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġmodels . size ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Find St ale Ids () Ġ{ ĊĠĠĠĠĠĠĠ Ġdb . accounts (). insert ( test Account ResponseData ( accountId Ġ= Ġ 2 3 4 , Ġprovider AccountId Ġ= Ġ 3 4 5 , Ġaccount Type Ġ= ĠAccount Type . BANK ). to Account ()) ĊĠĠĠĠĠĠĠ Ġdb . accounts (). insert ( test Account ResponseData ( accountId Ġ= Ġ 2 3 5 , Ġprovider AccountId Ġ= Ġ 3 4 5 , Ġaccount Type Ġ= ĠAccount Type . CRED IT _ CARD ). to Account ()) ĊĠĠĠĠĠĠĠ Ġdb . accounts (). insert ( test Account ResponseData ( accountId Ġ= Ġ 2 3 6 , Ġprovider AccountId Ġ= Ġ 3 4 5 , Ġaccount Type Ġ= ĠAccount Type . BANK ). to Account ()) ĊĠĠĠĠĠĠĠ Ġdb . accounts (). insert ( test Account ResponseData ( accountId Ġ= Ġ 2 3 7 , Ġprovider AccountId Ġ= Ġ 3 4 5 , Ġaccount Type Ġ= ĠAccount Type . CRED IT _ CARD ). to Account ()) ĊĊĠĠĠĠĠĠĠ Ġval Ġdata 1 Ġ= Ġtest Report Account Balance Data ( date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġperiod Ġ= ĠReport Period . MONTH , ĠaccountId Ġ= Ġ 2 3 4 , Ġid Ġ= Ġ 1 0 0 ) ĊĠĠĠĠĠĠĠ Ġval Ġdata 2 Ġ= Ġtest Report Account Balance Data ( date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġperiod Ġ= ĠReport Period . MONTH , ĠaccountId Ġ= Ġ 2 3 5 , Ġid Ġ= Ġ 1 0 1 ) ĊĠĠĠĠĠĠĠ Ġval Ġdata 3 Ġ= Ġtest Report Account Balance Data ( date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġperiod Ġ= ĠReport Period . MONTH , ĠaccountId Ġ= Ġ 2 3 6 , Ġid Ġ= Ġ 1 0 2 ) ĊĠĠĠĠĠĠĠ Ġval Ġdata 4 Ġ= Ġtest Report Account Balance Data ( date Ġ= Ġ" 2 0 1 8 - 0 2 ", Ġperiod Ġ= ĠReport Period . MONTH , ĠaccountId Ġ= Ġ 2 3 4 , Ġid Ġ= Ġ 1 0 3 ) ĊĠĠĠĠĠĠĠ Ġval Ġdata 5 Ġ= Ġtest Report Account Balance Data ( date Ġ= Ġ" 2 0 1 8 - 0 2 ", Ġperiod Ġ= ĠReport Period . MONTH , ĠaccountId Ġ= Ġ 2 3 5 , Ġid Ġ= Ġ 1 0 4 ) ĊĠĠĠĠĠĠĠ Ġval Ġdata 6 Ġ= Ġtest Report Account Balance Data ( date Ġ= Ġ" 2 0 1 8 - 0 2 ", Ġperiod Ġ= ĠReport Period . MONTH , ĠaccountId Ġ= Ġ 2 3 6 , Ġid Ġ= Ġ 1 0 5 ) ĊĠĠĠĠĠĠĠ Ġval Ġdata 7 Ġ= Ġtest Report Account Balance Data ( date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġperiod Ġ= ĠReport Period . MONTH , ĠaccountId Ġ= Ġ 2 3 7 , Ġid Ġ= Ġ 1 0 6 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġlist Ġ= Ġmutable ListOf ( data 1 , Ġdata 2 , Ġdata 3 , Ġdata 4 , Ġdata 5 , Ġdata 6 , Ġdata 7 ) ĊĊĠĠĠĠĠĠĠ Ġdb . reports Account Balance (). insert (* list . to Typed Array ()) ĊĊĠĠĠĠĠĠĠ Ġvar Ġsql Ġ= Ġsql For St ale Ids Account Balance Reports ( date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġperiod Ġ= ĠReport Period . MONTH , Ġreport Account Ids Ġ= Ġlong ArrayOf ( 2 3 4 , Ġ 2 3 5 )) ĊĠĠĠĠĠĠĠ Ġvar Ġmodels Ġ= Ġdb . reports Account Balance (). find ( sql ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 , Ġmodels . size ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 3 6 L , Ġmodels [ 0 ]. accountId ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 3 7 L , Ġmodels [ 1 ]. accountId ) ĊĊĠĠĠĠĠĠĠ Ġsql Ġ= Ġsql For St ale Ids Account Balance Reports ( date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġperiod Ġ= ĠReport Period . MONTH , Ġreport Account Ids Ġ= Ġlong ArrayOf ( 2 3 5 ), Ġaccount Type Ġ= ĠAccount Type . CRED IT _ CARD ) ĊĠĠĠĠĠĠĠ Ġmodels Ġ= Ġdb . reports Account Balance (). find ( sql ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġmodels . size ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 3 7 L , Ġmodels [ 0 ]. accountId ) ĊĊĠĠĠĠĠĠĠ Ġsql Ġ= Ġsql For St ale Ids Account Balance Reports ( date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġperiod Ġ= ĠReport Period . MONTH , Ġreport Account Ids Ġ= Ġlong ArrayOf ( 2 3 4 , Ġ 2 3 6 ), Ġaccount Type Ġ= ĠAccount Type . BANK ) ĊĠĠĠĠĠĠĠ Ġmodels Ġ= Ġdb . reports Account Balance (). find ( sql ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġmodels . size ) ĊĊĠĠĠĠĠĠĠ Ġsql Ġ= Ġsql For St ale Ids Account Balance Reports ( date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġperiod Ġ= ĠReport Period . MONTH , Ġreport Account Ids Ġ= Ġlong ArrayOf (), Ġaccount Type Ġ= ĠAccount Type . BANK ) ĊĠĠĠĠĠĠĠ Ġmodels Ġ= Ġdb . reports Account Balance (). find ( sql ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 , Ġmodels . size ) ĊĊĠĠĠĠĠĠĠ Ġsql Ġ= Ġsql For St ale Ids Account Balance Reports ( date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġperiod Ġ= ĠReport Period . MONTH , Ġreport Account Ids Ġ= Ġlong ArrayOf ( 2 3 4 ), ĠaccountId Ġ= Ġ 2 3 4 ) ĊĠĠĠĠĠĠĠ Ġmodels Ġ= Ġdb . reports Account Balance (). find ( sql ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġmodels . size ) ĊĊĠĠĠĠĠĠĠ Ġsql Ġ= Ġsql For St ale Ids Account Balance Reports ( date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġperiod Ġ= ĠReport Period . MONTH , Ġreport Account Ids Ġ= Ġlong ArrayOf (), ĠaccountId Ġ= Ġ 2 3 4 ) ĊĠĠĠĠĠĠĠ Ġmodels Ġ= Ġdb . reports Account Balance (). find ( sql ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġmodels . size ) ĊĊĠĠĠĠĠĠĠ Ġsql Ġ= Ġsql For St ale Ids Account Balance Reports ( date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġperiod Ġ= ĠReport Period . MONTH , Ġreport Account Ids Ġ= Ġlong ArrayOf (), ĠaccountId Ġ= Ġ 2 3 8 ) ĊĠĠĠĠĠĠĠ Ġmodels Ġ= Ġdb . reports Account Balance (). find ( sql ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġmodels . size ) ĊĊĠĠĠĠĠĠĠ Ġsql Ġ= Ġsql For St ale Ids Account Balance Reports ( date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġperiod Ġ= ĠReport Period . MONTH , Ġreport Account Ids Ġ= Ġlong ArrayOf ( 2 3 4 , Ġ 2 3 5 , Ġ 2 3 6 ), Ġaccount Type Ġ= ĠAccount Type . B ILL ) ĊĠĠĠĠĠĠĠ Ġmodels Ġ= Ġdb . reports Account Balance (). find ( sql ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġmodels . size ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Insert All () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdata 1 Ġ= Ġtest Report Account Balance Data ( date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġperiod Ġ= ĠReport Period . MONTH , ĠaccountId Ġ= Ġ 2 3 4 ) ĊĠĠĠĠĠĠĠ Ġval Ġdata 2 Ġ= Ġtest Report Account Balance Data ( date Ġ= Ġ" 2 0 1 8 - 0 2 ", Ġperiod Ġ= ĠReport Period . MONTH , ĠaccountId Ġ= Ġ 2 3 5 ) ĊĠĠĠĠĠĠĠ Ġval Ġdata 3 Ġ= Ġtest Report Account Balance Data ( date Ġ= Ġ" 2 0 1 8 - 0 3 ", Ġperiod Ġ= ĠReport Period . MONTH , ĠaccountId Ġ= Ġ 2 3 4 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġlist Ġ= Ġmutable ListOf ( data 1 , Ġdata 2 , Ġdata 3 ) ĊĊĠĠĠĠĠĠĠ Ġdb . reports Account Balance (). insert (* list . to Typed Array ()) ĊĊĠĠĠĠĠĠĠ Ġval Ġsql Ġ= Ġsql For Fetching Account Balance Reports ( from Date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġto Date Ġ= Ġ" 2 0 1 8 - 0 3 ", Ġperiod Ġ= ĠReport Period . MONTH ) ĊĠĠĠĠĠĠĠ Ġval Ġtest Observer Ġ= Ġdb . reports Account Balance (). load With Relation ( sql ). test () ĊĠĠĠĠĠĠĠ Ġtest Observer . await Value () ĊĠĠĠĠĠĠĠ ĠassertEquals ( 3 , Ġtest Observer . value (). size ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Update All () Ġ{ ĊĠĠĠĠĠĠĠ Ġvar Ġdata 1 Ġ= Ġtest Report Account Balance Data ( date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġperiod Ġ= ĠReport Period . MONTH , ĠaccountId Ġ= Ġ 2 3 4 , Ġid Ġ= Ġ 1 0 0 , Ġvalue Ġ= ĠBigDecimal ( 1 2 3 . 0 )) ĊĊĠĠĠĠĠĠĠ Ġdb . reports Account Balance (). insert ( data 1 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġsql Ġ= Ġsql For Fetching Account Balance Reports ( from Date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġto Date Ġ= Ġ" 2 0 1 8 - 0 3 ", Ġperiod Ġ= ĠReport Period . MONTH ) ĊĠĠĠĠĠĠĠ Ġvar Ġtest Observer Ġ= Ġdb . reports Account Balance (). load With Relation ( sql ). test () ĊĠĠĠĠĠĠĠ Ġtest Observer . await Value () ĊĠĠĠĠĠĠĠ ĠassertEquals ( BigDecimal ( 1 2 3 . 0 ), Ġtest Observer . value ()[ 0 ]. report ?. value ) ĊĊĠĠĠĠĠĠĠ Ġdata 1 Ġ= Ġtest Report Account Balance Data ( date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġperiod Ġ= ĠReport Period . MONTH , ĠaccountId Ġ= Ġ 2 3 4 , Ġid Ġ= Ġ 1 0 0 , Ġvalue Ġ= ĠBigDecimal ( 5 6 7 . 0 )) ĊĊĠĠĠĠĠĠĠ Ġdb . reports Account Balance (). update ( data 1 ) ĊĊĠĠĠĠĠĠĠ Ġtest Observer Ġ= Ġdb . reports Account Balance (). load With Relation ( sql ). test () ĊĠĠĠĠĠĠĠ Ġtest Observer . await Value () ĊĠĠĠĠĠĠĠ ĠassertEquals ( BigDecimal ( 5 6 7 . 0 ), Ġtest Observer . value ()[ 0 ]. report ?. value ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Delete Many () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdata 1 Ġ= Ġtest Report Account Balance Data ( date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġperiod Ġ= ĠReport Period . MONTH , ĠaccountId Ġ= Ġ 2 3 4 , Ġid Ġ= Ġ 1 0 0 ) ĊĠĠĠĠĠĠĠ Ġval Ġdata 2 Ġ= Ġtest Report Account Balance Data ( date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġperiod Ġ= ĠReport Period . MONTH , ĠaccountId Ġ= Ġ 2 3 5 , Ġid Ġ= Ġ 1 0 1 ) ĊĠĠĠĠĠĠĠ Ġval Ġdata 3 Ġ= Ġtest Report Account Balance Data ( date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġperiod Ġ= ĠReport Period . MONTH , ĠaccountId Ġ= Ġ 2 3 6 , Ġid Ġ= Ġ 1 0 2 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġlist Ġ= Ġmutable ListOf ( data 1 , Ġdata 2 , Ġdata 3 ) ĊĊĠĠĠĠĠĠĠ Ġdb . reports Account Balance (). insert (* list . to Typed Array ()) ĊĠĠĠĠĠĠĠ Ġval Ġsql Ġ= Ġsql For Fetching Account Balance Reports ( from Date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġto Date Ġ= Ġ" 2 0 1 8 - 0 3 ", Ġperiod Ġ= ĠReport Period . MONTH ) ĊĠĠĠĠĠĠĠ Ġvar Ġtest Observer Ġ= Ġdb . reports Account Balance (). load With Relation ( sql ). test () ĊĠĠĠĠĠĠĠ Ġtest Observer . await Value () ĊĠĠĠĠĠĠĠ ĠassertEquals ( 3 , Ġtest Observer . value (). size ) ĊĊĠĠĠĠĠĠĠ Ġdb . reports Account Balance (). delete Many ( long ArrayOf ( 1 0 0 , Ġ 1 0 1 )) ĊĊĠĠĠĠĠĠĠ Ġtest Observer Ġ= Ġdb . reports Account Balance (). load With Relation ( sql ). test () ĊĠĠĠĠĠĠĠ Ġtest Observer . await Value () ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġtest Observer . value (). size ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Clear () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdata 1 Ġ= Ġtest Report Account Balance Data ( date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġperiod Ġ= ĠReport Period . MONTH , ĠaccountId Ġ= Ġ 2 3 4 , Ġid Ġ= Ġ 1 0 0 ) ĊĠĠĠĠĠĠĠ Ġval Ġdata 2 Ġ= Ġtest Report Account Balance Data ( date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġperiod Ġ= ĠReport Period . MONTH , ĠaccountId Ġ= Ġ 2 3 5 , Ġid Ġ= Ġ 1 0 1 ) ĊĠĠĠĠĠĠĠ Ġval Ġdata 3 Ġ= Ġtest Report Account Balance Data ( date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġperiod Ġ= ĠReport Period . MONTH , ĠaccountId Ġ= Ġ 2 3 6 , Ġid Ġ= Ġ 1 0 2 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġlist Ġ= Ġmutable ListOf ( data 1 , Ġdata 2 , Ġdata 3 ) ĊĊĠĠĠĠĠĠĠ Ġdb . reports Account Balance (). insert (* list . to Typed Array ()) ĊĠĠĠĠĠĠĠ Ġval Ġsql Ġ= Ġsql For Fetching Account Balance Reports ( from Date Ġ= Ġ" 2 0 1 8 - 0 1 ", Ġto Date Ġ= Ġ" 2 0 1 8 - 0 3 ", Ġperiod Ġ= ĠReport Period . MONTH ) ĊĠĠĠĠĠĠĠ Ġvar Ġtest Observer Ġ= Ġdb . reports Account Balance (). load With Relation ( sql ). test () ĊĠĠĠĠĠĠĠ Ġtest Observer . await Value () ĊĠĠĠĠĠĠĠ ĠassertEquals ( 3 , Ġtest Observer . value (). size ) ĊĊĠĠĠĠĠĠĠ Ġdb . reports Account Balance (). clear () ĊĊĠĠĠĠĠĠĠ Ġtest Observer Ġ= Ġdb . reports Account Balance (). load With Relation ( sql ). test () ĊĠĠĠĠĠĠĠ Ġtest Observer . await Value () ĊĠĠĠĠĠĠĠ ĠassertTrue ( test Observer . value (). isEmpty ()) ĊĠĠĠ Ġ} Ċ } Ċ