package Ġcom . sw iss chain . matching . engine . services Ċ Ċ import Ġcom . sw iss chain . matching . engine . Abstract Test Ċ import Ġcom . sw iss chain . matching . engine . config . Test ApplicationContext Ċ import Ġcom . sw iss chain . matching . engine . da os . Incoming Limit Order Ċ import Ġcom . sw iss chain . matching . engine . da os . setting . Available Setting Group Ċ import Ġcom . sw iss chain . matching . engine . database . Test Di ctionaries Database Accessor Ċ import Ġcom . sw iss chain . matching . engine . database . Test Settings Database Accessor Ċ import Ġcom . sw iss chain . matching . engine . outgoing . messages . v 2 . enums . Order Reject Reason Ċ import Ġcom . sw iss chain . matching . engine . outgoing . messages . v 2 . enums . Order Status Ċ import Ġcom . sw iss chain . matching . engine . outgoing . messages . v 2 . events . Execution Event Ċ import Ġcom . sw iss chain . matching . engine . utils . Di ctionaries Init Ċ import Ġcom . sw iss chain . matching . engine . utils . Message Builder Ċ import Ġcom . sw iss chain . matching . engine . utils . Message Builder . Companion . build Limit Order Ċ import Ġcom . sw iss chain . matching . engine . utils . Message Builder . Companion . build Multi Limit Order Wrapper Ċ import Ġcom . sw iss chain . matching . engine . utils . get Setting Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . boot . test . context . SpringBootTest Ċ import Ġorg . springframework . boot . test . context . Test Configuration Ċ import Ġorg . springframework . context . annotation . Bean Ċ import Ġorg . springframework . context . annotation . Primary Ċ import Ġorg . springframework . test . annotation . Dir ties Context Ċ import Ġorg . springframework . test . context . junit 4 . Spring Runner Ċ import Ġkotlin . test . assertEquals Ċ Ċ @ RunWith ( Spring Runner :: class ) Ċ @ SpringBootTest ( classes Ġ= Ġ[( Test ApplicationContext :: class ), Ġ( Negative Price Test . Config :: class )]) Ċ @ Dir ties Context ( class Mode Ġ= ĠD irt ies Context . Class Mode . AFTER _ EACH _ TEST _ METHOD ) Ċ class ĠNegative Price Test Ġ: ĠAbstract Test () Ġ{ ĊĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġtest Settings Database Accessor : ĠTest Settings Database Accessor ĊĊĠĠĠ Ġ@ Test Configuration ĊĠĠĠ Ġclass ĠConfig Ġ{ ĊĠĠĠĠĠĠĠ Ġ@ Bean ĊĠĠĠĠĠĠĠ Ġ@ Primary ĊĠĠĠĠĠĠĠ Ġfun Ġtest Di ctionaries Database Accessor (): ĠTest Di ctionaries Database Accessor Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġtest Di ctionaries Database Accessor Ġ= ĠTest Di ctionaries Database Accessor () ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġtest Di ctionaries Database Accessor . add Asset ( Di ctionaries Init . create Asset (" USD ", Ġ 2 )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtest Di ctionaries Database Accessor . add Asset ( Di ctionaries Init . create Asset (" EUR ", Ġ 2 )) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn Ġtest Di ctionaries Database Accessor ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmessage Builder : ĠMessage Builder ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest Balance Holder Wrapper . update Balance ( 0 , Ġ" USD ", Ġ 1 . 0 ) ĊĠĠĠĠĠĠĠ Ġtest Balance Holder Wrapper . update Reserved Balance ( 0 , Ġ" USD ", Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġtest Di ctionaries Database Accessor . add Asset Pair ( Di ctionaries Init . create Asset Pair (" EUR USD ", Ġ" EUR ", Ġ" USD ", Ġ 5 )) ĊĊĠĠĠĠĠĠĠ Ġinit Services () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Limit Order () Ġ{ ĊĠĠĠĠĠĠĠ Ġsingle Limit Order Service . process Message ( message Builder . build Limit Order Wrapper ( build Limit Order ( wallet Id Ġ= Ġ 0 , Ġasset Id Ġ= Ġ" EUR USD ", Ġprice Ġ= Ġ- 1 . 0 , Ġvolume Ġ= Ġ 1 . 0 ))) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġclients Events Queue . size ) ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġclients Events Queue . poll () Ġas ĠExecution Event ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġresult . orders . size ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Order Status . RE JECT ED , Ġresult . orders . first (). status ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Order Reject Reason . INVALID _ PRICE , Ġresult . orders . first (). reject Reason ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Trusted Client Multi Limit Order () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest Settings Database Accessor . create OrUpdate Setting ( Available Setting Group . TR UST ED _ CLIENT S , Ġget Setting (" 0 ")) ĊĊĠĠĠĠĠĠĠ Ġinit Services () ĊĊĠĠĠĠĠĠĠ Ġmulti Limit Order Service . process Message ( build Multi Limit Order Wrapper (" EUR USD ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠIncoming Limit Order ( 1 . 0 , Ġ 1 . 0 , Ġid Ġ= Ġ" order 1 "), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠIncoming Limit Order ( 1 . 0 , Ġ- 1 . 0 , Ġid Ġ= Ġ" order 2 ") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ))) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġtrusted Clients Events Queue . size ) ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġtrusted Clients Events Queue . poll () ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġresult . orders . size ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Order Status . PL AC ED , Ġresult . orders . first Ġ{ Ġit . external Id Ġ== Ġ" order 1 " Ġ}. status ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġtest Order Database Accessor . get Orders (" EUR USD ", Ġtrue ). size ) ĊĠĠĠ Ġ} Ċ }