package Ġorg . gmd . slack . command Ċ Ċ import Ġorg . gmd . TestData . Companion . dummy Ċ import Ġorg . gmd . TestData . Companion . player 1 Ċ import Ġorg . gmd . TestData . Companion . player 2 Ċ import Ġorg . gmd . service . Game Service Ċ import Ġorg . gmd . slack . model . Slack Response Ċ import Ġorg . gmd . slack . Slack Response Helper Ċ import Ġorg . junit . Assert Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . mockito . Mockito Ċ import Ġorg . springframework . boot . test . context . SpringBootTest Ċ import Ġorg . springframework . boot . test . mock . mockito . Mock Bean Ċ import Ġorg . springframework . test . context . junit 4 . Spring Runner Ċ import Ġjava . util . concurrent . Comp letableFuture Ċ import Ġjava . util . concurrent . TimeUnit Ċ Ċ @ RunWith ( Spring Runner :: class ) Ċ @ SpringBootTest Ċ class ĠMatch Up Test Ġ{ ĊĊĠĠĠ Ġ@ Mock Bean ĊĠĠĠ Ġlateinit Ġvar Ġgame Service : ĠGame Service ĊĊĠĠĠ Ġprivate Ġval Ġaccount Ġ= Ġ" test " ĊĠĠĠ Ġprivate Ġval Ġadded Game Ġ= Ġdummy () ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Slack Response () Ġ{ ĊĊĠĠĠĠĠĠĠ Ġval Ġcomplet able Future Ġ= ĠCompletableFuture < Slack Response >() ĊĠĠĠĠĠĠĠ Ġval Ġmatch Up Ġ= Ġcreate Test Match Up ( comp letableFuture ) ĊĊĠĠĠĠĠĠĠ Ġmatch Up . parse ( listOf ( player 1 , Ġplayer 2 )) ĊĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= Ġcomplet able Future . get ( 1 , ĠTimeUnit . MIN UTES ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" player 1 Ġbe ats Ġplayer 2 Ġ 1 0 0 % Ġof Ġthe Ġtimes Ġ( sample : Ġ 1 Ġgames )", Ġresponse . text ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Slack Response On Wrong Tournament () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcomplet able Future Ġ= ĠCompletableFuture < Slack Response >() ĊĠĠĠĠĠĠĠ Ġval Ġmatch Up Ġ= Ġcreate Test Match Up ( comp letableFuture , Ġ" a Ġfake Ġtournament ") ĊĊĠĠĠĠĠĠĠ Ġmatch Up . parse ( listOf ( player 1 , Ġplayer 2 )) ĊĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= Ġcomplet able Future . get ( 1 , ĠTimeUnit . MIN UTES ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" No Ġmatches Ġfound ", Ġresponse . text ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Slack Response On Un Matching () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcomplet able Future Ġ= ĠCompletableFuture < Slack Response >() ĊĠĠĠĠĠĠĠ Ġval Ġmatch Up Ġ= Ġcreate Test Match Up ( comp letableFuture ) ĊĊĠĠĠĠĠĠĠ ĠMockito .` when `( game Service . list Games ( account , Ġ 1 0 0 0 )). thenReturn ( listOf ( added Game )) ĊĊĠĠĠĠĠĠĠ Ġmatch Up . parse ( listOf ( player 1 , Ġ" unknown Ġplayer ")) ĊĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= Ġcomplet able Future . get ( 1 , ĠTimeUnit . MIN UTES ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" No Ġmatches Ġfound ", Ġresponse . text ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġcreate Test Match Up ( comp letableFuture : ĠCompletableFuture < Slack Response >, Ġmatch Up Tournament : ĠString Ġ= Ġadded Game . tournament ): ĠMatch Up Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġhelper Ġ= ĠSlack Response Helper Ġ{ Ġresponse Ġ-> Ġcomplet able Future . complete ( response ) Ġ} ĊĊĠĠĠĠĠĠĠ ĠMockito .` when `( game Service . list Games ( account , Ġadded Game . tournament , Ġ 1 0 0 0 )). thenReturn ( listOf ( added Game )) ĊĠĠĠĠĠĠĠ Ġreturn ĠMatch Up ( helper , Ġgame Service , Ġaccount , Ġmatch Up Tournament , Ġ" player ") ĊĠĠĠ Ġ} Ċ } ĊĊ