package Ġorg . gmd . slack . command Ċ Ċ import Ġorg . gmd . Algorithm Ċ import Ġorg . gmd . Env Provider ForTesting Ċ import Ġorg . gmd . TestData . Companion . dummy Ċ import Ġorg . gmd . TestData . Companion . player 1 Ċ import Ġorg . gmd . TestData . Companion . player 2 Ċ import Ġorg . gmd . model . E volution Ċ import Ġorg . gmd . service . Async Game Service ForTesting Ċ 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 Ċ Ċ @ RunWith ( Spring Runner :: class ) Ċ @ SpringBootTest Ċ class ĠAdd Game Test Ġ{ ĊĊĠĠĠ Ġ@ Mock Bean ĊĠĠĠ Ġlateinit Ġvar Ġgame Service : ĠGame Service ĊĊĠĠĠ Ġval Ġaccount Ġ= Ġ" test " ĊĠĠĠ Ġval Ġadded Game Ġ= Ġdummy () ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġfun Ġadd Game Should Print Feedback Of The Added Game () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġhelper Ġ= ĠSlack Response Helper ({ Ġ_ Ġ-> Ġrun Ġ{} Ġ}) ĊĊĠĠĠĠĠĠĠ Ġ// TODO : ĠGive Ġit Ġa Ġtry Ġto Ġmock ito Ġkotlin Ġand Ġsee Ġif Ġit Ġworks Ġbetter Ġwith Ġmocks Ġ: _( ĊĠĠĠĠĠĠĠ ĠMockito .` when `( game Service . add Game ( account , Ġadded Game )). thenReturn ( added Game ) ĊĊĠĠĠĠĠĠĠ ĠAdd Game ( response Ġ= Ġhelper , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġenv Provider Ġ= ĠEnv Provider ForTesting ( empty Map (), Ġadded Game . timestamp !! ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġservice Ġ= Ġgame Service , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġasync Service Ġ= ĠAsync Game Service ForTesting ( game Service ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġaccount Ġ= Ġaccount , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġtournament Ġ= Ġadded Game . tournament ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. parse ( listOf ( player 1 , Ġplayer 2 )) ĊĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Good Ġgame ! ĠA Ġnew Ġgame Ġentry Ġhas Ġbeen Ġcreated !", Ġhelper . slack Response !!. text ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" 1 . Ġplayer 1 \ n 2 . Ġplayer 2 ", Ġhelper . slack Response !!. attachments . first (). text ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" in _ channel ", Ġhelper . slack Response !!. response Type ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġfun Ġadd Game Should Print E lo E volution If Required () Ġ{ ĊĠĠĠĠĠĠĠ Ġvar Ġasync Response : ĠSlack Response ? Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġval Ġhelper Ġ= ĠSlack Response Helper Ġ{ Ġresponse Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġrun Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġasync Response Ġ= Ġresponse ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġval Ġevolution s Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠE volution ( player 1 , ĠlistOf ( Pair ( 1 2 0 0 , Ġ 0 L ), ĠPair ( 1 2 1 3 , Ġ 0 L ))), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠE volution ( player 2 , ĠlistOf ( Pair ( 1 2 0 0 , Ġ 0 L ), ĠPair ( 1 1 9 3 , Ġ 0 L ))) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠMockito .` when `( game Service . add Game ( account , Ġadded Game )). thenReturn ( added Game ) ĊĠĠĠĠĠĠĠ ĠMockito .` when `( game Service . compute Tournament Member Score E volution ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġaccount Ġ= Ġaccount , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġtournament Ġ= Ġadded Game . tournament , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġalg Ġ= ĠAlgorithm . E LO , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġplayer Ġ= ĠlistOf ( player 1 , Ġplayer 2 ))). thenReturn ( e volution s ) ĊĊĊĠĠĠĠĠĠĠ ĠAdd Game ( response Ġ= Ġhelper , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġenv Provider Ġ= ĠEnv Provider ForTesting ( empty Map (), Ġadded Game . timestamp !! ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġservice Ġ= Ġgame Service , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġasync Service Ġ= ĠAsync Game Service ForTesting ( game Service ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġaccount Ġ= Ġaccount , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġtournament Ġ= Ġadded Game . tournament ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. parse ( listOf ( player 1 , Ġplayer 2 )) ĊĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" Good Ġgame ! ĠA Ġnew Ġgame Ġentry Ġhas Ġbeen Ġcreated !", Ġhelper . slack Response !!. text ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" 1 . Ġplayer 1 \ n 2 . Ġplayer 2 ", Ġhelper . slack Response !!. attachments . first (). text ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" 1 . Ġplayer 1 Ġ( 1 2 1 3 , Ġ+ 1 3 )\ n 2 . Ġplayer 2 Ġ( 1 1 9 3 , Ġ- 7 )", Ġasync Response !!. attachments . first (). text ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" in _ channel ", Ġhelper . slack Response !!. response Type ) ĊĊĠĠĠ Ġ} Ċ } ĊĊ