package Ġcom . cd lex ample Ċ Ċ import Ġcom . cd lex ample . flows . Issue Rate Card Ċ import Ġcom . cd lex ample . flows . Pro pose Flow Ċ import Ġcom . cd lex ample . flows . Pro pose Responder Flow Ċ import Ġcom . cd lex ample . flows . Responder Ċ import Ġcom . cd lex ample . states . Agreement State Ċ import Ġcom . cd lex ample . states . Rate Card State Ċ import Ġnet . cord a . core . contracts . Amount Ċ import Ġnet . cord a . core . flows . Flow Exception Ċ import Ġnet . cord a . core . node . services . query By Ċ import Ġnet . cord a . core . transactions . Signed Transaction Ċ import Ġnet . cord a . core . utilities . context Logger Ċ import Ġnet . cord a . core . utilities . get OrThrow Ċ import Ġnet . cord a . testing . common . internal . log Ċ import Ġnet . cord a . testing . node . Mock Network Ċ import Ġnet . cord a . testing . node . Mock Network Parameters Ċ import Ġnet . cord a . testing . node . Test C ord app Ċ import Ġorg . hamcrest . Matchers Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . rules . Expected Exception Ċ import Ġorg . slf 4 j . Logger Ċ import Ġorg . slf 4 j . LoggerFactory Ċ import Ġjava . lang . IllegalArgumentException Ċ import Ġjava . util .* Ċ import Ġkotlin . test . assertEquals Ċ Ċ class ĠRate Card Flow Tests Ġ{ ĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġlogger : ĠLogger Ġ= ĠLoggerFactory . getLogger ( this :: class . java . enc lo sing Class ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Rule ĊĠĠĠ Ġ@ Jvm Field ĊĠĠĠ Ġvar Ġexpected Exception Ġ= ĠExpected Exception . none () ĊĊĠĠĠ Ġprivate Ġval Ġnetwork Ġ= ĠMock Network ( Mock Network Parameters ( cord apps ForAll Nodes Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠ ĠTest C ord app . find C ord app (" com . cd lex ample . contracts "), ĊĠĠĠĠĠĠĠ ĠTest C ord app . find C ord app (" com . cd lex ample . flows ") ĊĠĠĠ Ġ))) ĊĠĠĠ Ġprivate Ġval Ġa Ġ= Ġnetwork . createNode () ĊĠĠĠ Ġprivate Ġval Ġb Ġ= Ġnetwork . createNode () ĊĠĠĠ Ġprivate Ġval Ġoperator Ġ= Ġnetwork . createNode () ĊĊĠĠĠ Ġinit Ġ{ ĊĠĠĠĠĠĠĠ ĠlistOf ( a , Ġb ). forEach Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġit . register Initi ated Flow ( Pro pose Responder Flow :: class . java ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġval Ġparty A Ġ= Ġa . info . legal Id entities . first () ĊĠĠĠ Ġval Ġparty B Ġ= Ġb . info . legal Id entities . first () ĊĠĠĠ Ġval Ġparty Operator Ġ= Ġoperator . info . legal Id entities . first () ĊĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun Ġsetup () Ġ= Ġnetwork . run Network () ĊĊĠĠĠ Ġ@ After ĊĠĠĠ Ġfun ĠtearDown () Ġ= Ġnetwork . stop Nodes () ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Issue Ġa Ġrate Ġcard `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġflow Ġ= ĠIssue Rate Card ( rate Ġ= Ġ 1 0 0 ) ĊĠĠĠĠĠĠĠ Ġval Ġresult : ĠSigned Transaction Ġ= Ġoperator . start Flow ( flow ). run AndGet ( network ) ĊĊĠĠĠĠĠĠĠ Ġ// ĠCheck Ġoutput Ġstate Ġis Ġreturned ĊĠĠĠĠĠĠĠ Ġval Ġoutput State Ġ= Ġresult . core Transaction . output States . single () Ġas ĠRate Card State ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 0 , Ġoutput State . rate , Ġ" Rate Ġshould Ġbe Ġcorrect ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Only Ġone Ġrate Ġcard Ġcan Ġbe Ġissued `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġflow 1 Ġ= ĠIssue Rate Card ( rate Ġ= Ġ 1 0 0 ) ĊĠĠĠĠĠĠĠ Ġoperator . start Flow ( flow 1 ) ĊĠĠĠĠĠĠĠ Ġnetwork . run Network () ĊĊĠĠĠĠĠĠĠ Ġexpected Exception . expect Cause ( Matchers . any ( IllegalArgumentException :: class . java )) ĊĠĠĠĠĠĠĠ Ġval Ġflow 2 Ġ= ĠIssue Rate Card ( rate Ġ= Ġ 2 0 0 ) ĊĠĠĠĠĠĠĠ Ġval Ġfuture Ġ= Ġoperator . start Flow ( flow 2 ) ĊĊĠĠĠĠĠĠĠ Ġnetwork . run Network () ĊĠĠĠĠĠĠĠ Ġexpected Exception . expect Cause ( Matchers . any ( IllegalArgumentException :: class . java )) ĊĠĠĠĠĠĠĠ Ġfuture . get () ĊĠĠĠ Ġ} Ċ }