package Ġmicro service . workshop . movie ag gregator servic ert . http Ċ Ċ import Ġorg . hamcrest . Matchers .` is ` Ċ import Ġorg . hamcrest . Matchers . has Size Ċ import Ġorg . junit . jupiter . api . BeforeEach Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . junit . jupiter . api . extension . Extend With Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . boot . test . context . SpringBootTest Ċ import Ġorg . springframework . http . HttpStatus Ċ import Ġorg . springframework . http . MediaType Ċ import Ġorg . springframework . test . context . junit . jupiter . Spring Extension Ċ 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 .* Ċ import Ġorg . springframework . test . web . servlet . setup . MockMvc Builders . web AppContext Setup Ċ import Ġorg . springframework . web . context . Web ApplicationContext Ċ Ċ @ Extend With ( Spring Extension :: class ) Ċ @ SpringBootTest Ċ class ĠAggregate Movie Controller Test Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmock Mvc : ĠMock Mvc ĊĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġweb ApplicationContext : ĠWeb ApplicationContext ĊĊĠĠĠ Ġ@ BeforeEach ĊĠĠĠ Ġfun Ġsetup () Ġ{ ĊĠĠĠĠĠĠĠ Ġthis . mock Mvc Ġ= Ġweb AppContext Setup ( web ApplicationContext ). build () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġfun Ġtest Exists () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Mvc . perform ( get ("/ movie / 1 ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. andExpect ( status (). ` is `( HttpStatus . OK . value ())) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. andExpect ( content (). contentType ( MediaType . APPLICATION _ JSON )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. andExpect ( json Path (" $. title ", Ġ` is ` (" The ĠGod father "))) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. andExpect ( json Path (" $. aw ards ", Ġhas Size < Any >( 3 ))) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. andExpect ( json Path (" $. cast Members ", Ġhas Size < Any >( 6 ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġfun Ġtest Not Exists () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Mvc . perform ( get ("/ movie / 2 1 ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. andExpect ( status (). ` is `( HttpStatus . NOT _ FOUND . value ())) ĊĠĠĠ Ġ} Ċ }