import Ġcom . fasterxml . jackson . databind . Serialization Feature Ċ import Ġcom . fasterxml . jackson . datatype . js r 3 1 0 . Java Time Module Ċ import Ġcom . fasterxml . jackson . module . kotlin . jackson ObjectMapper Ċ import Ġio . hol unda . camunda . variable . serializer . serialize Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . camunda . bpm . engine . variable . Variables Ċ import Ġorg . junit . Test Ċ import Ġjava . text . SimpleDateFormat Ċ import Ġjava . time . Instant Ċ import Ġjava . time . Offset DateTime Ċ import Ġjava . time . Zone Offset Ċ Ċ class ĠSimple Data Entry Command Sender Test Ġ{ ĊĊĠ Ġprivate Ġval Ġmapper Ġ= Ġj ack son ObjectMapper () ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` should Ġreturn Ġthe Ġvariables Ġmap `() Ġ{ ĊĊĠĠĠ Ġval Ġmap Ġ= ĠVariables ĊĠĠĠĠĠ Ġ. create Variables () ĊĠĠĠĠĠ Ġ. put Value (" key ", Ġ" value ") ĊĠĠĠĠĠ Ġ. put Value (" another - key ", Ġ 4 7 1 1 ) ĊĊĠĠĠ Ġval Ġresult Ġ= Ġserialize ( map , Ġmapper ) ĊĊĠĠĠ ĠassertThat ( result ). isEqualTo ( map ) ĊĠĠĠ Ġmap . forEach Ġ{ ĊĠĠĠĠĠ ĠassertThat ( result ). containsKey ( it . key ) ĊĠĠĠĠĠ ĠassertThat ( result [ it . key ]). isEqualTo ( it . value ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` should Ġtransform Ġsimple Ġpo jo Ġto Ġmap `() Ġ{ ĊĊĠĠĠ Ġval Ġpo jo Ġ= ĠPo jo 3 ( key Ġ= Ġ" value ", Ġanother Key Ġ= Ġ 4 7 1 1 ) ĊĊĠĠĠ Ġval Ġresult Ġ= Ġserialize ( pojo , Ġmapper ) ĊĊĠĠĠ ĠassertThat ( result [ Po jo 3 :: key . name ]). isEqualTo ( pojo . key ) ĊĠĠĠ ĠassertThat ( result [ Po jo 3 :: another Key . name ]). isEqualTo ( pojo . another Key ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` should Ġtransform Ġpo jo Ġwith Ġinstant Ġto Ġmap `() Ġ{ ĊĊĠĠĠ Ġmapper . date Format Ġ= ĠSimpleDateFormat (" yyyy - MM - dd ' T ' HH : mm ' Z '") ĊĠĠĠ Ġmapper . register Module ( Java Time Module ()) ĊĠĠĠ Ġmapper . configure ( Serialization Feature . WRITE _ DAT ES _ AS _ TIMESTAMP S , Ġfalse ) ĊĠĠĠ Ġmapper . configure ( Serialization Feature . WRITE _ DATE _ TIMESTAMP S _ AS _ NAN O SECONDS , Ġfalse ) ĊĊĠĠĠ Ġval Ġnow Ġ= ĠInstant . parse (" 2 0 2 0 - 1 0 - 1 5 T 0 7 : 2 0 : 0 5 . 8 7 1 6 4 1 Z ") ĊĠĠĠ Ġval Ġpo jo Ġ= ĠPo jo 5 ( key Ġ= Ġ" value ", Ġts Ġ= Ġnow , Ġdate Ġ= Ġnow . at Offset ( Zone Offset . UTC )) ĊĠĠĠ Ġval Ġresult Ġ= Ġserialize ( pojo , Ġmapper ) ĊĊĠĠĠ ĠassertThat ( result [ Po jo 5 :: key . name ]). isEqualTo ( pojo . key ) ĊĠĠĠ ĠassertThat ( result [ Po jo 5 :: date . name ]). isEqualTo ("${ pojo . date }") Ġ// Ġdates Ġto Ġstrings ĊĠĠĠ ĠassertThat ( result [ Po jo 5 :: ts . name ]). isEqualTo ("${ pojo . ts }") Ġ// Ġinstant Ġto Ġstring ĊĠ Ġ} ĊĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` should Ġtransform Ġpo jo Ġwith Ġlists Ġto Ġmap `() Ġ{ ĊĊĠĠĠ Ġval Ġpo jo Ġ= ĠPo jo 4 ( key Ġ= Ġ" value ", Ġanother Key Ġ= ĠlistOf ( 4 7 1 1 , Ġ 4 7 1 2 )) ĊĊĠĠĠ Ġval Ġresult Ġ= Ġserialize ( pojo , Ġmapper ) ĊĊĠĠĠ ĠassertThat ( result [ Po jo 4 :: key . name ]). isEqualTo ( pojo . key ) ĊĠĠĠ ĠassertThat ( result [ Po jo 4 :: another Key . name ] Ġas ĠList < *> ). contains Exactly Elements Of ( pojo . another Key ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` should Ġtransform Ġcomplex Ġpo jo Ġto Ġmap Ġof Ġmaps `() Ġ{ ĊĊĠĠĠ Ġval Ġpo jo 2 1 Ġ= ĠPo jo 2 ( key ZU ZU Z Ġ= Ġ" pojo 2 ", Ġchildren Ġ= ĠlistOf ( Po jo 1 ( key Ġ= Ġ" value 1 ", Ġanother Key Ġ= ĠlistOf ()))) ĊĠĠĠ Ġval Ġpo jo 2 2 Ġ= ĠPo jo 2 ( key ZU ZU Z Ġ= Ġ" pojo 3 ", Ġchildren Ġ= ĠlistOf ( Po jo 1 ( key Ġ= Ġ" value 2 ", Ġanother Key Ġ= ĠlistOf ()))) ĊĊĠĠĠ Ġval Ġpo jo Ġ= ĠPo jo 1 ( key Ġ= Ġ" value ", Ġanother Key Ġ= ĠlistOf ( pojo 2 1 , Ġpo jo 2 2 )) ĊĊĠĠĠ Ġval Ġresult Ġ= Ġserialize ( pojo , Ġmapper ) ĊĊĠĠĠ ĠassertThat ( result [ Po jo 1 :: key . name ]). isEqualTo ( pojo . key ) ĊĊĠĠĠ Ġ@ Suppress (" UN CHECK ED _ CAST ") ĊĠĠĠ Ġval Ġchildren Ġ= Ġresult [ Po jo 1 :: another Key . name ] Ġas ĠList < Map < String , ĠAny >> ĊĠĠĠ ĠassertThat ( children . size ). isEqualTo ( 2 ) ĊĠĠĠ ĠassertThat ( children [ 0 ]). containsKey ( Po jo 2 :: key ZU ZU Z . name ) ĊĠĠĠ ĠassertThat ( children [ 0 ]). containsKey ( Po jo 2 :: children . name ) ĊĠĠĠ ĠassertThat ( children [ 1 ]). containsKey ( Po jo 2 :: key ZU ZU Z . name ) ĊĠĠĠ ĠassertThat ( children [ 1 ]). containsKey ( Po jo 2 :: children . name ) ĊĊĠĠĠ ĠassertThat ( children [ 0 ][ Po jo 2 :: key ZU ZU Z . name ]). isEqualTo ( pojo 2 1 . key ZU ZU Z ) ĊĠĠĠ ĠassertThat ( children [ 1 ][ Po jo 2 :: key ZU ZU Z . name ]). isEqualTo ( pojo 2 2 . key ZU ZU Z ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` should Ġtransform Ġvariable Ġmap Ġwith Ġcomplex Ġpo jos Ġto Ġmap Ġof Ġmaps `() Ġ{ ĊĠĠĠ Ġval Ġmap Ġ= ĠVariables ĊĠĠĠĠĠ Ġ. create Variables () ĊĠĠĠĠĠ Ġ. put Value (" key ", Ġ" value ") ĊĠĠĠĠĠ Ġ. put Value (" another - key ", ĠPo jo 1 ( key Ġ= Ġ" key ", Ġanother Key Ġ= ĠlistOf ( Po jo 2 ( key ZU ZU Z Ġ= Ġ" p 2 ", Ġchildren Ġ= ĠlistOf ())) )) ĊĊĠĠĠ Ġval Ġresult Ġ= Ġserialize ( map , Ġmapper ) ĊĊĠĠĠ ĠassertThat ( result ). containsKey (" key ") ĊĠĠĠ ĠassertThat ( result ). containsKey (" another - key ") ĊĠĠĠ ĠassertThat ( result [" key "]). isEqualTo ( map [" key "]) ĊĊĠĠĠ Ġ@ Suppress (" UN CHECK ED _ CAST ") ĊĠĠĠ Ġval Ġexpected Po jo Map Ġ= Ġresult [" another - key "] Ġas ĠMap < String , ĠAny > ĊĠĠĠ ĠassertThat ( expected Po jo Map ). containsKey ( Po jo 1 :: key . name ) ĊĠĠĠ ĠassertThat ( expected Po jo Map ). containsKey ( Po jo 1 :: another Key . name ) ĊĊĠĠĠ ĠassertThat ( expected Po jo Map [ Po jo 1 :: key . name ]). isEqualTo (" key ") ĊĊĠĠĠ Ġ@ Suppress (" UN CHECK ED _ CAST ") ĊĠĠĠ Ġval Ġelements Ġ= Ġexpected Po jo Map [ Po jo 1 :: another Key . name ] Ġas ĠList < Map < String , ĠAny >> ĊĠĠĠ ĠassertThat ( elements ). contains Exactly ( linked Map Of ( Po jo 2 :: key ZU ZU Z . name Ġto Ġ" p 2 ", ĠPo jo 2 :: children . name Ġto ĠlistOf < String > ())) ĊĠ Ġ} Ċ } Ċ Ċ data Ġclass ĠPo jo 1 ( ĊĠ Ġval Ġkey : ĠString , ĊĠ Ġval Ġanother Key : ĠList < Po jo 2 > Ċ ) Ċ Ċ data Ġclass ĠPo jo 2 ( ĊĠ Ġval Ġkey ZU ZU Z : ĠString , ĊĠ Ġvar Ġchildren : ĠList < Po jo 1 > Ġ= ĠlistOf () Ċ ) Ċ Ċ data Ġclass ĠPo jo 3 ( ĊĠ Ġval Ġkey : ĠString , ĊĠ Ġval Ġanother Key : ĠInt Ċ ) Ċ Ċ data Ġclass ĠPo jo 4 ( ĊĠ Ġval Ġkey : ĠString , ĊĠ Ġval Ġanother Key : ĠList < Int > Ċ ) Ċ Ċ data Ġclass ĠPo jo 5 ( ĊĠ Ġval Ġkey : ĠString , ĊĠ Ġval Ġts : ĠInstant , ĊĠ Ġval Ġdate : ĠOffset DateTime Ċ ) Ċ