package Ġde . rie ck pil . learning Ċ Ċ import Ġorg . hamcrest . Matchers .` is ` Ċ import Ġorg . junit . jupiter . api . Assertions . assertEquals Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . mockito . Mockito .` when ` Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . boot . test . autoconfigure . web . servlet . Web Mvc Test Ċ import Ġorg . springframework . boot . test . mock . mockito . Mock Bean Ċ import Ġorg . springframework . test . web . servlet . MockMvc Ċ import Ġorg . springframework . test . web . servlet . request . MockMvc Request Builders . get Ċ import Ġorg . springframework . test . web . servlet . result . MockMvc Result Matchers . json Path Ċ import Ġjava . time . LocalDate Ċ import Ġjava . util .* Ċ import Ġorg . springframework . test . web . servlet . result . MockMvc Result Handlers . print Ċ Ċ @ Web Mvc Test ( Main Controller :: class ) Ċ class ĠMain Controller Test Ġ{ ĊĊĠ Ġ@ Autowired ĊĠ Ġlateinit Ġvar Ġmock Mvc : ĠMock Mvc ĊĊĠ Ġ@ Mock Bean ĊĠ Ġlateinit Ġvar Ġperson Provider : ĠPerson Provider ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Message () Ġ{ ĊĠĠĠ Ġthis . mock Mvc . perform ( get ("/ api ")). andExpect Ġ{ ĊĠĠĠĠĠ ĠassertEquals ( 2 0 0 , Ġit . response . status ) ĊĠĠĠĠĠ ĠassertEquals (" Hello ĠWorld !", Ġit . response . content AsString ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun ĠtestData () Ġ{ ĊĠĠĠ Ġ` when `( person Provider . get Pers ons ()). thenReturn ( listOf ( ĊĠĠĠĠĠ ĠPerson (" Du ke ", ĠLocalDate . MIN , ĠUUID . randomUUID ()), ĊĠĠĠĠĠ ĠPerson (" Mi ke ", ĠLocalDate . MAX , ĠUUID . randomUUID ()))) ĊĊĠĠĠ Ġthis . mock Mvc . perform ( get ("/ data ")). andExpect Ġ{ ĊĠĠĠĠĠ ĠassertEquals ( 2 0 0 , Ġit . response . status ) ĊĠĠĠĠĠ Ġjson Path (" $. size ", Ġ` is `( 2 )) ĊĠĠĠ Ġ}. and Do ( print ()) ĊĠ Ġ} Ċ Ċ } Ċ