Ċ Ċ package Ġorg . springframework . web . servlet . mvc . method . annotation Ċ Ċ import Ġorg . junit . Assert .* Ċ import Ġorg . junit . Test Ċ import Ġorg . springframework . mock . web . test . Mock HttpServletRequest Ċ import Ġorg . springframework . mock . web . test . Mock HttpServletResponse Ċ import Ġorg . springframework . web . bind . annotation . RequestMapping Ċ import Ġorg . springframework . web . bind . annotation . RestController ĊĊ Ċ class ĠServlet Annotation Controller Handler Method Kotlin Tests Ġ: ĠAbstract Servlet Handler Method Tests () Ġ{ ĊĊ ĉ @ Test Ċ ĉ fun Ġdata Class Binding () Ġ{ Ċĉ ĉ init Servlet With Controllers ( Data Class Controller :: class . java ) ĊĊĉ ĉ val Ġrequest Ġ= ĠMock HttpServletRequest (" GET ", Ġ"/ bind ") Ċĉ ĉ request . add Parameter (" param 1 ", Ġ" value 1 ") Ċĉ ĉ request . add Parameter (" param 2 ", Ġ" 2 ") Ċĉ ĉ val Ġresponse Ġ= ĠMock HttpServletResponse () Ċĉ ĉ servlet . service ( request , Ġresponse ) Ċĉ ĉ assertEquals (" value 1 - 2 ", Ġresponse . content AsString ) Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun Ġdata Class Binding With Optional Parameter And All Parameters () Ġ{ Ċĉ ĉ init Servlet With Controllers ( Data Class Controller :: class . java ) ĊĊĉ ĉ val Ġrequest Ġ= ĠMock HttpServletRequest (" GET ", Ġ"/ bind - optional - parameter ") Ċĉ ĉ request . add Parameter (" param 1 ", Ġ" value 1 ") Ċĉ ĉ request . add Parameter (" param 2 ", Ġ" 2 ") Ċĉ ĉ val Ġresponse Ġ= ĠMock HttpServletResponse () Ċĉ ĉ servlet . service ( request , Ġresponse ) Ċĉ ĉ assertEquals (" value 1 - 2 ", Ġresponse . content AsString ) Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun Ġdata Class Binding With Optional Parameter And Only Missing Parameters () Ġ{ Ċĉ ĉ init Servlet With Controllers ( Data Class Controller :: class . java ) ĊĊĉ ĉ val Ġrequest Ġ= ĠMock HttpServletRequest (" GET ", Ġ"/ bind - optional - parameter ") Ċĉ ĉ request . add Parameter (" param 1 ", Ġ" value 1 ") Ċĉ ĉ val Ġresponse Ġ= ĠMock HttpServletResponse () Ċĉ ĉ servlet . service ( request , Ġresponse ) Ċĉ ĉ assertEquals (" value 1 - 1 2 ", Ġresponse . content AsString ) Ċ ĉ } ĊĊĊ ĉ data Ġclass ĠData Class ( val Ġparam 1 : ĠString , Ġval Ġparam 2 : ĠInt ) ĊĊ ĉ data Ġclass ĠData Class With Optional Parameter ( val Ġparam 1 : ĠString , Ġval Ġparam 2 : ĠInt Ġ= Ġ 1 2 ) ĊĊ ĉ @ RestController Ċ ĉ class ĠData Class Controller Ġ{ ĊĊĉ ĉ @ RequestMapping ("/ bind ") Ċĉ ĉ fun Ġhandle ( data : ĠData Class ) Ġ= Ġ"${ data . param 1 }-${ data . param 2 }" ĊĊĉ ĉ @ RequestMapping ("/ bind - optional - parameter ") Ċĉ ĉ fun Ġhandle ( data : ĠData Class With Optional Parameter ) Ġ= Ġ"${ data . param 1 }-${ data . param 2 }" Ċ ĉ } Ċ Ċ } Ċ