package Ġorg . v accine impact . order ly web . tests . integration _ tests . tests Ċ Ċ import Ġcom . n ha ar man . mockito _ kotlin . any Ċ import Ġcom . n ha ar man . mockito _ kotlin . do Return Ċ import Ġcom . n ha ar man . mockito _ kotlin . mock Ċ import Ġfre emark er . ext . beans . String Model Ċ import Ġfre emark er . template . Simple Hash Ċ import Ġfre emark er . template . Simple Sequence Ċ import Ġfre emark er . template . Template Boolean Model Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . junit . Test Ċ import Ġorg . pac 4 j . core . profile . Common Profile Ċ import Ġorg . v accine impact . order ly web . Action Context Ċ import Ġorg . v accine impact . order ly web . Serializer Ċ import Ġorg . v accine impact . order ly web . app _ start . Template Object Wrapper Ċ import Ġorg . v accine impact . order ly web . controllers . web . Serial ise Ċ import Ġorg . v accine impact . order ly web . models .* Ċ import Ġorg . v accine impact . order ly web . view models . Documents ViewModel Ċ import Ġorg . v accine impact . order ly web . view models . Index ViewModel Ċ import Ġjava . time . Instant Ċ Ċ class ĠTemplate Object Wrapper Tests Ċ { ĊĠĠĠ Ġclass ĠTest Class (@ Serial ise (" report Json ") Ġval Ġreport : ĠReport ) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` can Ġwrap Ġcomplex Ġproperties `() ĊĠĠĠ Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġnow Ġ= ĠInstant . now () ĊĠĠĠĠĠĠĠ Ġval Ġart Files Ġ= ĠlistOf ( FileInfo (" graph . png ", Ġ 1 2 3 4 )) ĊĠĠĠĠĠĠĠ Ġval Ġreport Ġ= ĠReport Version With Ar te facts Data Desc Params Resources ( Report Version With Desc Latest Elapsed (" r 1 ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" first Ġreport ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" v 1 ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġtrue , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġnow , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" v 1 ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" a Ġfake Ġreport ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 1 . 5 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" git Branch ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" abc 1 2 3 "), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠlistOf ( Ar te fact ( Ar te fact Format . DATA , Ġ" a Ġgraph ", Ġart Files )), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠlistOf (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠlistOf ( Data Info (" hash ", Ġ 1 2 3 4 , Ġ 2 3 4 5 )), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmap Of (" param " Ġto Ġ" value "), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmap Of (" p 1 " Ġto Ġ" v 1 ", Ġ" p 2 " Ġto Ġ" v 2 ")) ĊĊĠĠĠĠĠĠĠ Ġval Ġsut Ġ= ĠTemplate Object Wrapper () ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġsut . wrap ( report ) Ġas ĠSimple Hash ĊĊĠĠĠĠĠĠĠ ĠassertThat ( result [" name "]. toString ()). isEqualTo (" r 1 ") ĊĠĠĠĠĠĠĠ ĠassertThat ( result [" id "]. toString ()). isEqualTo (" v 1 ") ĊĠĠĠĠĠĠĠ ĠassertThat (( result [" published "] Ġas ĠTemplate Boolean Model ). as Boolean ). isEqualTo ( true ) ĊĠĠĠĠĠĠĠ ĠassertThat (( result [" date "]). toString ()). isEqualTo ( now . toString ()) ĊĊĠĠĠĠĠĠĠ Ġval Ġwrapped Ar te facts Ġ= Ġresult [" art ef acts "] Ġas ĠSimple Sequence ĊĊĠĠĠĠĠĠĠ Ġval Ġwrapped Ar te fact Ġ= Ġwrapped Ar te facts [ 0 ] Ġas ĠString Model ĊĠĠĠĠĠĠĠ ĠassertThat ( wrapped Ar te fact [" format "]. toString ()). isEqualTo (" data ") ĊĠĠĠĠĠĠĠ ĠassertThat ( wrapped Ar te fact [" description "]. toString ()). isEqualTo (" a Ġgraph ") ĊĊĠĠĠĠĠĠĠ Ġval Ġfiles Ġ= Ġwrapped Ar te fact [" files "] Ġas ĠSimple Sequence ĊĠĠĠĠĠĠĠ Ġval Ġfile Model Ġ= Ġfiles [ 0 ] Ġas ĠString Model ĊĠĠĠĠĠĠĠ ĠassertThat ( file Model [" name "]. toString ()). isEqualTo (" graph . png ") ĊĠĠĠĠĠĠĠ ĠassertThat ( file Model [" size "]. toString ()). isEqualTo (" 1 2 3 4 ") ĊĊĠĠĠĠĠĠĠ Ġval Ġdata Ġ= Ġresult [" data Info "] Ġas ĠSimple Sequence ĊĠĠĠĠĠĠĠ Ġval Ġdata Model Ġ= Ġdata [ 0 ] Ġas ĠString Model ĊĠĠĠĠĠĠĠ ĠassertThat ( data Model [" name "]. toString ()). isEqualTo (" hash ") ĊĠĠĠĠĠĠĠ ĠassertThat ( data Model [" csv Size "]. toString ()). isEqualTo (" 1 2 3 4 ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` adds Ġextra Ġfield Ġwhen Ġmarked Ġwith Ġthe Ġserial ise Ġattribute `() ĊĠĠĠ Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġreport Ġ= ĠReport (" some Ġreport ", Ġ" display Ġname ", Ġ" v 1 ") ĊĠĠĠĠĠĠĠ Ġval Ġmodel Ġ= ĠTest Class ( report ) ĊĠĠĠĠĠĠĠ Ġval Ġsut Ġ= ĠTemplate Object Wrapper () ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġsut . wrap ( model ) Ġas ĠSimple Hash ĊĊĠĠĠĠĠĠĠ ĠassertThat ( result [" report Json "]. toString ()) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. isEqualTo ( Serializer . instance . gson . toJson ( report )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` includes Ġall Ġdeclared Ġand Ġinherited Ġproperties Ġof Ġview Ġmodel `() ĊĠĠĠ Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġmock Context Ġ= Ġmock < Action Context > Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon Ġ{ Ġit . user Profile Ġ} Ġdo Return ĠCommon Profile (). apply Ġ{ Ġid Ġ= Ġ" user . name " Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon Ġ{ Ġhas Permission ( any ()) Ġ} Ġdo Return Ġtrue ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġval Ġmodel Ġ= ĠIndex ViewModel ( mock Context , ĠlistOf (), ĠlistOf (), ĠlistOf (), ĠlistOf (), Ġtrue , Ġfalse , Ġnull , Ġfalse ) ĊĊĠĠĠĠĠĠĠ Ġval Ġsut Ġ= ĠTemplate Object Wrapper () ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġsut . wrap ( model ) Ġas ĠSimple Hash ĊĠĠĠĠĠĠĠ ĠassertThat ( result [" appName "]. toString ()). isEqualTo (" Reporting Ġportal ") ĊĠĠĠĠĠĠĠ ĠassertThat ( result [" auth Provider "]. toString ()). isEqualTo (" Mont ag u ") ĊĠĠĠĠĠĠĠ ĠassertThat ( result [" app Email "]. toString ()). isEqualTo (" mont ag u - help @ imp erial . ac . uk ") ĊĠĠĠĠĠĠĠ ĠassertThat ( result [" user "]. toString ()). isEqualTo (" user . name ") ĊĠĠĠĠĠĠĠ ĠassertThat (( result [" logged In "] Ġas ĠTemplate Boolean Model ). as Boolean ). isEqualTo ( true ) ĊĠĠĠĠĠĠĠ ĠassertThat (( result [" is Reviewer "] Ġas ĠTemplate Boolean Model ). as Boolean ). isEqualTo ( true ) ĊĠĠĠĠĠĠĠ ĠassertThat (( result [" isAdmin "] Ġas ĠTemplate Boolean Model ). as Boolean ). isEqualTo ( true ) ĊĠĠĠĠĠĠĠ ĠassertThat (( result [" fine Gr ained Auth "] Ġas ĠTemplate Boolean Model ). as Boolean ). isEqualTo ( true ) ĊĠĠĠĠĠĠĠ ĠassertThat (( result [" reports "] )). isNotNull () ĊĠĠĠĠĠĠĠ ĠassertThat (( result [" pinned Reports "] )). isNotNull () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` wrap s ĠDocuments ViewModel Ġcorrectly `() ĊĠĠĠ Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġmock Context Ġ= Ġmock < Action Context > Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon Ġ{ Ġit . user Profile Ġ} Ġdo Return ĠCommon Profile (). apply Ġ{ Ġid Ġ= Ġ" user . name " Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon Ġ{ Ġhas Permission ( any ()) Ġ} Ġdo Return Ġtrue ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġval Ġmodel Ġ= ĠDocuments ViewModel . build ( mock Context , ĠlistOf ( Document (" name ", Ġ" display Ġname ", Ġ" path ", Ġtrue , Ġfalse , ĠlistOf ()))) ĊĊĠĠĠĠĠĠĠ Ġval Ġsut Ġ= ĠTemplate Object Wrapper () ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġsut . wrap ( model ) Ġas ĠSimple Hash ĊĠĠĠĠĠĠĠ Ġval Ġdoc Ġ= Ġ(( result [" docs "] Ġas ĠSimple Sequence )[ 0 ] Ġas ĠString Model ) ĊĠĠĠĠĠĠĠ ĠassertThat (( doc [" file "] Ġas ĠTemplate Boolean Model ). as Boolean ). isEqualTo ( true ) ĊĠĠĠ Ġ} Ċ } Ċ