@Test @Transactional public void getAddressesByCountry() 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/country/AU")) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("$.[*].country").isArray()); mockAddressEndpoint.perform(get("/addresses/country/dummy")) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("$.[*].country").isEmpty()); }
@GetMapping(value = "/addresses/country/{country}") public List<Address> getAddressesByCountry(@PathVariable String country) { return addressRepository.findAllByCountry(country); }
AddressEndpoint { @GetMapping(value = "/addresses/country/{country}") public List<Address> getAddressesByCountry(@PathVariable String country) { return addressRepository.findAllByCountry(country); } }
AddressEndpoint { @GetMapping(value = "/addresses/country/{country}") public List<Address> getAddressesByCountry(@PathVariable String country) { return addressRepository.findAllByCountry(country); } AddressEndpoint(AddressRepository addressRepository); }
AddressEndpoint { @GetMapping(value = "/addresses/country/{country}") public List<Address> getAddressesByCountry(@PathVariable String country) { return addressRepository.findAllByCountry(country); } 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/country/{country}") public List<Address> getAddressesByCountry(@PathVariable String country) { return addressRepository.findAllByCountry(country); } 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);  }