@Test public void weatherForecast() throws Exception { WeatherForecast forecast = new WeatherForecast(); forecast.setName("Brussels"); forecast.getEntries().add(createWeatherEntry(285.45, 600, "02d", Instant.ofEpochSecond(1234))); forecast.getEntries().add(createWeatherEntry(294.45, 800, "01d", Instant.ofEpochSecond(5678))); given(this.weatherService.getWeatherForecast("be", "brussels")).willReturn(forecast); this.mvc.perform(get("/api/weather/weekly/be/brussels")) .andExpect(status().isOk()) .andExpect(jsonPath("$.name", is("Brussels"))) .andExpect(jsonPath("$.entries[0].temperature", is(285.45))) .andExpect(jsonPath("$.entries[1].temperature", is(294.45))); verify(this.weatherService).getWeatherForecast("be", "brussels"); }
@RequestMapping("/weekly/{country}/{city}") public WeatherForecast getWeatherForecast(@PathVariable String country, @PathVariable String city) { return this.weatherService.getWeatherForecast(country, city); }
WeatherApiController { @RequestMapping("/weekly/{country}/{city}") public WeatherForecast getWeatherForecast(@PathVariable String country, @PathVariable String city) { return this.weatherService.getWeatherForecast(country, city); } }
WeatherApiController { @RequestMapping("/weekly/{country}/{city}") public WeatherForecast getWeatherForecast(@PathVariable String country, @PathVariable String city) { return this.weatherService.getWeatherForecast(country, city); } WeatherApiController(WeatherService weatherService); }
WeatherApiController { @RequestMapping("/weekly/{country}/{city}") public WeatherForecast getWeatherForecast(@PathVariable String country, @PathVariable String city) { return this.weatherService.getWeatherForecast(country, city); } WeatherApiController(WeatherService weatherService); @RequestMapping("/now/{country}/{city}") Weather getWeather(@PathVariable String country,
			@PathVariable String city); @RequestMapping("/weekly/{country}/{city}") WeatherForecast getWeatherForecast(@PathVariable String country,
			@PathVariable String city); }
WeatherApiController { @RequestMapping("/weekly/{country}/{city}") public WeatherForecast getWeatherForecast(@PathVariable String country, @PathVariable String city) { return this.weatherService.getWeatherForecast(country, city); } WeatherApiController(WeatherService weatherService); @RequestMapping("/now/{country}/{city}") Weather getWeather(@PathVariable String country,
			@PathVariable String city); @RequestMapping("/weekly/{country}/{city}") WeatherForecast getWeatherForecast(@PathVariable String country,
			@PathVariable String city);  }