package Ġcom . w es ley f uch ter . tod olist Ċ Ċ import Ġjunit . framework . Assert . assertEquals Ċ import Ġjunit . framework . Assert . assertNotNull Ċ 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 . boot . test . web . client . Test Rest Template Ċ import Ġorg . springframework . boot . test . web . client . post For Entity Ċ import Ġorg . springframework . http . HttpStatus Ċ import Ġorg . springframework . test . context . junit 4 . Spring Runner Ċ Ċ @ RunWith ( Spring Runner :: class ) Ċ @ SpringBootTest ( web Environment Ġ= ĠSpring Boot Test . Web Environment . RANDOM _ PORT ) Ċ class ĠTask Controller IntegrationTest Ġ{ ĊĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġtemplate : ĠTest Rest Template ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġshould Ġreturn Ġthe Ġlist Ġof Ġtasks `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġtemplate . get For Entity ("/ tasks ", ĠArrayList :: class . java ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( result ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( result . statusCode , ĠHttpStatus . OK ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( listOf ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmap Of ( Pair (" description ", Ġ" Task Ġ 1 "), ĠPair (" done ", Ġfalse )), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmap Of ( Pair (" description ", Ġ" Task Ġ 2 "), ĠPair (" done ", Ġtrue )) ĊĠĠĠĠĠĠĠ Ġ), Ġresult . body ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġshould Ġpersist Ġa Ġtask Ġand Ġreturn Ġthe Ġsame Ġcontent `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġtemplate . post For Entity < Map < String , ĠAny >> ("/ tasks ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmap Of ( Pair (" description ", Ġ" Task Ġ 3 "), ĠPair (" done ", Ġfalse ))) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( result ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( result . statusCode , ĠHttpStatus . OK ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( map Of ( Pair (" description ", Ġ" Task Ġ 3 "), ĠPair (" done ", Ġfalse )), Ġresult . body ) ĊĠĠĠ Ġ} Ċ Ċ } Ċ