Implemented first part of Road Risk API.

This commit is contained in:
2022-05-02 01:19:19 +03:00
parent 8a1daa0fe2
commit 6c1a1642f1
21 changed files with 790 additions and 0 deletions
@@ -0,0 +1,67 @@
package com.github.prominence.openweathermap.api.mapper;
import com.github.prominence.openweathermap.api.model.roadrisk.RoadRiskRecord;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
class RoadRiskResponseMapperTest {
@Test
void mapToObjects() {
final String jsonResponse = """
[
{
"dt": 1602702000,
"coord": [
7.27,
44.04
],
"weather": {
"temp": 278.44,
"wind_speed": 2.27,
"wind_deg": 7,
"precipitation_intensity": 0.38,
"dew_point": 276.13
},
"road": {
"state": 2,
"temp": 293.85
},
"alerts": [
{
"sender_name": "METEO-FRANCE",
"event": "Moderate thunderstorm warning",
"event_level": 2
}
]
},
{
"dt": 1602702400,
"coord": [
7.37,
45.04
],
"weather": {
"temp": 282.44,
"wind_speed": 1.84,
"wind_deg": 316,
"dew_point": 275.99
},
"road": {
"state": 1,
"temp": 293.85
},
"alerts": [
]
}
]
""";
final List<RoadRiskRecord> roadRiskRecords = new RoadRiskResponseMapper().mapToObjects(jsonResponse);
assertNotNull(roadRiskRecords);
}
}