package Ġcom . red iss i . tr akt . services Ċ Ċ import Ġcom . red iss i . tr akt . Base TestCase Ċ import Ġcom . red iss i . tr akt . entities .* Ċ import Ġkotlinx . coroutines . delay Ċ import Ġkotlinx . coroutines . run Blocking Ċ import Ġorg . am sh ove . k lu ent . shouldBe EqualTo Ċ import Ġorg . am sh ove . k lu ent . should Not BeNull Ċ import Ġorg . junit . Test Ċ import Ġjava . io . IOException Ċ Ċ class ĠSc ro bble Test Ġ: ĠBase TestCase () Ġ{ ĊĠĠĠ Ġprivate Ġfun Ġgen Episode Progress ( progress : ĠDouble ): ĠSc ro bble Progress Ġ{ ĊĠĠĠĠĠĠĠ Ġ// ĠUse Ġa Ġdifferent Ġepisode Ġthan Ġfor Ġother Ġtests Ġto Ġavoid Ġconflicts . ĊĠĠĠĠĠĠĠ Ġval Ġepisode Ġ= ĠSync Episode ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġids Ġ= ĠEp isode Ids . tv db ( 4 6 4 7 8 8 7 ) Ġ/* ĠAg ents Ġof ĠSh ield ĠS 0 1 E 0 2 Ġ*/ ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġreturn ĠSc ro bble Progress . create ( episode , Ġprogress , Ġnull , Ġnull ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġgen Movie Progress ( progress : ĠDouble ): ĠSc ro bble Progress Ġ{ ĊĠĠĠĠĠĠĠ Ġ// ĠUse Ġa Ġdifferent Ġmovie Ġthan Ġfor Ġother Ġtests Ġto Ġavoid Ġconflicts . ĊĠĠĠĠĠĠĠ Ġval Ġmovie Ġ= ĠSync Movie ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġids Ġ= ĠMovie Ids . t mdb ( 6 0 3 ) Ġ/* ĠThe ĠMatrix Ġ*/ ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġreturn ĠSc ro bble Progress . create ( movie , Ġprogress , Ġnull , Ġnull ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( IOException :: class , ĠInterruptedException :: class ) ĊĠĠĠ Ġfun Ġ` sc ro bble Ġan Ġepisode `() Ġ= Ġrun Blocking < Unit > Ġ{ ĊĠĠĠĠĠĠĠ Ġvar Ġplayback Response Ġ= Ġtr akt . sc ro bble (). start Watch ing ( gen Episode Progress ( 2 0 . 0 )) ĊĠĠĠĠĠĠĠ Ġplayback Response . should Not BeNull () ĊĠĠĠĠĠĠĠ Ġplayback Response . action . should Not BeNull (). shouldBe EqualTo (" start ") ĊĊĠĠĠĠĠĠĠ Ġ// ĠGive Ġthe Ġserver Ġsome Ġtime Ġto Ġprocess Ġthe Ġrequest . ĊĠĠĠĠĠĠĠ Ġdelay ( 1 5 0 0 ) ĊĊĠĠĠĠĠĠĠ Ġplayback Response Ġ= Ġtr akt . sc ro bble (). pause Watch ing ( gen Episode Progress ( 5 0 . 0 )) ĊĠĠĠĠĠĠĠ Ġplayback Response . should Not BeNull () ĊĠĠĠĠĠĠĠ Ġplayback Response . action . should Not BeNull (). shouldBe EqualTo (" pause ") ĊĊĠĠĠĠĠĠĠ Ġ// ĠGive Ġthe Ġserver Ġsome Ġtime Ġto Ġprocess Ġthe Ġrequest . ĊĠĠĠĠĠĠĠ Ġdelay ( 1 5 0 0 ) ĊĠĠĠĠĠĠĠ Ġplayback Response Ġ= Ġtr akt . sc ro bble (). stop Watch ing ( gen Episode Progress ( 7 5 . 0 )) ĊĊĠĠĠĠĠĠĠ Ġ// ĠA bove Ġ 8 0 % Ġprogress Ġaction Ġis Ġ" sc ro bble ", Ġbelow Ġ" pause ". ĊĠĠĠĠĠĠĠ Ġ// ĠPause Ġto Ġavoid Ġblocking Ġthe Ġnext Ġtest Ġuntil Ġthe Ġepisode Ġruntime Ġhas Ġpassed . ĊĠĠĠĠĠĠĠ Ġplayback Response . should Not BeNull () ĊĠĠĠĠĠĠĠ Ġplayback Response . action . should Not BeNull (). shouldBe EqualTo (" pause ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( IOException :: class , ĠInterruptedException :: class ) ĊĠĠĠ Ġfun Ġ` sc ro bble Ġa Ġmovie `() Ġ= Ġrun Blocking < Unit > Ġ{ ĊĠĠĠĠĠĠĠ Ġvar Ġplayback Response Ġ= Ġtr akt . sc ro bble (). start Watch ing ( gen Movie Progress ( 2 0 . 0 )) ĊĠĠĠĠĠĠĠ Ġplayback Response . should Not BeNull () ĊĠĠĠĠĠĠĠ Ġplayback Response . action . should Not BeNull (). shouldBe EqualTo (" start ") ĊĠĠĠĠĠĠĠ Ġ// ĠGive Ġthe Ġserver Ġsome Ġtime Ġto Ġprocess Ġthe Ġrequest . ĊĠĠĠĠĠĠĠ Ġdelay ( 1 5 0 0 ) ĊĠĠĠĠĠĠĠ Ġplayback Response Ġ= Ġtr akt . sc ro bble (). pause Watch ing ( gen Movie Progress ( 5 0 . 0 )) ĊĊĠĠĠĠĠĠĠ Ġplayback Response . should Not BeNull () ĊĠĠĠĠĠĠĠ Ġplayback Response . action . should Not BeNull (). shouldBe EqualTo (" pause ") ĊĠĠĠĠĠĠĠ Ġ// ĠGive Ġthe Ġserver Ġsome Ġtime Ġto Ġprocess Ġthe Ġrequest . ĊĠĠĠĠĠĠĠ Ġdelay ( 1 5 0 0 ) ĊĠĠĠĠĠĠĠ Ġplayback Response Ġ= Ġtr akt . sc ro bble (). stop Watch ing ( gen Movie Progress ( 7 5 . 0 )) ĊĊĠĠĠĠĠĠĠ Ġ// ĠA bove Ġ 8 0 % Ġprogress Ġaction Ġis Ġ" sc ro bble ", Ġbelow Ġ" pause ". ĊĠĠĠĠĠĠĠ Ġ// ĠPause Ġto Ġavoid Ġblocking Ġthe Ġnext Ġtest Ġuntil Ġthe Ġmovie Ġruntime Ġhas Ġpassed . ĊĠĠĠĠĠĠĠ Ġplayback Response . should Not BeNull () ĊĠĠĠĠĠĠĠ Ġplayback Response . action . should Not BeNull (). shouldBe EqualTo (" pause ") ĊĠĠĠ Ġ} Ċ }