package Ġcom . will mad ison . battle ship . controllers Ċ Ċ import Ġjunit . framework . TestCase . assertNotNull Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . boot . test . context . SpringBootTest Ċ import Ġorg . springframework . test . context . Active Profiles Ċ import Ġorg . springframework . test . context . junit 4 . Spring Runner Ċ import Ġorg . springframework . test . web . servlet . MockMvc Ċ import Ġorg . springframework . test . web . servlet . request . MockMvc Request Builders . post Ċ import Ġorg . springframework . test . web . servlet . result . MockMvc Result Matchers . status Ċ import Ġorg . springframework . test . web . servlet . setup . MockMvc Builders Ċ import Ġorg . springframework . web . context . Web ApplicationContext Ċ Ċ @ RunWith ( Spring Runner :: class ) Ċ @ Active Profiles ( profiles Ġ= ĠarrayOf (" test ")) Ċ @ SpringBootTest Ċ class ĠBattle ship Controller Test Ġ{ ĊĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġlateinit Ġprivate Ġvar Ġctx : ĠWeb ApplicationContext ĊĊĠĠĠ Ġlateinit Ġprivate Ġvar Ġm vc : ĠMock Mvc ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġm vc Ġ= ĠMock Mvc Builders . web AppContext Setup ( ctx ). build () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcreate Board () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġm vc . perform ( post ("/ battle ship / boards "). param (" width ", Ġ" 4 ")) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. andExpect ( status (). is Created ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. andReturn () ĊĊĠĠĠĠĠĠĠ ĠassertNotNull ( result . response . content AsString ) ĊĠĠĠ Ġ} Ċ }