package Ġorg . http 4 k . core Ċ Ċ import Ġcom . nat pr y ce . ham k rest . abs ent Ċ import Ġcom . nat pr y ce . ham k rest . assertion . assertThat Ċ import Ġcom . nat pr y ce . ham k rest . equalTo Ċ import Ġorg . junit . jupiter . api . Test Ċ Ċ class ĠParameters Test Ġ{ ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġextract _ query _ parameters () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertThat (" foo = one & bar = two ". to Parameters (). find Single (" foo ") !! , ĠequalTo (" one ")) ĊĠĠĠĠĠĠĠ ĠassertThat (" foo =& bar = two ". to Parameters (). find Single (" foo ") !! , ĠequalTo ("")) ĊĠĠĠĠĠĠĠ ĠassertThat (" foo & bar = two ". to Parameters (). find Single (" foo "), Ġabsent ()) ĊĠĠĠĠĠĠĠ ĠassertThat (" foo & bar = two ". to Parameters (). find Single (" not there "), Ġabsent ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġquery _ parameters _ are _ decoded () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertThat (" foo = one + two & bar = three ". to Parameters (). find Single (" foo ") !! , ĠequalTo (" one Ġtwo ")) ĊĠĠĠĠĠĠĠ ĠassertThat (" foo = one & super % 2 F bar = two ". to Parameters (). find Single (" super / bar ") !! , ĠequalTo (" two ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġround _ trip () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertThat (" a = 1 & b & c + d = three + four & a = 2 ". to Parameters (). to Url Form Encoded (), ĠequalTo (" a = 1 & b & c + d = three + four & a = 2 ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` can Ġconvert Ġparameters Ġto Ġmap `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġmap : ĠMap < String , ĠList < String ? >> Ġ= ĠlistOf (" a " Ġto Ġ" A ", Ġ" b " Ġto Ġ" B ", Ġ" a " Ġto Ġnull ). to Parameters Map () ĊĊĠĠĠĠĠĠĠ ĠassertThat ( map [" a "], ĠequalTo ( listOf (" A ", Ġnull ))) ĊĠĠĠĠĠĠĠ ĠassertThat ( map [" b "], ĠequalTo ( listOf (" B "))) ĊĠĠĠĠĠĠĠ ĠassertThat ( map [" c "], Ġabsent ()) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( map . getFirst (" a "), ĠequalTo (" A ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( map . getFirst (" b "), ĠequalTo (" B ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( map . getFirst (" c "), Ġabsent ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġsplit Ġquery Ġparam Ġonly Ġinto Ġ 2 Ġstrings `() Ġ{ ĊĠĠĠĠĠĠĠ ĠassertThat (" q 1 = value 1 = 1 0 & q 2 = value 2 = 1 0 ". to Parameters (), ĠequalTo ( listOf (" q 1 " Ġto Ġ" value 1 = 1 0 ", Ġ" q 2 " Ġto Ġ" value 2 = 1 0 "))) ĊĠĠĠ Ġ} Ċ } Ċ