package Ġme . pro xer . library Ċ Ċ import Ġokhttp 3 . mock webserver . Mock Response Ċ import Ġokhttp 3 . mock webserver . Mock WebServer Ċ import Ġokhttp 3 . mock webserver . Re corded Request Ċ import Ġjava . lang . invoke . Method Handles Ċ import Ġjava . text . SimpleDateFormat Ċ import Ġjava . util . Date Ċ import Ġjava . util . Locale Ċ import Ġjava . util . concurrent . TimeUnit Ċ Ċ fun Ġfrom Resource ( file : ĠString ): ĠString Ġ= ĠMethod Handles . lookup (). lookup Class (). class Loader ĊĠĠĠ Ġ. let Ġ{ Ġrequire NotNull ( it . getResource ( file )) Ġ} ĊĠĠĠ Ġ. read Text ( Charsets . UTF _ 8 ) Ċ Ċ fun ĠString . to Pro xer Date (): ĠDate Ġ= ĠSimpleDateFormat (" yyyy - MM - dd ", ĠLocale . GER MAN Y ). parse ( this ) Ċ fun ĠString . to Pro xer DateTime (): ĠDate Ġ= ĠSimpleDateFormat (" yyyy - MM - dd Ġhh : mm : ss ", ĠLocale . GER MAN Y ). parse ( this ) Ċ Ċ fun Ġ< T > ĠMock WebServer . run Request ( response : ĠMock Response , Ġaction : Ġ() Ġ-> ĠT ): ĠPair < T , ĠRe corded Request > Ġ{ ĊĠĠĠ Ġenqueue ( response ) ĊĊĠĠĠ Ġreturn Ġtry Ġ{ ĊĠĠĠĠĠĠĠ Ġaction () Ġto Ġrequire NotNull ( take Request ( 3 , ĠTimeUnit . SECONDS )) ĊĠĠĠ Ġ} Ġcatch Ġ( error : ĠThrowable ) Ġ{ ĊĠĠĠĠĠĠĠ Ġtake Request ( 3 , ĠTimeUnit . SECONDS ) ĊĊĠĠĠĠĠĠĠ Ġthrow Ġerror ĊĠĠĠ Ġ} Ċ } Ċ Ċ fun Ġ< T > ĠMock WebServer . run Request Ign oring Error ( response : ĠMock Response , Ġaction : Ġ() Ġ-> ĠT ): ĠPair < T ?, ĠRe corded Request > Ġ{ ĊĠĠĠ Ġenqueue ( response ) ĊĊĠĠĠ Ġreturn Ġtry Ġ{ ĊĠĠĠĠĠĠĠ Ġaction () Ġto Ġrequire NotNull ( take Request ( 3 , ĠTimeUnit . SECONDS )) ĊĠĠĠ Ġ} Ġcatch Ġ( error : ĠThrowable ) Ġ{ ĊĠĠĠĠĠĠĠ Ġnull Ġto Ġrequire NotNull ( take Request ( 3 , ĠTimeUnit . SECONDS )) ĊĠĠĠ Ġ} Ċ } Ċ Ċ fun Ġ< T > ĠMock WebServer . run Request ( body File : ĠString , Ġaction : Ġ() Ġ-> ĠT ): ĠPair < T , ĠRe corded Request > Ġ{ ĊĠĠĠ Ġreturn Ġrun Request ( Mock Response (). set Body ( from Resource ( body File )), Ġaction ) Ċ } Ċ Ċ fun Ġ< T > ĠMock WebServer . run Request Ign oring Error ( body File : ĠString , Ġaction : Ġ() Ġ-> ĠT ): ĠPair < T ?, ĠRe corded Request > Ġ{ ĊĠĠĠ Ġreturn Ġrun Request Ign oring Error ( Mock Response (). set Body ( from Resource ( body File )), Ġaction ) Ċ } Ċ