@Test @Transactional public void getAddressesLikeZip() throws Exception { mockAddressEndpoint.perform(get("/addresses/count")) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(content().string(ALL_ADDRESSES)); mockAddressEndpoint.perform(get("/addresses/like/8QE")) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("$.[*].zipcode").value("8QE")); mockAddressEndpoint.perform(get("/addresses/like/Q")) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("$.[*].zipcode").value("8QE")); mockAddressEndpoint.perform(get("/addresses/like/E")) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("$.[*].zipcode").isArray()); mockAddressEndpoint.perform(get("/addresses/like/dummy")) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("$.[*].zipcode").isEmpty()); }
@GetMapping(value = "/addresses/like/{zip}") public List<Address> getAddressesLikeZip(@PathVariable String zip) { return addressRepository.findAllLikeZip(zip); }
AddressEndpoint { @GetMapping(value = "/addresses/like/{zip}") public List<Address> getAddressesLikeZip(@PathVariable String zip) { return addressRepository.findAllLikeZip(zip); } }
AddressEndpoint { @GetMapping(value = "/addresses/like/{zip}") public List<Address> getAddressesLikeZip(@PathVariable String zip) { return addressRepository.findAllLikeZip(zip); } AddressEndpoint(AddressRepository addressRepository); }
AddressEndpoint { @GetMapping(value = "/addresses/like/{zip}") public List<Address> getAddressesLikeZip(@PathVariable String zip) { return addressRepository.findAllLikeZip(zip); } AddressEndpoint(AddressRepository addressRepository); @PostMapping("/addresses") Address createAddress(@RequestBody Address address); @GetMapping(value = "/addresses/count") Long countAll(); @GetMapping(value = "/addresses/country/{country}") List<Address> getAddressesByCountry(@PathVariable String country); @GetMapping(value = "/addresses/like/{zip}") List<Address> getAddressesLikeZip(@PathVariable String zip); }
AddressEndpoint { @GetMapping(value = "/addresses/like/{zip}") public List<Address> getAddressesLikeZip(@PathVariable String zip) { return addressRepository.findAllLikeZip(zip); } AddressEndpoint(AddressRepository addressRepository); @PostMapping("/addresses") Address createAddress(@RequestBody Address address); @GetMapping(value = "/addresses/count") Long countAll(); @GetMapping(value = "/addresses/country/{country}") List<Address> getAddressesByCountry(@PathVariable String country); @GetMapping(value = "/addresses/like/{zip}") List<Address> getAddressesLikeZip(@PathVariable String zip);  }