package Ġio . open future . api . controller . api Ċ Ċ import Ġio . open future . api . config . Controller Tests Ċ import Ġio . open future . api . domain . holder . Add E thereum Share Holder Request Ċ import Ġio . open future . api . domain . holder . Update E thereum Share Holder Request Ċ import Ġio . open future . api . entity . auth . Open Key Ċ import Ġio . open future . api . entity . auth . Role Ċ import Ġio . open future . api . entity . auth . User Ċ import Ġio . open future . api . entity . scaffold . E thereum Sca ffold Ċ import Ġio . open future . api . entity . scaffold . E thereum Sca ffold Summary Ċ import Ġio . open future . api . entity . scaffold . Sca ffold Version . V 1 Ċ import Ġio . open future . api . service . E thereum Sca ffold Service Ċ import Ġorg . junit . Test Ċ import Ġorg . mockito . BDD Mockito . given Ċ import Ġorg . mockito . BDD Mockito . verify Ċ import Ġorg . springframework . boot . test . autoconfigure . web . servlet . Web Mvc Test Ċ import Ġorg . springframework . boot . test . mock . mockito . Mock Bean Ċ import Ġorg . springframework . http . HttpHeaders . AUTHORIZATION Ċ import Ġorg . springframework . http . MediaType . APPLICATION _ JSON _ UTF 8 Ċ import Ġorg . springframework . test . web . servlet . request . MockMvc Request Builders .* Ċ import Ġorg . springframework . test . web . servlet . result . MockMvc Result Matchers . status Ċ import Ġjava . math . BigInteger . ZERO Ċ Ċ @ Web Mvc Test ( E thereum Share Holder Api Controller :: class ) Ċ class ĠEthereum Share Holder Api Controller Tests Ġ: ĠController Tests () Ġ{ ĊĊĠĠĠ Ġ@ Mock Bean ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġservice : ĠEthereum Sca ffold Service ĊĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġadd Share Holder Test () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġaddress Ġ= Ġ" 0 x 8 cf 1 6 6 4 B 0 9 F 2 1 6 5 3 8 bc 9 A 3 2 B 2 c 2 6 f 8 5 a 1 9 fd 7 6 B 5 " ĊĠĠĠĠĠĠĠ Ġval Ġrequest Ġ= ĠAdd E thereum Share Holder Request ( address , Ġ 3 ) ĊĠĠĠĠĠĠĠ Ġval Ġopen Key Ġ= Ġcreate Open Key ( set Of ( Role (" ROLE _ MASTER "))) ĊĠĠĠĠĠĠĠ Ġval Ġrequest Json Ġ= ĠobjectMapper . writeValue AsString ( request ) ĊĊĠĠĠĠĠĠĠ Ġgiven ( key Service . find ( open Key . value )). willReturn ( open Key ) ĊĠĠĠĠĠĠĠ Ġgiven ( service . add Share Holder ( address , Ġopen Key . user , Ġrequest )). willReturn ( create Sca ffold Summary ()) ĊĊĠĠĠĠĠĠĠ Ġm vc . perform ( post ("/ api / ethereum - scaffold s /$ address / holders ") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. header ( AUTHORIZATION , Ġopen Key . value ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. contentType ( APPLICATION _ JSON _ UTF 8 ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. content ( request Json )) ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. andExpect ( status (). is Ok ) ĊĊĠĠĠĠĠĠĠ Ġverify ( service ). add Share Holder ( address , Ġopen Key . user , Ġrequest ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġupdate Share Holder Test () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġaddress Ġ= Ġ" 0 x 8 cf 1 6 6 4 B 0 9 F 2 1 6 5 3 8 bc 9 A 3 2 B 2 c 2 6 f 8 5 a 1 9 fd 7 6 B 5 " ĊĠĠĠĠĠĠĠ Ġval Ġrequest Ġ= ĠUpdate E thereum Share Holder Request ( 3 ) ĊĠĠĠĠĠĠĠ Ġval Ġopen Key Ġ= Ġcreate Open Key ( set Of ( Role (" ROLE _ MASTER "))) ĊĠĠĠĠĠĠĠ Ġval Ġrequest Json Ġ= ĠobjectMapper . writeValue AsString ( request ) ĊĊĠĠĠĠĠĠĠ Ġgiven ( key Service . find ( open Key . value )). willReturn ( open Key ) ĊĠĠĠĠĠĠĠ Ġgiven ( service . update Share Holder ( address , Ġopen Key . user , Ġaddress , Ġrequest )). willReturn ( create Sca ffold Summary ()) ĊĊĠĠĠĠĠĠĠ Ġm vc . perform ( put ("/ api / ethereum - scaffold s /$ address / holders /$ address ") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. header ( AUTHORIZATION , Ġopen Key . value ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. contentType ( APPLICATION _ JSON _ UTF 8 ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. content ( request Json )) ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. andExpect ( status (). is Ok ) ĊĊĠĠĠĠĠĠĠ Ġverify ( service ). update Share Holder ( address , Ġopen Key . user , Ġaddress , Ġrequest ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġremove Share Holder Test () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġaddress Ġ= Ġ" 0 x 8 cf 1 6 6 4 B 0 9 F 2 1 6 5 3 8 bc 9 A 3 2 B 2 c 2 6 f 8 5 a 1 9 fd 7 6 B 5 " ĊĠĠĠĠĠĠĠ Ġval Ġopen Key Ġ= Ġcreate Open Key ( set Of ( Role (" ROLE _ MASTER "))) ĊĊĠĠĠĠĠĠĠ Ġgiven ( key Service . find ( open Key . value )). willReturn ( open Key ) ĊĠĠĠĠĠĠĠ Ġgiven ( service . remove Share Holder ( address , Ġopen Key . user , Ġaddress )). willReturn ( create Sca ffold Summary ()) ĊĊĠĠĠĠĠĠĠ Ġm vc . perform ( delete ("/ api / ethereum - scaffold s /$ address / holders /$ address ") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. header ( AUTHORIZATION , Ġopen Key . value )) ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. andExpect ( status (). is Ok ) ĊĊĠĠĠĠĠĠĠ Ġverify ( service ). remove Share Holder ( address , Ġopen Key . user , Ġaddress ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġcreate Sca ffold Summary () Ġ= ĠEthereum Sca ffold Summary ( E thereum Sca ffold ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"", Ġ"", Ġ"", Ġ 1 , Ġ"", Ġmutable ListOf (), ĠV 1 . getId (), ĠOpen Key ( User (" ")), Ġ" 0 x 8 cf 1 6 6 4 B 0 9 F 2 1 6 5 3 8 bc 9 A 3 2 B 2 c 2 6 f 8 5 a 1 9 fd 7 6 B 5 ", Ġ""), ĠZERO , ĠZERO , Ġtrue ) Ċ Ċ }