package Ġpl . be one . prom ena . alf resco . module . core . external . transformation Ċ Ċ import Ġio . kot lint est . shouldBe Ċ import Ġio . kot lint est . should Not Throw Any Ċ import Ġio . kot lint est . should Throw Exactly Ċ import Ġkotlinx . coroutines . as Coroutine Dispatcher Ċ import Ġkotlinx . coroutines . delay Ċ import Ġkotlinx . coroutines . launch Ċ import Ġkotlinx . coroutines . run Blocking Ċ import Ġorg . alf resco . rad . test . A lf resco TestRunner Ċ import Ġorg . alf resco . service . cm r . repository . Node Ref Ċ import Ġorg . alf resco . service . cm r . repository . Store Ref Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġpl . be one . prom ena . alf resco . module . core . application model . transformation . Transformation Execution Ċ import Ġpl . be one . prom ena . alf resco . module . core . application model . transformation . Transformation Execution Result Ċ import Ġpl . be one . prom ena . alf resco . module . core . external . Abstract Utils A lf resco IT Ċ import Ġpl . be one . prom ena . alf resco . module . core . external . transformation . manager . Memory With A lf resco Persistence Prom ena Mutable Transformation Manager Ċ import Ġpl . be one . prom ena . core . internal . serialization . K ry o Serialization Service Ċ import Ġjava . time . Duration Ċ import Ġjava . time . Duration . ZERO Ċ import Ġjava . util . concurrent . Executors Ċ import Ġjava . util . concurrent . TimeoutException Ċ Ċ @ RunWith ( A lf resco TestRunner :: class ) Ċ class ĠMemory With A lf resco Persistence Prom ena Mutable Transformation Manager Test IT Ġ: ĠAbstract Utils A lf resco IT () Ġ{ ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġtransformation Execution Result Ġ= ĠTransformation Execution Result ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠNode Ref ( Store Ref . STORE _ REF _ WORK SPACE _ SP ACES STORE , Ġ" b 0 bfb 1 4 c - be 3 8 - 4 8 be - 9 0 c 3 - cae 4 a 7 fd 0 c 8 f "), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠNode Ref ( Store Ref . STORE _ REF _ WORK SPACE _ SP ACES STORE , Ġ" 7 ab df 1 e 2 - 9 2 f 4 - 4 7 b 2 - 9 8 3 a - 6 1 1 e 4 2 f 3 5 5 5 c ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġexception Ġ= ĠRuntimeException (" exception ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġval Ġserialization Service Ġ= ĠK ry o Serialization Service () ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġprom ena Mutable Transformation Manager : ĠMemory With A lf resco Persistence Prom ena Mutable Transformation Manager ĊĊĠĠĠ Ġprivate Ġval Ġdispatcher Ġ= ĠExec utors . new Fixed ThreadPool ( 4 ). as Coroutine Dispatcher () ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġprom ena Mutable Transformation Manager Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠMemory With A lf resco Persistence Prom ena Mutable Transformation Manager ( true , Ġ 1 0 0 , ĠDuration . of Millis ( 5 0 0 ), Ġserialization Service , Ġservice Registry ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcorrect Flow And Waiting For Result Before Transaction Is Completed () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġtransformation Execution Ġ= Ġprom ena Mutable Transformation Manager . start Transformation () ĊĠĠĠĠĠĠĠ Ġprom ena Mutable Transformation Manager . complete Transformation ( transformation Execution , Ġtransformation Execution Result ) ĊĠĠĠĠĠĠĠ Ġprom ena Mutable Transformation Manager . getResult ( transformation Execution , ĠZERO ) ĠshouldBe Ġtransformation Execution Result ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcorrect Flow And Waiting For Result After Transaction Is Completed () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġtransformation Execution Ġ= Ġprom ena Mutable Transformation Manager . start Transformation () ĊĠĠĠĠĠĠĠ Ġrun Blocking ( dispatcher ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlaunch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprom ena Mutable Transformation Manager . complete Transformation ( transformation Execution , Ġtransformation Execution Result ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġlaunch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġdelay ( 5 0 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprom ena Mutable Transformation Manager . getResult ( transformation Execution , ĠZERO ) ĠshouldBe Ġtransformation Execution Result ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġincorrect Flow And Waiting For Result Before Transaction Is Completed () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġtransformation Execution Ġ= Ġprom ena Mutable Transformation Manager . start Transformation () ĊĠĠĠĠĠĠĠ Ġprom ena Mutable Transformation Manager . complete Error Transformation ( transformation Execution , Ġexception ) ĊĠĠĠĠĠĠĠ Ġshould Throw Exactly < RuntimeException > Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġprom ena Mutable Transformation Manager . getResult ( transformation Execution , ĠZERO ) ĊĠĠĠĠĠĠĠ Ġ}. message ĠshouldBe Ġexception . message ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġincorrect Flow And Waiting For Result After Transaction Is Completed () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġtransformation Execution Ġ= Ġprom ena Mutable Transformation Manager . start Transformation () ĊĠĠĠĠĠĠĠ Ġrun Blocking ( dispatcher ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlaunch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprom ena Mutable Transformation Manager . complete Error Transformation ( transformation Execution , Ġexception ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġlaunch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġdelay ( 1 0 0 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġshould Throw Exactly < RuntimeException > Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprom ena Mutable Transformation Manager . getResult ( transformation Execution , ĠZERO ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ}. message ĠshouldBe Ġexception . message ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġgetting Result Before Transaction Is Completed _ should Throw TimeoutException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġtransformation Execution Ġ= Ġprom ena Mutable Transformation Manager . start Transformation () ĊĠĠĠĠĠĠĠ Ġrun Blocking ( dispatcher ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlaunch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġdelay ( 1 0 0 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprom ena Mutable Transformation Manager . complete Transformation ( transformation Execution , Ġtransformation Execution Result ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġlaunch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġdelay ( 5 0 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġshould Throw Exactly < TimeoutException > Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprom ena Mutable Transformation Manager . getResult ( transformation Execution , ĠZERO ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ}. message ĠshouldBe Ġ" Waiting Ġtime Ġfor Ġtransformation Ġ< ${ transformation Execution . id }> Ġhas Ġexpired " ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġlaunch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġdelay ( 2 0 0 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprom ena Mutable Transformation Manager . getResult ( transformation Execution ) ĠshouldBe Ġtransformation Execution Result ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġdefault Wait Max () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġtransformation Execution Ġ= Ġprom ena Mutable Transformation Manager . start Transformation () ĊĠĠĠĠĠĠĠ Ġrun Blocking ( dispatcher ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlaunch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġdelay ( 7 0 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprom ena Mutable Transformation Manager . complete Transformation ( transformation Execution , Ġtransformation Execution Result ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġlaunch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġshould Throw Exactly < TimeoutException > Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprom ena Mutable Transformation Manager . getResult ( transformation Execution ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ}. message ĠshouldBe Ġ" Waiting Ġtime Ġfor Ġtransformation Ġ< ${ transformation Execution . id }> Ġhas Ġexpired " ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġlaunch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġdelay ( 1 1 0 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprom ena Mutable Transformation Manager . getResult ( transformation Execution ) ĠshouldBe Ġtransformation Execution Result ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġgetting Result Before Transaction Is Started _ should Throw IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġshould Throw Exactly < IllegalStateException > Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġprom ena Mutable Transformation Manager . getResult ( Transformation Execution (" abs ent ")) ĊĠĠĠĠĠĠĠ Ġ}. message ĠshouldBe Ġ" There Ġis Ġno Ġtransformation Ġ< abs ent > Ġin Ġprogress " ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġmarking Transaction That Was Not Started As Complete _ should Not Throw Any Exception () Ġ{ ĊĠĠĠĠĠĠĠ Ġshould Not Throw Any Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġprom ena Mutable Transformation Manager . complete Transformation ( Transformation Execution (" abs ent "), Ġtransformation Execution Result ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġstress Test () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġtransformation Execution Ġ= Ġ( 1 .. 1 0 0 ). map Ġ{ Ġprom ena Mutable Transformation Manager . start Transformation () Ġ} ĊĠĠĠĠĠĠĠ Ġrun Blocking ( dispatcher ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtransformation Execution . forEach Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġlaunch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprom ena Mutable Transformation Manager . complete Transformation ( it , Ġtransformation Execution Result ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġtransformation Execution . forEach Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġlaunch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprom ena Mutable Transformation Manager . getResult ( it , ĠDuration . of Millis ( 3 0 0 0 )) ĠshouldBe Ġtransformation Execution Result ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ }