From db3e22f4e5b95b63c9bfcd8e836babf6f9a981e5 Mon Sep 17 00:00:00 2001 From: Jaewon Lee Date: Wed, 18 Sep 2024 15:00:09 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20openweathermap=20api=20=EC=9A=94?= =?UTF-8?q?=EC=B2=AD=20=EC=8B=9C=20=EB=B0=98=ED=99=98=20dto=20=ED=95=84?= =?UTF-8?q?=EB=93=9C=EB=A5=BC=20camel=20case=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weather/openweathermap/OpenweathermapWeatherClient.java | 6 +++--- .../weather/openweathermap/OpenweathermapWeatherInfo.java | 5 ++++- .../openweathermap/OpenweathermapWeatherHttpClientTest.java | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/dnd/runus/infrastructure/weather/openweathermap/OpenweathermapWeatherClient.java b/src/main/java/com/dnd/runus/infrastructure/weather/openweathermap/OpenweathermapWeatherClient.java index fb59dc19..82e1081e 100644 --- a/src/main/java/com/dnd/runus/infrastructure/weather/openweathermap/OpenweathermapWeatherClient.java +++ b/src/main/java/com/dnd/runus/infrastructure/weather/openweathermap/OpenweathermapWeatherClient.java @@ -30,9 +30,9 @@ public WeatherInfo getWeatherInfo(double longitude, double latitude) { return new WeatherInfo( mapWeatherType(info.weather()[0].id()), - info.main().feels_like(), - info.main().temp_min(), - info.main().temp_max(), + info.main().feelsLike(), + info.main().tempMin(), + info.main().tempMax(), info.main().humidity(), info.wind().speed()); } diff --git a/src/main/java/com/dnd/runus/infrastructure/weather/openweathermap/OpenweathermapWeatherInfo.java b/src/main/java/com/dnd/runus/infrastructure/weather/openweathermap/OpenweathermapWeatherInfo.java index 059cc837..febd6f46 100644 --- a/src/main/java/com/dnd/runus/infrastructure/weather/openweathermap/OpenweathermapWeatherInfo.java +++ b/src/main/java/com/dnd/runus/infrastructure/weather/openweathermap/OpenweathermapWeatherInfo.java @@ -1,12 +1,15 @@ package com.dnd.runus.infrastructure.weather.openweathermap; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; @JsonIgnoreProperties(ignoreUnknown = true) public record OpenweathermapWeatherInfo(Weather[] weather, Main main, Wind wind) { record Weather(int id, String main, String description, String icon) {} - record Main(double temp, double feels_like, double temp_min, double temp_max, double pressure, double humidity) {} + @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) + record Main(double temp, double feelsLike, double tempMin, double tempMax, double pressure, double humidity) {} record Wind(double speed, double deg, double gust) {} } diff --git a/src/test/java/com/dnd/runus/infrastructure/weather/openweathermap/OpenweathermapWeatherHttpClientTest.java b/src/test/java/com/dnd/runus/infrastructure/weather/openweathermap/OpenweathermapWeatherHttpClientTest.java index b2f91869..d57a2629 100644 --- a/src/test/java/com/dnd/runus/infrastructure/weather/openweathermap/OpenweathermapWeatherHttpClientTest.java +++ b/src/test/java/com/dnd/runus/infrastructure/weather/openweathermap/OpenweathermapWeatherHttpClientTest.java @@ -93,7 +93,7 @@ void getWeatherInfo() { // then assertNotNull(weatherInfo); assertEquals(800, weatherInfo.weather()[0].id()); - assertEquals(10.0, weatherInfo.main().feels_like()); - assertEquals(10.0, weatherInfo.main().temp_min()); + assertEquals(10.0, weatherInfo.main().feelsLike()); + assertEquals(10.0, weatherInfo.main().tempMin()); } }