package Ġcom . template Ċ Ċ import Ġcom . google . common . collect . ImmutableList Ċ import Ġgro ovy . util . Gro ovy TestCase . assertEquals Ċ import Ġnet . cord a . core . identity . C ord a X 5 0 0 Name Ċ import Ġnet . cord a . core . identity . Party Ċ import Ġnet . cord a . core . utilities . get OrThrow Ċ import Ġnet . cord a . testing . core . Test Identity Ċ import Ġnet . cord a . testing . node . Mock Network Ċ import Ġnet . cord a . testing . node . Started Mock Node Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ Ċ class ĠRequest Loan Flow Test Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġnetwork : ĠMock Network ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġnode A : ĠStarted Mock Node ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġnode B : ĠStarted Mock Node ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun Ġsetup () Ġ{ ĊĠĠĠĠĠĠĠ Ġnetwork Ġ= ĠMock Network ( ImmutableList . of (" com . template ")) ĊĠĠĠĠĠĠĠ Ġnode A Ġ= Ġnetwork . create Party Node ( C ord a X 5 0 0 Name (" Borrow er ", Ġ"", Ġ" GB ")) ĊĠĠĠĠĠĠĠ Ġnode B Ġ= Ġnetwork . create Party Node ( C ord a X 5 0 0 Name (" Inter medi ary ", Ġ"", Ġ" GB ")) ĊĠĠĠĠĠĠĠ Ġ// Ġval Ġnode A Ġ= ĠTest Identity ( C ord a X 5 0 0 Name (" Borrow er ",""," GB ")). party ĊĠĠĠĠĠĠĠ Ġ// Ġval Ġnode B Ġ= ĠTest Identity ( C ord a X 5 0 0 Name (" Inter medi ary ",""," GB ")). party ĊĠĠĠĠĠĠĠ Ġnetwork . run Network () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ After ĊĠĠĠ Ġfun ĠtearDown () Ġ{ ĊĠĠĠĠĠĠĠ Ġnetwork . stop Nodes () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Flow Ġrecords Ġtransaction Ġin Ġboth Ġparties Ġvault `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġflow Ġ= ĠRequest Loan Flow ( 1 0 0 0 , Ġ 1 0 , Ġ 1 , Ġinter medi ary Ġ= Ġnode B . info . legal Id entities [ 0 ]) ĊĠĠĠĠĠĠĠ Ġval Ġfuture Ġ= Ġnode A . start Flow ( flow ) ĊĠĠĠĠĠĠĠ Ġnetwork . run Network () ĊĠĠĠĠĠĠĠ Ġval Ġsigned Tx Ġ= Ġfuture . get OrThrow () ĊĠĠĠĠĠĠĠ Ġfor Ġ( node Ġin ĠlistOf ( node A , Ġnode B )) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( signed Tx , Ġnode . services . validated Transactions . getTransaction ( signed Tx . id )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ// node . services . validated Transactions . getTransaction ( signed Tx . id ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġfun Ġtransaction Construct edBy Flow Has One Request Loan Command () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġflow Ġ= ĠRequest Loan Flow ( 1 0 0 0 , Ġ 1 0 , Ġ 1 , Ġinter medi ary Ġ= Ġnode B . info . legal Id entities [ 0 ]) ĊĠĠĠĠĠĠĠ Ġval Ġfuture Ġ= Ġnode A . start Flow ( flow ) ĊĊĠĠĠĠĠĠĠ Ġnetwork . run Network () ĊĊĠĠĠĠĠĠĠ Ġval Ġsigned Transaction Ġ= Ġfuture . get () ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġsigned Transaction . tx . commands . size . to Long ()) ĊĠĠĠĠĠĠĠ Ġval Ġ( value ) Ġ= Ġsigned Transaction . tx . commands [ 0 ] ĊĊĠĠĠĠĠĠĠ Ġassert ( value Ġis ĠRequest And Neg otiate Loan Contract . Commands . Request Loan ) ĊĊĠĠĠ Ġ} ĊĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġfun Ġtransaction Construct edBy Flow Uses The Correct Not ary () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġinter medi ary : ĠParty ĊĊĠĠĠĠĠĠĠ Ġ// val Ġflow Ġ= ĠToken Issue Flow ( node B . info . legal Id entities [ 0 ], Ġ 9 9 ) ĊĠĠĠĠĠĠĠ Ġval Ġflow Ġ= ĠRequest Loan Flow ( 1 0 0 0 , Ġ 1 0 , Ġ 1 , Ġinter medi ary Ġ= Ġnode A . info . legal Id entities [ 0 ]) ĊĠĠĠĠĠĠĠ Ġval Ġfuture Ġ= Ġnode A . start Flow ( flow ) ĊĠĠĠĠĠĠĠ Ġnetwork . run Network () ĊĠĠĠĠĠĠĠ Ġval Ġsigned Transaction Ġ= Ġfuture . get () ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġsigned Transaction . tx . output States . size . to Long ()) ĊĠĠĠĠĠĠĠ Ġval Ġoutput Ġ= Ġsigned Transaction . tx . outputs [ 0 ] ĊĠĠĠĠĠĠĠ Ġ// val Ġoutput Ġ= Ġsigned Transact io ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( network . not ary Nodes [ 0 ]. info . legal Id entities [ 0 ], Ġoutput . not ary ) ĊĊĠĠĠ Ġ} Ċ }