package Ġcom . bright space . ks ire n Ċ Ċ import Ġcom . squareup . mos hi . Json EncodingException Ċ import Ġorg . junit . Test Ċ import Ġkotlin . test . assertEquals Ċ import Ġkotlin . test . assertTrue Ċ Ċ /** Ċ Ġ* ĠCopyright Ġ 2 0 1 7 ĠD 2 L ĠCorporation Ċ Ġ* Ċ Ġ* ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ Ġ* Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ Ġ* Ċ Ġ* Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* Ċ Ġ* ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ Ġ* Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ Ġ* ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ Ġ* ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ Ġ* Ġlimitations Ġunder Ġthe ĠLicense . Ċ Ġ*/ Ċ class ĠField Test Ġ{ ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġexpect Field () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfield : ĠField Ġ= ĠField . fromJson (""" { Ġ" class ":[" class 1 ", Ġ" class 2 "], Ġ" name ": Ġ" order Number ", Ġ" type ": Ġ" hidden ", Ġ" value ": Ġ" 4 2 " Ġ} """. to KS ire n Json Reader ()) ĊĠĠĠĠĠĠĠ ĠassertEquals (" order Number ", Ġfield . name ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" hidden ", Ġfield . type ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" 4 2 ", Ġfield . value ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( field . classes . contains (" class 1 ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( field . classes . contains (" class 2 ")) ĊĠĠĠ Ġ} ĊĊ ĉ @ Test Ċ ĉ fun Ġexpect FieldValue Array () Ġ{ Ċĉ ĉ val Ġfield : ĠField Ġ= ĠField . fromJson (""" { Ġ" class ":[" class 1 ", Ġ" class 2 "], Ġ" name ": Ġ" order Number ", Ġ" type ": Ġ" hidden ", Ġ" value ": Ġ"[ 4 2 ]" Ġ} """. to KS ire n Json Reader ()) Ċĉ ĉ assertEquals (" order Number ", Ġfield . name ) Ċĉ ĉ assertEquals (" hidden ", Ġfield . type ) Ċĉ ĉ assertEquals ("[ 4 2 ]", Ġfield . value ) Ċĉ ĉ assertTrue ( field . classes . contains (" class 1 ")) Ċĉ ĉ assertTrue ( field . classes . contains (" class 2 ")) Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun Ġboolean Parse Test () Ġ{ Ċĉ ĉ val Ġfield : ĠField Ġ= ĠField . fromJson (""" { Ġ" name ": Ġ" express Shipping ", Ġ" type ": Ġ" checkbox ", Ġ" value ": Ġfalse Ġ} """. to KS ire n Json Reader ()) Ċĉ ĉ assertEquals (" express Shipping ", Ġfield . name ) Ċĉ ĉ assertEquals (" checkbox ", Ġfield . type ) Ċĉ ĉ assertEquals (" false ", Ġfield . value ) Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun Ġnull Parse Test () Ġ{ Ċĉ ĉ val Ġfield : ĠField Ġ= ĠField . fromJson (""" { Ġ" name ": Ġ" express Shipping ", Ġ" type ": Ġ" checkbox ", Ġ" value ": Ġnull Ġ} """. to KS ire n Json Reader ()) Ċĉ ĉ assertEquals (" express Shipping ", Ġfield . name ) Ċĉ ĉ assertEquals (" checkbox ", Ġfield . type ) Ċĉ ĉ assertEquals ( null , Ġfield . value ) Ċ ĉ } ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġexpect Json Exception () Ġ{ ĊĠĠĠĠĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠField . fromJson (""" { Ġ" name ": Ġ" order Number " Ġ" type ": Ġ" hidden ", Ġ" value ": Ġ" 4 2 " Ġ} """. to KS ire n Json Reader ()) ĊĠĠĠĠĠĠĠ Ġ} Ġcatch Ġ( ex : ĠJson EncodingException ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġassert ( true ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ