package Ġcom . ve ge soft . money tracker . statistics . handler Ċ Ċ import Ġcom . ve ge soft . money tracker . statistics . client . Account History Client Ċ import Ġcom . ve ge soft . money tracker . statistics . client . request . Transaction Request Ċ import Ġcom . ve ge soft . money tracker . statistics . client . response . Transaction Response Ċ import Ġcom . ve ge soft . money tracker . statistics . command . Load Transactions Command Ċ import Ġcom . ve ge soft . money tracker . statistics . domain . Account Statistic Ċ import Ġcom . ve ge soft . money tracker . statistics . domain . Account Statistic Range Ċ import Ġcom . ve ge soft . money tracker . statistics . domain . Transaction Ċ import Ġcom . ve ge soft . money tracker . statistics . domain . repository . Account Statistic Repository Ċ import Ġcom . ve ge soft . money tracker . statistics . handler . mapper . Load Transaction Command Mapper Ċ import Ġio . mock k . every Ċ import Ġio . mock k . impl . annotations . Inject Mock Ks Ċ import Ġio . mock k . impl . annotations . Mock K Ċ import Ġio . mock k . junit 5 . Mock K Extension Ċ import Ġio . mock k . verify Ċ import Ġorg . junit . jupiter . api . DisplayName Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . junit . jupiter . api . extension . Extend With Ċ import Ġreactor . core . publisher . Flux Ċ import Ġreactor . core . publisher . Mono Ċ import Ġreactor . test . Step Verifier Ċ import Ġjava . math . BigDecimal Ċ import Ġjava . time . LocalDateTime Ċ import Ġjava . util .* Ċ Ċ @ Extend With ( Mock K Extension :: class ) Ċ internal Ġclass ĠReactive Load Transactions Handler Test Ġ{ ĊĊĠĠĠ Ġ@ Mock K ĊĠĠĠ Ġlateinit Ġvar Ġaccount History Client : ĠAccount History Client ĊĠĠĠ Ġ@ Mock K ĊĠĠĠ Ġlateinit Ġvar Ġaccount Statistics Repository : ĠAccount Statistic Repository ĊĠĠĠ Ġ@ Mock K ĊĠĠĠ Ġlateinit Ġvar Ġload Transaction Command Mapper : ĠLoad Transaction Command Mapper ĊĠĠĠ Ġ@ Inject Mock Ks ĊĠĠĠ Ġlateinit Ġvar Ġreactive Load Transactions Handler : ĠReactive Load Transactions Handler ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ DisplayName (" Should Ġhandle Ġcommand ") ĊĠĠĠ Ġfun Ġhandle () Ġ{ ĊĠĠĠĠĠĠĠ Ġ// Given ĊĠĠĠĠĠĠĠ Ġval ĠaccountId Ġ= ĠUUID . randomUUID () ĊĠĠĠĠĠĠĠ Ġval Ġfrom Ġ= ĠLocalDateTime . now () ĊĠĠĠĠĠĠĠ Ġval Ġto Ġ= ĠLocalDateTime . now () ĊĠĠĠĠĠĠĠ Ġval Ġamount Ġ= ĠBigDecimal . TEN ĊĠĠĠĠĠĠĠ Ġval Ġtype Ġ= Ġ" food " ĊĠĠĠĠĠĠĠ Ġval Ġtransaction Request Ġ= ĠTransaction Request ( accountId , Ġfrom , Ġto ) ĊĠĠĠĠĠĠĠ Ġval Ġtransaction Response Ġ= ĠTransaction Response ( amount , Ġtype ) ĊĠĠĠĠĠĠĠ Ġval Ġtransaction Ġ= ĠTransaction ( amount , Ġtype ) ĊĠĠĠĠĠĠĠ Ġval Ġload Transactions Command Ġ= ĠLoad Transactions Command ( LocalDateTime . now (), ĠLocalDateTime . now (), ĠaccountId ) ĊĠĠĠĠĠĠĠ Ġval Ġaccount Statistic Ġ= ĠAccount Statistic ( UUID . randomUUID (), ĠAccount Statistic Range ( from , Ġto ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠaccountId , ĠBigDecimal . TEN , Ġmutable ListOf (), Ġmutable ListOf ()) ĊĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġload Transaction Command Mapper . map To Transaction Request ( load Transactions Command ) Ġ} Ġreturns Ġtransaction Request ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġload Transaction Command Mapper . map To Transaction ( transaction Response ) Ġ} Ġreturns Ġtransaction ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġaccount History Client . find Transaction Views ( transaction Request ) Ġ} Ġreturns ĠFlux . just ( transaction Response ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġaccount Statistics Repository . save ( any < Account Statistic >()) Ġ} Ġreturns ĠMono . just ( account Statistic ) ĊĠĠĠĠĠĠĠ Ġ// When ĊĠĠĠĠĠĠĠ Ġval Ġhandle Ġ= Ġreactive Load Transactions Handler . handle ( load Transactions Command ) ĊĠĠĠĠĠĠĠ Ġ// Then ĊĠĠĠĠĠĠĠ ĠStep Verifier . create ( handle ). expect Complete (). verify () ĊĠĠĠĠĠĠĠ Ġverify Ġ{ Ġaccount History Client . find Transaction Views ( transaction Request ) Ġ} ĊĠĠĠĠĠĠĠ Ġverify Ġ{ Ġload Transaction Command Mapper . map To Transaction Request ( load Transactions Command ) Ġ} ĊĠĠĠĠĠĠĠ Ġverify Ġ{ Ġaccount Statistics Repository . save ( any < Account Statistic >()) Ġ} ĊĠĠĠ Ġ} Ċ }