1 package de.example.exampletdd.test;
3 import junit.framework.TestCase;
5 import org.json.JSONException;
7 import de.example.exampletdd.model.WeatherData;
8 import de.example.exampletdd.parser.JPOSWeatherParser;
10 public class JPOSWeatherParserTest extends TestCase {
11 private JPOSWeatherParser jposWeatherParser;
14 protected void setUp() throws Exception {
17 this.jposWeatherParser = new JPOSWeatherParser();
20 public void testRetrieveWeatherFromJPOS() throws JSONException {
22 final String jsonData = "{\"coord\":{\"lon\":139,\"lat\":35}}";
23 final double longitude = 139;
24 final double latitude = 35;
25 final WeatherData.Coord coord = new WeatherData.Coord(longitude, latitude);
26 final WeatherData expectedWeather = new WeatherData.Builder().setCoord(coord).build();
29 final WeatherData finalWeather = this.jposWeatherParser.retrieveWeatherFromJPOS(jsonData);
32 assertEquals(expectedWeather.toString(), finalWeather.toString());