package Ġcom . template . flows Ċ Ċ import Ġcom . google . common . collect . ImmutableList Ċ import Ġcom . template . Contract . El ig ibility Contract Ċ import Ġcom . template . Loan Request Flow Ċ import Ġcom . template . State . El ig ibility State Ċ import Ġcom . template . State . Loan State Ċ import Ġcom . template . verify Check El ig ibility Flow Ċ import Ġnet . cord a . core . contracts . Unique Identifier Ċ import Ġnet . cord a . core . utilities . get OrThrow Ċ import Ġnet . cord a . testing . node . Mock Network Ċ import Ġnet . cord a . testing . node . Started Mock Node Ċ import Ġorg . junit .* Ċ import Ġkotlin . test . assertEquals Ċ Ċ class ĠVerify Check El ig ibility Flow Tests Ġ{ ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġnetwork : ĠMock Network ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġnode A : ĠStarted Mock Node ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġnode B : ĠStarted Mock Node ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġnode C : ĠStarted Mock Node ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġloan Id : ĠUnique Identifier ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun Ġsetup () Ġ{ ĊĠĠĠĠĠĠĠ Ġnetwork Ġ= ĠMock Network ( ImmutableList . of (" com . template ")) ĊĠĠĠĠĠĠĠ Ġnode A Ġ= Ġnetwork . create Party Node ( null ) ĊĠĠĠĠĠĠĠ Ġnode B Ġ= Ġnetwork . create Party Node ( null ) ĊĠĠĠĠĠĠĠ Ġnode C Ġ= Ġnetwork . create Party Node ( null ) ĊĠĠĠĠĠĠĠ Ġnetwork . run Network () ĊĊĠĠĠĠĠĠĠ Ġ// ĠRun Ġthe ĠLo an ĠRequest ĠFlow Ġfirst ĊĠĠĠĠĠĠĠ Ġval Ġflow Ġ= ĠLo an Request Flow (" J hon ", Ġ 9 9 , Ġ" FL F PK 1 6 7 2 D ", Ġnode B . info . legal Id entities [ 0 ]) ĊĠĠĠĠĠĠĠ Ġval Ġloan Request Flow Future Ġ= Ġnode A . start Flow ( flow ) ĊĠĠĠĠĠĠĠ Ġnetwork . run Network () ĊĠĠĠĠĠĠĠ Ġval Ġresults Ġ= Ġloan Request Flow Future . get OrThrow () ĊĠĠĠĠĠĠĠ Ġval Ġnew Loan State Ġ= Ġresults . tx . outputs . single (). data Ġas ĠLo an State ĊĠĠĠĠĠĠĠ Ġloan Id Ġ= Ġnew Loan State . linear Id ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ After ĊĠĠĠ Ġfun ĠtearDown () Ġ{ ĊĠĠĠĠĠĠĠ Ġnetwork . stop Nodes () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġfun Ġtransaction Construct edBy Flow Uses The Correct Not ary () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġverify Check El ig ibility Flow Ġ= Ġverify Check El ig ibility Flow ( loan Id , Ġnode C . info . legal Id entities [ 0 ]) ĊĠĠĠĠĠĠĠ Ġval Ġverify Check El ig ibility Flow Future Ġ= Ġnode B . start Flow ( verify Check El ig ibility Flow ) ĊĠĠĠĠĠĠĠ Ġnetwork . run Network () ĊĠĠĠĠĠĠĠ Ġval Ġsigned Transaction Ġ= Ġverify Check El ig ibility Flow Future . get () ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġsigned Transaction . tx . output States . size . to Long ()) ĊĠĠĠĠĠĠĠ Ġval Ġoutput Ġ= Ġsigned Transaction . tx . outputs [ 0 ] ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( network . not ary Nodes [ 0 ]. info . legal Id entities [ 0 ], Ġoutput . not ary ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġfun Ġtransaction Construct edBy Flow Has Correct Parameters () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġverify Check El ig ibility Flow Ġ= Ġverify Check El ig ibility Flow ( loan Id , Ġnode C . info . legal Id entities [ 0 ]) ĊĠĠĠĠĠĠĠ Ġval Ġverify Check El ig ibility Flow Future Ġ= Ġnode B . start Flow ( verify Check El ig ibility Flow ) ĊĠĠĠĠĠĠĠ Ġnetwork . run Network () ĊĠĠĠĠĠĠĠ Ġval Ġsigned Transaction Ġ= Ġverify Check El ig ibility Flow Future . get () ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġsigned Transaction . tx . output States . size . to Long ()) ĊĠĠĠĠĠĠĠ Ġval Ġoutput Ġ= Ġsigned Transaction . tx . outputs OfType ( El ig ibility State :: class . java )[ 0 ] ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( node B . info . legal Id entities [ 0 ], Ġoutput . bank ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( node C . info . legal Id entities [ 0 ], Ġoutput . credit Rating Ag ency ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" J hon ", Ġoutput . name ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( null , Ġoutput . c ibil Rating ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( loan Id , output . loan Id ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġfun Ġtransaction Construct edBy Flow Has One Output Using The Correct Contract () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġverify Check El ig ibility Flow Ġ= Ġverify Check El ig ibility Flow ( loan Id , Ġnode C . info . legal Id entities [ 0 ]) ĊĠĠĠĠĠĠĠ Ġval Ġverify Check El ig ibility Flow Future Ġ= Ġnode B . start Flow ( verify Check El ig ibility Flow ) ĊĠĠĠĠĠĠĠ Ġnetwork . run Network () ĊĠĠĠĠĠĠĠ Ġval Ġsigned Transaction Ġ= Ġverify Check El ig ibility Flow Future . get () ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġsigned Transaction . tx . output States . size . to Long ()) ĊĠĠĠĠĠĠĠ Ġval Ġ(_, Ġcontract ) Ġ= Ġsigned Transaction . tx . outputs [ 0 ] ĊĊĠĠĠĠĠĠĠ ĠassertEquals (" com . template . Contract . El ig ibility Contract ", Ġcontract ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġfun Ġtransaction Construct edBy Flow Has One Check El ig ibility Command () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġverify Check El ig ibility Flow Ġ= Ġverify Check El ig ibility Flow ( loan Id , Ġnode C . info . legal Id entities [ 0 ]) ĊĠĠĠĠĠĠĠ Ġval Ġverify Check El ig ibility Flow Future Ġ= Ġnode B . start Flow ( verify Check El ig ibility Flow ) ĊĠĠĠĠĠĠĠ Ġnetwork . run Network () ĊĠĠĠĠĠĠĠ Ġval Ġsigned Transaction Ġ= Ġverify Check El ig ibility Flow Future . get () ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġsigned Transaction . tx . commands . size . to Long ()) ĊĠĠĠĠĠĠĠ Ġval Ġ( value ) Ġ= Ġsigned Transaction . tx . commands [ 0 ] ĊĊĠĠĠĠĠĠĠ Ġassert ( value Ġis ĠEl ig ibility Contract . Commands . Check El ig ibility ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġfun Ġtransaction Construct edBy Flow Has One Command With The Bank As AS ign er () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġverify Check El ig ibility Flow Ġ= Ġverify Check El ig ibility Flow ( loan Id , Ġnode C . info . legal Id entities [ 0 ]) ĊĠĠĠĠĠĠĠ Ġval Ġverify Check El ig ibility Flow Future Ġ= Ġnode B . start Flow ( verify Check El ig ibility Flow ) ĊĠĠĠĠĠĠĠ Ġnetwork . run Network () ĊĠĠĠĠĠĠĠ Ġval Ġsigned Transaction Ġ= Ġverify Check El ig ibility Flow Future . get () ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġsigned Transaction . tx . commands . size . to Long ()) ĊĠĠĠĠĠĠĠ Ġval Ġ(_, Ġsign ers ) Ġ= Ġsigned Transaction . tx . commands [ 0 ] ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 , Ġsign ers . size . to Long ()) ĊĠĠĠĠĠĠĠ Ġassert ( sign ers . contains All ( listOf ( node B . info . legal Id entities [ 0 ]. own ing Key , Ġnode C . info . legal Id entities [ 0 ]. own ing Key ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġfun Ġtransaction Construct edBy Flow Has No One Input Attachments Or Time Windows () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġverify Check El ig ibility Flow Ġ= Ġverify Check El ig ibility Flow ( loan Id , Ġnode C . info . legal Id entities [ 0 ]) ĊĠĠĠĠĠĠĠ Ġval Ġverify Check El ig ibility Flow Future Ġ= Ġnode B . start Flow ( verify Check El ig ibility Flow ) ĊĠĠĠĠĠĠĠ Ġnetwork . run Network () ĊĠĠĠĠĠĠĠ Ġval Ġsigned Transaction Ġ= Ġverify Check El ig ibility Flow Future . get () ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġsigned Transaction . tx . inputs . size . to Long ()) ĊĠĠĠĠĠĠĠ Ġ// ĠThe Ġsingle Ġattachment Ġis Ġthe Ġcontract Ġattachment . ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġsigned Transaction . tx . attachments . size . to Long ()) ĊĠĠĠĠĠĠĠ ĠassertEquals ( null , Ġsigned Transaction . tx . time Window ) ĊĠĠĠ Ġ} Ċ }