package Ġcom . j algo arena Ċ Ċ import Ġcom . google . common . io . Resources Ċ import Ġcom . j algo arena . config . Test ApplicationConfiguration Ċ import Ġcom . j algo arena . domain . StatusCode Ċ import Ġcom . j algo arena . domain . Submission Ċ import Ġcom . j algo arena . web . Problems Controller Ċ import Ġcom . j algo arena . web . Sub missions Listener Ċ import Ġjunit params . JUnit Params Runner Ċ import Ġjunit params . Parameters Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . junit . Class Rule Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . test . context . Context Configuration Ċ import Ġorg . springframework . test . context . junit 4 . rules . Spring Class Rule Ċ import Ġorg . springframework . test . context . junit 4 . rules . Spring Method Rule Ċ import Ġjava . time . LocalDateTime Ċ Ċ @ RunWith ( JUnit Params Runner :: class ) Ċ @ Context Configuration ( classes Ġ= Ġ[ Test ApplicationConfiguration :: class ]) Ċ class ĠJ udge Controller IntegrationTest Ġ{ ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĊĠĠĠĠĠĠĠ Ġ@ Class Rule ĊĠĠĠĠĠĠĠ Ġ@ Jvm Field Ġval ĠS CR Ġ= ĠSpring Class Rule () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Rule ĊĠĠĠ Ġ@ Jvm Field Ġval Ġspring Method Rule Ġ= ĠSpring Method Rule () ĊĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġsubmissions Listener : ĠSub missions Listener ĊĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġproblems Controller : ĠPro blems Controller ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Parameters (" fib , ĠF ib onacci ", Ġ" 2 - sum , Ġ 2 ĠSum ", Ġ" stoi , ĠString Ġto ĠInteger Ġ( stoi )", Ġ" word - lad der , ĠWord ĠL adder ") ĊĠĠĠ Ġfun Ġfinds Existing Problems ( problem Id : ĠString , Ġproblem Title : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfib Ġ= Ġproblems Controller . problem ( problem Id ) ĊĠĠĠĠĠĠĠ ĠassertThat ( fib . title ). isEqualTo ( problem Title ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Parameters (" fib ", Ġ" 2 - sum ", Ġ" stoi ", Ġ" word - lad der ") ĊĠĠĠ Ġfun Ġincludes Problem In ListOf All Problems ( problem Id : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġproblem Ids Ġ= Ġproblems Controller . problems () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. map Ġ{ Ġit . id Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġproblem Ids . contains ( problem Id ) ĊĠĠĠĠĠĠĠ ĠassertThat ( result ). isTrue () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Parameters (" fib ", Ġ" 2 - sum ", Ġ" stoi ", Ġ" word - lad der ") ĊĠĠĠ Ġfun Ġgenerates Non Empty Java Skeleton Code ( problem Id : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġskeleton Code Ġ= Ġproblems Controller . problem ( problem Id ). skeleton Code ĊĠĠĠĠĠĠĠ ĠassertThat ( skeleton Code ). isNotEmpty () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Parameters (" 2 - sum , ĠTwo Sum ", Ġ" fib , ĠF ib Fast ", Ġ" stoi , ĠMy Sto i ", Ġ" word - lad der , ĠWord L adder ", Ġ" is - string - unique , ĠIs String Unique 2 ", Ġ" check - perm , ĠCheck Perm ", Ġ" pal indrome - perm , ĠPal indrome Perm ", Ġ" one - away , ĠOne Away ", Ġ" string - compress , ĠString Compress ", Ġ" rotate - matrix , ĠRotate Matrix ", Ġ" zero - matrix , ĠZero Matrix ", Ġ" remove - d ups , ĠRemove D ups ", Ġ" k th - to - last , ĠK Th To Last ", Ġ" string - rotation , ĠString Rotation ", Ġ" sum - lists , ĠSum Lists ", Ġ" sum - lists - 2 , ĠSum Lists 2 ", Ġ" pal indrome - list , ĠPal indrome List ", Ġ" binary - search , ĠBinary Search ", Ġ" delete - tail - node , ĠDelete Tail Node ", Ġ" repeated - elements , ĠRe peated Elements ", Ġ" first - non - repeated - char , ĠFirst Non Repeated Char ", Ġ" find - middle - node , ĠFind Middle Node ", Ġ" horizontal - flip , ĠHorizontal Flip ", Ġ" vertical - flip , ĠVertical Flip ", Ġ" single - number , ĠSingle Number ", Ġ" pre order - traversal , ĠPre order Traversal ", Ġ" in order - traversal , ĠIn order Traversal ", Ġ" post order - traversal , ĠPost order Traversal ", Ġ" height - binary - tree , ĠHeight Of Binary Tree ", Ġ" sum - binary - tree , ĠSum Binary Tree ", Ġ" insert - stars , ĠInsert St ars ", Ġ" transpose - matrix , ĠTr anspose Matrix ", Ġ" merge - k - sorted - linked - lists , ĠMerge K Sorted LinkedList s ") ĊĠĠĠ Ġfun Ġjud ges Java Correct Solution ( problem Id : ĠString , Ġsolution Id : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġsource Code Ġ= ĠResources . toString ( Resources . getResource ("$ solution Id . java "), ĠChar sets . UTF _ 8 ) ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġsubmissions Listener . judge ( Submission ( sourceCode , Ġ" 0 - 0 ", Ġ" 0 ", Ġproblem Id , ĠLocalDateTime . now (), Ġ 0 , Ġ" dummy _ token ")) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( result . statusCode ). isEqualTo ( StatusCode . ACCEPT ED . toString ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġreturns Formatted Message If Compilation Error () Ġ{ ĊĊĠĠĠĠĠĠĠ Ġval Ġskeleton Code Ġ= Ġproblems Controller . problem (" fib "). skeleton Code !! ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġsubmissions Listener . judge ( Submission ( skeleton Code , Ġ" 0 - 0 ", Ġ" 3 ", Ġ" fib ", ĠLocalDateTime . now (), Ġ 0 , Ġ" dummy _ token ")) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( result . errorMessage ). isEqualTo (" Line : 1 1 : Ġerror : Ġmissing Ġreturn Ġstatement \ n ĠĠĠ Ġ}\ n ĠĠĠ Ġ^ \ n ") ĊĠĠĠ Ġ} Ċ } Ċ