2 * Copyright 2014 Gustavo Martin Morcuende
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package name.gumartinm.weather.information.test;
18 import name.gumartinm.weather.information.parser.JPOSWeatherParser;
20 import junit.framework.TestCase;
22 import org.json.JSONException;
24 public class JPOSWeatherParserTest extends TestCase {
25 private JPOSWeatherParser jposWeatherParser;
28 protected void setUp() throws Exception {
31 this.jposWeatherParser = new JPOSWeatherParser();
34 public void testRetrieveWeatherFromJPOS() throws JSONException {
36 final String jsonData = "{\"coord\":{\"lon\":139,\"lat\":35}}";
37 final double longitude = 139;
38 final double latitude = 35;
39 final WeatherData.Coord coord = new WeatherData.Coord(longitude, latitude);
40 final WeatherData expectedWeather = new WeatherData.Builder().setCoord(coord).build();
43 final WeatherData finalWeather = this.jposWeatherParser.retrieveWeatherFromJPOS(jsonData);
46 assertEquals(expectedWeather.toString(), finalWeather.toString());