package Ġcom . rar ible . core . reduce . service Ċ Ċ import Ġcom . rar ible . core . reduce . Abstract IntegrationTest Ċ import Ġcom . rar ible . core . reduce . blockchain . Blockchain Snapshot Strategy Ċ import Ġcom . rar ible . core . reduce . factory . create AccountId Ċ import Ġcom . rar ible . core . reduce . factory . create Account Income Transfer Ċ import Ġcom . rar ible . core . reduce . factory . create Account Outcome Transfer Ċ import Ġcom . rar ible . core . reduce . service . model . Account Balance Ċ import Ġcom . rar ible . core . reduce . service . model . AccountId Ċ import Ġcom . rar ible . core . reduce . service . model . Account Reduce Event Ċ import Ġcom . rar ible . core . reduce . service . model . Account Reduce Snapshot Ċ import Ġcom . rar ible . core . reduce . service . reducer . Account Balance Reducer Ċ import Ġcom . rar ible . core . reduce . service . repository . Account Balance Repository Ċ import Ġcom . rar ible . core . reduce . service . repository . Account Balance Snapshot Repository Ċ import Ġcom . rar ible . core . reduce . service . repository . Account Reduce Event Repository Ċ import Ġkotlinx . coroutines . reactive . await First Ċ import Ġkotlinx . coroutines . reactor . as Flux Ċ import Ġkotlinx . coroutines . run Blocking Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġjava . math . BigInteger Ċ Ċ internal Ġclass ĠReduce Service Test Ġ: ĠAbstract IntegrationTest () Ġ{ ĊĠĠĠ Ġprivate Ġval Ġbalance Repository Ġ= ĠAccount Balance Repository ( template ) ĊĠĠĠ Ġprivate Ġval Ġsnapshot Repository Ġ= ĠAccount Balance Snapshot Repository ( template ) ĊĠĠĠ Ġprivate Ġval Ġsnapshot Strategy Ġ= ĠBlock chain Snapshot Strategy < Account Reduce Snapshot , ĠAccount Balance , ĠAccount Id >( 4 ) ĊĠĠĠ Ġprivate Ġval Ġevent Repository Ġ= ĠAccount Reduce Event Repository ( template ) ĊĠĠĠ Ġprivate Ġval Ġupdate Service Ġ= ĠReduce Data Update Service ( balance Repository ) ĊĠĠĠ Ġprivate Ġval Ġreducer Ġ= ĠAccount Balance Reducer ( balance Repository ) ĊĊĠĠĠ Ġprivate Ġval Ġservice Ġ= ĠReduce Service ( ĊĠĠĠĠĠĠĠ Ġreducer Ġ= Ġreducer , ĊĠĠĠĠĠĠĠ Ġevent Repository Ġ= Ġevent Repository , ĊĠĠĠĠĠĠĠ Ġupdate Service Ġ= Ġupdate Service , ĊĠĠĠĠĠĠĠ Ġsnapshot Repository Ġ= Ġsnapshot Repository , ĊĠĠĠĠĠĠĠ Ġsnapshot Strategy Ġ= Ġsnapshot Strategy ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġget Ġall Ġevents Ġby Ġaccount Ġid `() Ġ= Ġrun Blocking < Unit > Ġ{ ĊĠĠĠĠĠĠĠ Ġval ĠaccountId Ġ= Ġcreate AccountId () ĊĊĠĠĠĠĠĠĠ Ġval Ġevent 1 Ġ= Ġcreate Account Income Transfer ( accountId ). copy ( value Ġ= ĠBigInteger . valueOf ( 1 0 ), Ġblock Number Ġ= Ġ 3 ) ĊĠĠĠĠĠĠĠ Ġval Ġevent 2 Ġ= Ġcreate Account Income Transfer ( accountId ). copy ( value Ġ= ĠBigInteger . valueOf ( 5 ), Ġblock Number Ġ= Ġ 1 ) ĊĠĠĠĠĠĠĠ Ġval Ġevent 3 Ġ= Ġcreate Account Outcome Transfer ( accountId ). copy ( value Ġ= ĠBigInteger . valueOf ( 7 ), Ġblock Number Ġ= Ġ 4 ) ĊĠĠĠĠĠĠĠ Ġval Ġevent 4 Ġ= Ġcreate Account Outcome Transfer ( accountId ). copy ( value Ġ= ĠBigInteger . valueOf ( 7 ), Ġblock Number Ġ= Ġ 2 ) ĊĊĠĠĠĠĠĠĠ ĠlistOf ( event 1 , Ġevent 2 , Ġevent 3 , Ġevent 4 , Ġcreate Account Outcome Transfer ()). forEach Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġevent Repository . save ( it ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġevent List Ġ= Ġevent Repository . get Events ( reducer . getData Key From Event ( Account Reduce Event ( event 1 )), Ġnull ). as Flux (). collect List (). await First () ĊĠĠĠĠĠĠĠ ĠassertThat ( event List ). has Size ( 4 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( event List [ 0 ]. event . block Number ). isEqualTo ( 1 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( event List [ 1 ]. event . block Number ). isEqualTo ( 2 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( event List [ 2 ]. event . block Number ). isEqualTo ( 3 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( event List [ 3 ]. event . block Number ). isEqualTo ( 4 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġreduce Ġevents Ġfor Ġall Ġaccounts `() Ġ= Ġrun Blocking < Unit > Ġ{ ĊĠĠĠĠĠĠĠ Ġval ĠaccountId 1 Ġ= Ġcreate AccountId () ĊĠĠĠĠĠĠĠ Ġval ĠaccountId 2 Ġ= Ġcreate AccountId () ĊĊĠĠĠĠĠĠĠ Ġval Ġevent 1 Ġ= Ġcreate Account Income Transfer ( accountId 1 ). copy ( value Ġ= ĠBigInteger . valueOf ( 1 0 ), Ġblock Number Ġ= Ġ 3 ) ĊĠĠĠĠĠĠĠ Ġval Ġevent 2 Ġ= Ġcreate Account Outcome Transfer ( accountId 1 ). copy ( value Ġ= ĠBigInteger . valueOf ( 9 ), Ġblock Number Ġ= Ġ 4 ) ĊĠĠĠĠĠĠĠ Ġval Ġevent 3 Ġ= Ġcreate Account Income Transfer ( accountId 2 ). copy ( value Ġ= ĠBigInteger . valueOf ( 1 0 ), Ġblock Number Ġ= Ġ 3 ) ĊĠĠĠĠĠĠĠ Ġval Ġevent 4 Ġ= Ġcreate Account Outcome Transfer ( accountId 2 ). copy ( value Ġ= ĠBigInteger . valueOf ( 9 ), Ġblock Number Ġ= Ġ 4 ) ĊĊĠĠĠĠĠĠĠ ĠlistOf ( event 1 , Ġevent 2 , Ġevent 3 , Ġevent 4 , Ġcreate Account Outcome Transfer ()). forEach Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġevent Repository . save ( it ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġservice . on Events ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠAccount Reduce Event ( event 1 ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠAccount Reduce Event ( event 2 ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠAccount Reduce Event ( event 3 ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠAccount Reduce Event ( event 4 ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġbalance 1 Ġ= Ġbalance Repository . get ( accountId 1 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( balance 1 ?. balance ). isEqualTo ( BigInteger . ONE ) ĊĊĠĠĠĠĠĠĠ Ġval Ġbalance 2 Ġ= Ġbalance Repository . get ( accountId 2 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( balance 2 ?. balance ). isEqualTo ( BigInteger . ONE ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġreduce Ġsimple Ġevents `() Ġ= Ġrun Blocking < Unit > Ġ{ ĊĠĠĠĠĠĠĠ Ġval ĠaccountId 1 Ġ= Ġcreate AccountId () ĊĠĠĠĠĠĠĠ Ġval ĠaccountId 2 Ġ= Ġcreate AccountId () ĊĊĠĠĠĠĠĠĠ Ġval Ġevent 1 1 Ġ= Ġcreate Account Income Transfer ( accountId 1 ). copy ( value Ġ= ĠBigInteger . valueOf ( 1 0 ), Ġblock Number Ġ= Ġ 1 ) ĊĠĠĠĠĠĠĠ Ġval Ġevent 2 1 Ġ= Ġcreate Account Income Transfer ( accountId 1 ). copy ( value Ġ= ĠBigInteger . valueOf ( 5 ), Ġblock Number Ġ= Ġ 2 ) ĊĠĠĠĠĠĠĠ Ġval Ġevent 3 1 Ġ= Ġcreate Account Outcome Transfer ( accountId 1 ). copy ( value Ġ= ĠBigInteger . valueOf ( 7 ), Ġblock Number Ġ= Ġ 3 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġevent 1 2 Ġ= Ġcreate Account Income Transfer ( accountId 2 ). copy ( value Ġ= ĠBigInteger . valueOf ( 2 0 ), Ġblock Number Ġ= Ġ 2 ) ĊĠĠĠĠĠĠĠ Ġval Ġevent 2 2 Ġ= Ġcreate Account Outcome Transfer ( accountId 2 ). copy ( value Ġ= ĠBigInteger . valueOf ( 5 ), Ġblock Number Ġ= Ġ 3 ) ĊĠĠĠĠĠĠĠ Ġval Ġevent 3 2 Ġ= Ġcreate Account Outcome Transfer ( accountId 2 ). copy ( value Ġ= ĠBigInteger . valueOf ( 1 0 ), Ġblock Number Ġ= Ġ 4 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġnew Events Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠAccount Reduce Event ( event 1 1 ), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠAccount Reduce Event ( event 2 1 ), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠAccount Reduce Event ( event 3 1 ), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠAccount Reduce Event ( event 1 2 ), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠAccount Reduce Event ( event 2 2 ), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠAccount Reduce Event ( event 3 2 ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġnew Events . forEach Ġ{ Ġevent Repository . save ( it . event ) Ġ} ĊĊĠĠĠĠĠĠĠ Ġservice . on Events ( new Events ) ĊĊĠĠĠĠĠĠĠ Ġval Ġaccount Balance 1 Ġ= Ġbalance Repository . get ( accountId 1 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( account Balance 1 ). isNotNull ĊĠĠĠĠĠĠĠ ĠassertThat ( account Balance 1 ?. balance ). isEqualTo ( BigInteger . valueOf ( 8 )) ĊĊĠĠĠĠĠĠĠ Ġval Ġaccount Balance 2 Ġ= Ġbalance Repository . get ( accountId 2 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( account Balance 2 ). isNotNull ĊĠĠĠĠĠĠĠ ĠassertThat ( account Balance 2 ?. balance ). isEqualTo ( BigInteger . valueOf ( 5 )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġmake Ġlatest Ġsnapshot Ġafter Ġfull Ġreduce `() Ġ= Ġrun Blocking < Unit > Ġ{ ĊĠĠĠĠĠĠĠ Ġval ĠaccountId Ġ= Ġcreate AccountId () ĊĠĠĠĠĠĠĠ Ġval Ġincome s Ġ= Ġcreate Seq Account Income Reduce Event ( accountId , Ġincome Ġ= Ġ 1 , Ġamount Ġ= Ġ 1 0 , Ġstart Block Number Ġ= Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġval Ġoutcomes Ġ= Ġcreate Seq Account Outcome Reduce Event ( accountId , Ġoutcome Ġ= Ġ 1 , Ġamount Ġ= Ġ 1 0 , Ġstart Block Number Ġ= Ġ 1 0 ) ĊĊĠĠĠĠĠĠĠ Ġ( income s Ġ+ Ġoutcomes ). forEach Ġ{ Ġevent Repository . save ( it . event ) Ġ} ĊĊĠĠĠĠĠĠĠ Ġservice . on Events ( income s ) ĊĊĠĠĠĠĠĠĠ Ġval Ġaccount Balance 1 Ġ= Ġbalance Repository . get ( accountId ) ĊĠĠĠĠĠĠĠ ĠassertThat ( account Balance 1 ?. balance ). isEqualTo ( BigInteger . valueOf ( 0 )) ĊĊĠĠĠĠĠĠĠ Ġval Ġsnapshot Ġ= Ġsnapshot Repository . get ( accountId ) ĊĠĠĠĠĠĠĠ ĠassertThat ( snapshot ?. mark ). isEqualTo ( 1 7 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( snapshot ?. data ?. balance ). isEqualTo ( 3 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġmake Ġlatest Ġsnapshot Ġif Ġenough Ġblock Ġconform ations `() Ġ= Ġrun Blocking < Unit > Ġ{ ĊĠĠĠĠĠĠĠ Ġval ĠaccountId Ġ= Ġcreate AccountId () ĊĠĠĠĠĠĠĠ Ġval Ġincome s Ġ= Ġcreate Seq Account Income Reduce Event ( accountId , Ġincome Ġ= Ġ 1 , Ġamount Ġ= Ġ 1 , Ġstart Block Number Ġ= Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġval Ġoutcomes Ġ= Ġcreate Seq Account Outcome Reduce Event ( accountId , Ġoutcome Ġ= Ġ 1 , Ġamount Ġ= Ġ 1 , Ġstart Block Number Ġ= Ġ 2 0 ) ĊĊĠĠĠĠĠĠĠ Ġ( income s Ġ+ Ġoutcomes ). forEach Ġ{ Ġevent Repository . save ( it . event ) Ġ} ĊĊĠĠĠĠĠĠĠ Ġservice . on Events ( income s ) ĊĊĠĠĠĠĠĠĠ Ġval Ġaccount Balance 1 Ġ= Ġbalance Repository . get ( accountId ) ĊĠĠĠĠĠĠĠ ĠassertThat ( account Balance 1 ?. balance ). isEqualTo ( BigInteger . valueOf ( 0 )) ĊĊĠĠĠĠĠĠĠ Ġval Ġsnapshot Ġ= Ġsnapshot Repository . get ( accountId ) ĊĠĠĠĠĠĠĠ ĠassertThat ( snapshot ?. mark ). isEqualTo ( 1 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( snapshot ?. data ?. balance ). isEqualTo ( 1 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġmake Ġlatest Ġsnapshot Ġif Ġenough Ġblock Ġconform ations , Ġcomplex Ġtest `() Ġ= Ġrun Blocking < Unit > Ġ{ ĊĠĠĠĠĠĠĠ Ġval ĠaccountId Ġ= Ġcreate AccountId () ĊĠĠĠĠĠĠĠ Ġval Ġincome s Ġ= Ġcreate Seq Account Income Reduce Event ( accountId , Ġincome Ġ= Ġ 1 , Ġamount Ġ= Ġ 2 , Ġstart Block Number Ġ= Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġval Ġoutcomes Ġ= Ġcreate Seq Account Outcome Reduce Event ( accountId , Ġoutcome Ġ= Ġ 1 , Ġamount Ġ= Ġ 1 , Ġstart Block Number Ġ= Ġ 3 0 ) ĊĊĠĠĠĠĠĠĠ Ġ( income s Ġ+ Ġoutcomes ). forEach Ġ{ Ġevent Repository . save ( it . event ) Ġ} ĊĊĠĠĠĠĠĠĠ Ġservice . on Events ( income s ) ĊĊĠĠĠĠĠĠĠ Ġval Ġaccount Balance 1 Ġ= Ġbalance Repository . get ( accountId ) ĊĠĠĠĠĠĠĠ ĠassertThat ( account Balance 1 ?. balance ). isEqualTo ( BigInteger . valueOf ( 1 )) ĊĊĠĠĠĠĠĠĠ Ġval Ġsnapshot Ġ= Ġsnapshot Repository . get ( accountId ) ĊĠĠĠĠĠĠĠ ĠassertThat ( snapshot ?. mark ). isEqualTo ( 2 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( snapshot ?. data ?. balance ). isEqualTo ( 2 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġuse Ġlatest Ġsnapshot Ġfor Ġnext Ġreduce `() Ġ= Ġrun Blocking < Unit > Ġ{ ĊĠĠĠĠĠĠĠ Ġval ĠaccountId Ġ= Ġcreate AccountId () ĊĠĠĠĠĠĠĠ Ġval Ġincome s Ġ= Ġcreate Seq Account Income Reduce Event ( accountId , Ġincome Ġ= Ġ 1 , Ġamount Ġ= Ġ 1 0 , Ġstart Block Number Ġ= Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġval Ġoutcomes Ġ= Ġcreate Seq Account Outcome Reduce Event ( accountId , Ġoutcome Ġ= Ġ 1 , Ġamount Ġ= Ġ 1 0 , Ġstart Block Number Ġ= Ġ 1 0 ) ĊĊĠĠĠĠĠĠĠ Ġ( income s Ġ+ Ġoutcomes ). forEach Ġ{ Ġevent Repository . save ( it . event ) Ġ} ĊĊĠĠĠĠĠĠĠ Ġservice . on Events ( income s ) ĊĊĠĠĠĠĠĠĠ Ġevent Repository . drop Collection () ĊĊĠĠĠĠĠĠĠ Ġval Ġold Other Income s Ġ= Ġcreate Seq Account Income Reduce Event ( accountId , Ġincome Ġ= Ġ 1 0 0 0 , Ġamount Ġ= Ġ 1 0 , Ġstart Block Number Ġ= Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġval Ġnew Income s Ġ= Ġcreate Seq Account Income Reduce Event ( accountId , Ġincome Ġ= Ġ 1 , Ġamount Ġ= Ġ 2 , Ġstart Block Number Ġ= Ġ 1 8 ) ĊĊĠĠĠĠĠĠĠ Ġ( old Other Income s Ġ+ Ġnew Income s ). forEach Ġ{ Ġevent Repository . save ( it . event ) Ġ} ĊĊĠĠĠĠĠĠĠ Ġservice . on Events ( new Income s ) ĊĊĠĠĠĠĠĠĠ Ġval Ġaccount Balance 1 Ġ= Ġbalance Repository . get ( accountId ) ĊĠĠĠĠĠĠĠ ĠassertThat ( account Balance 1 ?. balance ). isEqualTo ( BigInteger . valueOf ( 5 )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġdrop Ġsnapshot Ġif Ġcome Ġold Ġmark `() Ġ= Ġrun Blocking < Unit > Ġ{ ĊĠĠĠĠĠĠĠ Ġval ĠaccountId Ġ= Ġcreate AccountId () ĊĠĠĠĠĠĠĠ Ġval Ġincome s Ġ= Ġcreate Seq Account Income Reduce Event ( accountId , Ġincome Ġ= Ġ 1 , Ġamount Ġ= Ġ 1 0 , Ġstart Block Number Ġ= Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġval Ġoutcomes Ġ= Ġcreate Seq Account Outcome Reduce Event ( accountId , Ġoutcome Ġ= Ġ 1 , Ġamount Ġ= Ġ 1 0 , Ġstart Block Number Ġ= Ġ 1 0 ) ĊĊĠĠĠĠĠĠĠ Ġ( income s Ġ+ Ġoutcomes ). forEach Ġ{ Ġevent Repository . save ( it . event ) Ġ} ĊĊĠĠĠĠĠĠĠ Ġservice . on Events ( income s ) ĊĊĠĠĠĠĠĠĠ Ġevent Repository . drop Collection () ĊĊĠĠĠĠĠĠĠ Ġval Ġnew Income s Ġ= Ġcreate Seq Account Income Reduce Event ( accountId , Ġincome Ġ= Ġ 1 , Ġamount Ġ= Ġ 3 , Ġstart Block Number Ġ= Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġval Ġnew Outcome s Ġ= Ġcreate Seq Account Outcome Reduce Event ( accountId , Ġoutcome Ġ= Ġ 1 , Ġamount Ġ= Ġ 2 , Ġstart Block Number Ġ= Ġ 9 ) ĊĊĠĠĠĠĠĠĠ Ġ( new Income s Ġ+ Ġnew Outcome s ). forEach Ġ{ Ġevent Repository . save ( it . event ) Ġ} ĊĊĠĠĠĠĠĠĠ Ġservice . on Events ( new Outcome s ) ĊĊĠĠĠĠĠĠĠ Ġval Ġaccount Balance 1 Ġ= Ġbalance Repository . get ( accountId ) ĊĠĠĠĠĠĠĠ ĠassertThat ( account Balance 1 ?. balance ). isEqualTo ( BigInteger . valueOf ( 1 )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġcreate Seq Account Income Reduce Event ( ĊĠĠĠĠĠĠĠ ĠaccountId : ĠAccount Id , ĊĠĠĠĠĠĠĠ Ġincome : ĠLong , ĊĠĠĠĠĠĠĠ Ġamount : ĠLong , ĊĠĠĠĠĠĠĠ Ġstart Block Number : ĠLong ĊĠĠĠ Ġ): ĠList < Account Reduce Event > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġ( 1 .. amount ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. map Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcreate Account Income Transfer ( accountId ). copy ( value Ġ= ĠBigInteger . valueOf ( income ), Ġblock Number Ġ= Ġstart Block Number Ġ+ Ġit ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. map Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠAccount Reduce Event ( it ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġcreate Seq Account Outcome Reduce Event ( ĊĠĠĠĠĠĠĠ ĠaccountId : ĠAccount Id , ĊĠĠĠĠĠĠĠ Ġoutcome : ĠLong , ĊĠĠĠĠĠĠĠ Ġamount : ĠLong , ĊĠĠĠĠĠĠĠ Ġstart Block Number : ĠLong ĊĠĠĠ Ġ): ĠList < Account Reduce Event > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġ( 1 .. amount ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. map Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcreate Account Outcome Transfer ( accountId ). copy ( value Ġ= ĠBigInteger . valueOf ( outcome ), Ġblock Number Ġ= Ġstart Block Number Ġ+ Ġit ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. map Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠAccount Reduce Event ( it ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ