aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLuis Vidal <lvidal@cyngn.com>2016-04-16 13:16:41 -0700
committerLuis Vidal <lvidal@cyngn.com>2016-04-20 10:27:10 -0700
commitab3916fd2ac48b02f5ef4608dd1b65f1cc62e927 (patch)
tree1c2797433afd86006a3fd87346378bed82858591 /tests
parent02a71cc24e4917c765f3a5a7a6077c755ef70db1 (diff)
downloadvendor_cmsdk-ab3916fd2ac48b02f5ef4608dd1b65f1cc62e927.zip
vendor_cmsdk-ab3916fd2ac48b02f5ef4608dd1b65f1cc62e927.tar.gz
vendor_cmsdk-ab3916fd2ac48b02f5ef4608dd1b65f1cc62e927.tar.bz2
Add Weather API test coverage
Test coverage for: - DayForecast.Builder - ServiceRequestResult.Builder - WeatherInfo.Builder - WeatherLocation.Builder Change-Id: I66e716fa7a768b095e4b72011eda359b06a55f2e TICKET: CYNGNOS-2491
Diffstat (limited to 'tests')
-rw-r--r--tests/src/org/cyanogenmod/tests/weather/unit/DayForecastBuilderTest.java108
-rw-r--r--tests/src/org/cyanogenmod/tests/weather/unit/ServiceRequestResultBuilderTest.java96
-rw-r--r--tests/src/org/cyanogenmod/tests/weather/unit/WeatherInfoBuilderTest.java252
-rw-r--r--tests/src/org/cyanogenmod/tests/weather/unit/WeatherLocationBuilderTest.java129
4 files changed, 585 insertions, 0 deletions
diff --git a/tests/src/org/cyanogenmod/tests/weather/unit/DayForecastBuilderTest.java b/tests/src/org/cyanogenmod/tests/weather/unit/DayForecastBuilderTest.java
new file mode 100644
index 0000000..469b353
--- /dev/null
+++ b/tests/src/org/cyanogenmod/tests/weather/unit/DayForecastBuilderTest.java
@@ -0,0 +1,108 @@
+/**
+ * Copyright (C) 2016 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.cyanogenmod.tests.weather.unit;
+
+import android.os.Parcel;
+import android.test.AndroidTestCase;
+import android.test.suitebuilder.annotation.SmallTest;
+import cyanogenmod.providers.WeatherContract;
+import cyanogenmod.weather.WeatherInfo.DayForecast;
+
+public class DayForecastBuilderTest extends AndroidTestCase {
+
+ private static final int mConditionCode = WeatherContract.WeatherColumns.WeatherCode.HURRICANE;
+ private static final double mLow = 35;
+ private static final double mHigh = 58;
+
+ @SmallTest
+ public void testUnravelFromParcel() {
+ DayForecast forecast = new DayForecast.Builder(mConditionCode).setHigh(mHigh).setLow(mLow)
+ .build();
+
+ Parcel parcel = Parcel.obtain();
+ forecast.writeToParcel(parcel, 0);
+
+ parcel.setDataPosition(0);
+
+ DayForecast forecastFromParcel = DayForecast.CREATOR.createFromParcel(parcel);
+
+ assertEquals(forecast, forecastFromParcel);
+ assertEquals(forecast.getConditionCode(), forecastFromParcel.getConditionCode());
+ assertEquals(forecast.getHigh(), forecastFromParcel.getHigh());
+ assertEquals(forecast.getLow(), forecastFromParcel.getLow());
+ }
+
+ @SmallTest
+ public void testUnravelFromParcelWithDefaultValues() {
+ //Condition code is required
+ DayForecast forecast = new DayForecast.Builder(mConditionCode).build();
+
+ Parcel parcel = Parcel.obtain();
+ forecast.writeToParcel(parcel, 0);
+
+ parcel.setDataPosition(0);
+
+ DayForecast forecastFromParcel = DayForecast.CREATOR.createFromParcel(parcel);
+
+ assertEquals(forecast, forecastFromParcel);
+ assertEquals(forecast.getConditionCode(), forecastFromParcel.getConditionCode());
+ assertEquals(forecast.getHigh(), forecastFromParcel.getHigh());
+ assertEquals(forecast.getLow(), forecastFromParcel.getLow());
+ }
+
+ @SmallTest
+ public void testDayForecastBuilder() {
+ DayForecast forecast = new DayForecast.Builder(mConditionCode).setHigh(mHigh).setLow(mLow)
+ .build();
+
+ assertEquals(forecast.getConditionCode(), mConditionCode);
+ assertEquals(forecast.getHigh(), mHigh);
+ assertEquals(forecast.getLow(), mLow);
+ }
+
+ @SmallTest
+ public void testInvalidWeatherConditionCode() {
+ try {
+ DayForecast forecast = new DayForecast.Builder(Integer.MIN_VALUE).build();
+ throw new AssertionError("DayForecast object was built with invalid condition code!");
+ } catch (IllegalArgumentException e) {
+ /* EXPECTED */
+ }
+ }
+
+ @SmallTest
+ public void testInvalidHighTemperature() {
+ try {
+ DayForecast forecast = new DayForecast.Builder(mConditionCode).setHigh(Double.NaN)
+ .setLow(mLow).build();
+ throw new AssertionError("DayForecast object was built with invalid high temperature!");
+ } catch (IllegalArgumentException e) {
+ /* EXPECTED */
+ }
+ }
+
+ @SmallTest
+ public void testInvalidLowTemperature() {
+ try {
+ DayForecast forecast = new DayForecast.Builder(mConditionCode).setHigh(mHigh)
+ .setLow(Double.NaN).build();
+ throw new AssertionError("DayForecast object was built with invalid low temperature!");
+ } catch (IllegalArgumentException e) {
+ /* EXPECTED */
+ }
+ }
+}
diff --git a/tests/src/org/cyanogenmod/tests/weather/unit/ServiceRequestResultBuilderTest.java b/tests/src/org/cyanogenmod/tests/weather/unit/ServiceRequestResultBuilderTest.java
new file mode 100644
index 0000000..069e362
--- /dev/null
+++ b/tests/src/org/cyanogenmod/tests/weather/unit/ServiceRequestResultBuilderTest.java
@@ -0,0 +1,96 @@
+/**
+ * Copyright (C) 2016 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.cyanogenmod.tests.weather.unit;
+
+import android.os.Parcel;
+import android.test.AndroidTestCase;
+import android.test.suitebuilder.annotation.SmallTest;
+import cyanogenmod.providers.WeatherContract;
+import cyanogenmod.weather.WeatherInfo;
+import cyanogenmod.weather.WeatherLocation;
+import cyanogenmod.weatherservice.ServiceRequestResult;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ServiceRequestResultBuilderTest extends AndroidTestCase {
+
+ @SmallTest
+ public void testUnravelFromParcelWithWeatherInfo() {
+ final String cityName = "Cancun";
+ final double temperature = 70;
+ final int temperatureUnit = WeatherContract.WeatherColumns.TempUnit.CELSIUS;
+
+ WeatherInfo info = new WeatherInfo.Builder(cityName, temperature, temperatureUnit)
+ .build();
+
+ ServiceRequestResult result = new ServiceRequestResult.Builder(info).build();
+
+ Parcel parcel = Parcel.obtain();
+ result.writeToParcel(parcel, 0);
+
+ parcel.setDataPosition(0);
+
+ ServiceRequestResult resultFromParcel
+ = ServiceRequestResult.CREATOR.createFromParcel(parcel);
+
+ assertEquals(result, resultFromParcel);
+ assertEquals(result.getWeatherInfo(), resultFromParcel.getWeatherInfo());
+ }
+
+ @SmallTest
+ public void testsUnravelFromParcelWithWeatherLocationList() {
+
+ List<WeatherLocation> weatherLocationList = new ArrayList<>();
+ weatherLocationList.add(new WeatherLocation.Builder("Cancun").build());
+ ServiceRequestResult result = new ServiceRequestResult.Builder(weatherLocationList).build();
+
+ Parcel parcel = Parcel.obtain();
+ result.writeToParcel(parcel, 0);
+
+ parcel.setDataPosition(0);
+
+ ServiceRequestResult resultFromParcel
+ = ServiceRequestResult.CREATOR.createFromParcel(parcel);
+
+ assertEquals(result, resultFromParcel);
+ assertEquals(result.getLocationLookupList(), resultFromParcel.getLocationLookupList());
+ }
+
+ @SmallTest
+ public void testNullWeatherInfo() {
+ try {
+ WeatherInfo info = null;
+ ServiceRequestResult result = new ServiceRequestResult.Builder(info).build();
+ throw new AssertionError("ServiceRequestResult object was built with null WeatherInfo");
+ } catch (IllegalArgumentException e) {
+ /* EXPECTED */
+ }
+ }
+
+ @SmallTest
+ public void testNullWeatherLocationList() {
+ try {
+ List<WeatherLocation> list = null;
+ ServiceRequestResult result = new ServiceRequestResult.Builder(list).build();
+ throw new AssertionError("ServiceRequestResult object was built with null "
+ + "WeatherLocation list");
+ } catch (IllegalArgumentException e) {
+ /* EXPECTED */
+ }
+ }
+}
diff --git a/tests/src/org/cyanogenmod/tests/weather/unit/WeatherInfoBuilderTest.java b/tests/src/org/cyanogenmod/tests/weather/unit/WeatherInfoBuilderTest.java
new file mode 100644
index 0000000..22d0e41
--- /dev/null
+++ b/tests/src/org/cyanogenmod/tests/weather/unit/WeatherInfoBuilderTest.java
@@ -0,0 +1,252 @@
+/**
+ * Copyright (C) 2016 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.cyanogenmod.tests.weather.unit;
+
+import android.os.Parcel;
+import android.test.AndroidTestCase;
+import android.test.suitebuilder.annotation.SmallTest;
+import cyanogenmod.providers.WeatherContract;
+import cyanogenmod.weather.WeatherInfo;
+
+public class WeatherInfoBuilderTest extends AndroidTestCase {
+
+ private static final String mCityName = "Cancun";
+ private static final double mTemperature = 70;
+ private static final int mTemperatureUnit = WeatherContract.WeatherColumns.TempUnit.CELSIUS;
+ private static final double mHumidity = 45;
+ private static final double mWindSpeed = 15;
+ private static final double mWindDirection = 150;
+ private static final int mWindSpeedUnit = WeatherContract.WeatherColumns.WindSpeedUnit.KPH;
+ private static final long mTimestamp = System.currentTimeMillis();
+ private static final double mTodaysHigh = 80;
+ private static final double mTodaysLow = 65;
+ private static final int mWeatherConditionCode
+ = WeatherContract.WeatherColumns.WeatherCode.SUNNY;
+
+ @SmallTest
+ public void testUnravelFromParcelWithDefaultValues() {
+ //City name, temp and unit are required
+ WeatherInfo info = new WeatherInfo.Builder(mCityName, mTemperature, mTemperatureUnit)
+ .build();
+ Parcel parcel = Parcel.obtain();
+ info.writeToParcel(parcel, 0);
+
+ parcel.setDataPosition(0);
+
+ WeatherInfo weatherInfoFromParcel = WeatherInfo.CREATOR.createFromParcel(parcel);
+ assertNotNull(weatherInfoFromParcel);
+
+ assertEquals(info, weatherInfoFromParcel);
+ //City name
+ assertEquals(info.getCity(), weatherInfoFromParcel.getCity());
+ //Forecast list
+ assertEquals(info.getForecasts(), weatherInfoFromParcel.getForecasts());
+ //Humidity
+ assertEquals(info.getHumidity(), weatherInfoFromParcel.getHumidity());
+ //Temp
+ assertEquals(info.getConditionCode(), weatherInfoFromParcel.getConditionCode());
+ assertEquals(info.getTemperature(), weatherInfoFromParcel.getTemperature());
+ assertEquals(info.getTemperatureUnit(), weatherInfoFromParcel.getTemperatureUnit());
+ //Timestamp
+ assertEquals(info.getTimestamp(), weatherInfoFromParcel.getTimestamp());
+ //Today's low/high
+ assertEquals(info.getTodaysHigh(), weatherInfoFromParcel.getTodaysHigh());
+ assertEquals(info.getTodaysLow(), weatherInfoFromParcel.getTodaysLow());
+ //Wind
+ assertEquals(info.getWindDirection(), weatherInfoFromParcel.getWindDirection());
+ assertEquals(info.getWindSpeed(), weatherInfoFromParcel.getWindDirection());
+ assertEquals(info.getWindSpeedUnit(), weatherInfoFromParcel.getWindSpeedUnit());
+ //Verify default values
+ assertEquals(info.getTodaysHigh(), Double.NaN);
+ }
+
+ @SmallTest
+ public void testWeatherInfoBuilder() {
+ WeatherInfo info = new WeatherInfo.Builder(mCityName, mTemperature, mTemperatureUnit)
+ .setHumidity(mHumidity)
+ .setWind(mWindSpeed, mWindDirection, mWindSpeedUnit)
+ .setTimestamp(mTimestamp)
+ .setTodaysHigh(mTodaysHigh)
+ .setTodaysLow(mTodaysLow)
+ .setWeatherCondition(mWeatherConditionCode).build();
+
+ assertEquals(info.getCity(), mCityName);
+ assertEquals(info.getTemperature(), mTemperature);
+ assertEquals(info.getTemperatureUnit(), mTemperatureUnit);
+ assertEquals(info.getHumidity(), mHumidity);
+ assertEquals(info.getWindSpeed(), mWindSpeed);
+ assertEquals(info.getWindDirection(), mWindDirection);
+ assertEquals(info.getWindSpeedUnit(), mWindSpeedUnit);
+ assertEquals(info.getTimestamp(), mTimestamp);
+ assertEquals(info.getTodaysHigh(), mTodaysHigh);
+ assertEquals(info.getTodaysLow(), mTodaysLow);
+ assertEquals(info.getConditionCode(), mWeatherConditionCode);
+ }
+
+ @SmallTest
+ public void testUnravelFromParcel() {
+ WeatherInfo info = new WeatherInfo.Builder(mCityName, mTemperature, mTemperatureUnit)
+ .setHumidity(mHumidity)
+ .setWind(mWindSpeed, mWindDirection, mWindSpeedUnit)
+ .setTimestamp(mTimestamp)
+ .setTodaysHigh(mTodaysHigh)
+ .setTodaysLow(mTodaysLow)
+ .setWeatherCondition(mWeatherConditionCode).build();
+
+ Parcel parcel = Parcel.obtain();
+ info.writeToParcel(parcel, 0);
+
+ parcel.setDataPosition(0);
+
+ WeatherInfo infoFromParcel = WeatherInfo.CREATOR.createFromParcel(parcel);
+ assertEquals(info.getCity(), infoFromParcel.getCity());
+ assertEquals(info.getTemperature(), infoFromParcel.getTemperature());
+ assertEquals(info.getTemperatureUnit(), infoFromParcel.getTemperatureUnit());
+ assertEquals(info.getHumidity(), infoFromParcel.getHumidity());
+ assertEquals(info.getWindSpeed(), infoFromParcel.getWindSpeed());
+ assertEquals(info.getWindDirection(), infoFromParcel.getWindDirection());
+ assertEquals(info.getWindSpeedUnit(), infoFromParcel.getWindSpeedUnit());
+ assertEquals(info.getTimestamp(), infoFromParcel.getTimestamp());
+ assertEquals(info.getTodaysHigh(), infoFromParcel.getTodaysHigh());
+ assertEquals(info.getTodaysLow(), infoFromParcel.getTodaysLow());
+ assertEquals(info.getConditionCode(), infoFromParcel.getConditionCode());
+ }
+
+ @SmallTest
+ public void testNullCityName() {
+ try {
+ WeatherInfo info = new WeatherInfo.Builder(null, mTemperature, mTemperatureUnit)
+ .build();
+ throw new AssertionError("WeatherInfo object built with null city name!");
+ } catch (IllegalArgumentException e) {
+ /* EXPECTED */
+ }
+ }
+
+ @SmallTest
+ public void testInvalidTemperature() {
+ try {
+ WeatherInfo info = new WeatherInfo.Builder(mCityName, Double.NaN, mTemperatureUnit)
+ .build();
+ throw new AssertionError("WeatherInfo object built with invalid temperature value!");
+ } catch (IllegalArgumentException e) {
+ /* EXPECTED */
+ }
+ }
+
+ @SmallTest
+ public void testInvalidTemperatureUnit() {
+ try {
+ WeatherInfo info = new WeatherInfo.Builder(mCityName, mTemperature,Integer.MIN_VALUE)
+ .build();
+ throw new AssertionError("WeatherInfo object built with invalid temperature unit!");
+ } catch (IllegalArgumentException e) {
+ /* EXPECTED */
+ }
+ }
+
+ @SmallTest
+ public void testNullForecastList() {
+ try {
+ WeatherInfo info = new WeatherInfo.Builder(mCityName, mTemperature,mTemperatureUnit)
+ .setForecast(null).build();
+ throw new AssertionError("WeatherInfo object built with null forecast list!");
+ } catch (IllegalArgumentException e) {
+ /* EXPECTED */
+ }
+ }
+
+ @SmallTest
+ public void testInvalidWeatherConditionCode() {
+ try {
+ WeatherInfo info = new WeatherInfo.Builder(mCityName, mTemperature,mTemperatureUnit)
+ .setWeatherCondition(Integer.MIN_VALUE).build();
+ throw new AssertionError("WeatherInfo object built with invalid weather "
+ + "condition code!");
+ } catch (IllegalArgumentException e) {
+ /* EXPECTED */
+ }
+ }
+
+ @SmallTest
+ public void testInvalidHumidity() {
+ try {
+ WeatherInfo info = new WeatherInfo.Builder(mCityName, mTemperature,mTemperatureUnit)
+ .setHumidity(Double.NaN).build();
+ throw new AssertionError("WeatherInfo object built with invalid humidity value!");
+ } catch (IllegalArgumentException e) {
+ /* EXPECTED */
+ }
+ }
+
+ @SmallTest
+ public void testInvalidWindSpeed() {
+ try {
+ WeatherInfo info = new WeatherInfo.Builder(mCityName, mTemperature,mTemperatureUnit)
+ .setWind(Double.NaN, mWindDirection, mWindSpeedUnit)
+ .build();
+ throw new AssertionError("WeatherInfo object built with invalid wind speed!");
+ } catch (IllegalArgumentException e) {
+ /* EXPECTED */
+ }
+ }
+
+ @SmallTest
+ public void testInvalidWindDirection() {
+ try {
+ WeatherInfo info = new WeatherInfo.Builder(mCityName, mTemperature,mTemperatureUnit)
+ .setWind(mWindSpeed, Double.NaN, mWindSpeedUnit)
+ .build();
+ throw new AssertionError("WeatherInfo object built with invalid wind direction!");
+ } catch (IllegalArgumentException e) {
+ /* EXPECTED */
+ }
+ }
+
+ @SmallTest
+ public void testInvalidWindSpeedUnit(){
+ try {
+ WeatherInfo info = new WeatherInfo.Builder(mCityName, mTemperature,mTemperatureUnit)
+ .setWind(mWindSpeed, mWindDirection, Integer.MIN_VALUE).build();
+ throw new AssertionError("WeatherInfo object built with invalid wind speed unit!");
+ } catch (IllegalArgumentException e) {
+ /* EXPECTED */
+ }
+ }
+
+ @SmallTest
+ public void testInvalidTodaysLow() {
+ try {
+ WeatherInfo info = new WeatherInfo.Builder(mCityName, mTemperature,mTemperatureUnit)
+ .setTodaysLow(Double.NaN).build();
+ throw new AssertionError("WeatherInfo object built with invalid low temp!");
+ } catch (IllegalArgumentException e) {
+ /* EXPECTED */
+ }
+ }
+
+ @SmallTest
+ public void testInvalidTodaysHigh() {
+ try {
+ WeatherInfo info = new WeatherInfo.Builder(mCityName, mTemperature,mTemperatureUnit)
+ .setTodaysHigh(Double.NaN).build();
+ throw new AssertionError("WeatherInfo object built with invalid high temp!");
+ } catch (IllegalArgumentException e) {
+ /* EXPECTED */
+ }
+ }
+}
diff --git a/tests/src/org/cyanogenmod/tests/weather/unit/WeatherLocationBuilderTest.java b/tests/src/org/cyanogenmod/tests/weather/unit/WeatherLocationBuilderTest.java
new file mode 100644
index 0000000..852163c
--- /dev/null
+++ b/tests/src/org/cyanogenmod/tests/weather/unit/WeatherLocationBuilderTest.java
@@ -0,0 +1,129 @@
+/**
+ * Copyright (C) 2016 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.cyanogenmod.tests.weather.unit;
+
+import android.os.Parcel;
+import android.test.AndroidTestCase;
+import android.test.suitebuilder.annotation.SmallTest;
+import cyanogenmod.weather.WeatherLocation;
+
+public class WeatherLocationBuilderTest extends AndroidTestCase {
+
+ private static final String mCityId = "can1";
+ private static final String mCityName = "Cancun";
+ private static final String mState = "Quintana Roo";
+ private static final String mCountryId = "MX";
+ private static final String mCountry = "Mexico";
+ private static final String mZipCode = "77510";
+
+ @SmallTest
+ public void testUnravelFromParcelTwoArgsConstructor() {
+ WeatherLocation location = new WeatherLocation.Builder(mCityId, mCityName)
+ .setState(mState).setPostalCode(mZipCode).setCountryId(mCountryId)
+ .setCountry(mCountry).build();
+
+ Parcel parcel = Parcel.obtain();
+ location.writeToParcel(parcel, 0);
+
+ parcel.setDataPosition(0);
+
+ WeatherLocation locationFromParcel = WeatherLocation.CREATOR.createFromParcel(parcel);
+
+ assertEquals(location, locationFromParcel);
+ assertEquals(location.getCityId(), locationFromParcel.getCityId());
+ assertEquals(location.getCity(), locationFromParcel.getCity());
+ assertEquals(location.getState(), locationFromParcel.getState());
+ assertEquals(location.getPostalCode(), locationFromParcel.getPostalCode());
+ assertEquals(location.getCountry(), locationFromParcel.getCountry());
+ assertEquals(location.getCountryId(), locationFromParcel.getCountryId());
+ }
+
+ @SmallTest
+ public void testUnravelFromParcelOneArgConstructor() {
+ WeatherLocation location = new WeatherLocation.Builder(mCityName)
+ .setState(mState).setPostalCode(mZipCode).setCountryId(mCountryId)
+ .setCountry(mCountry).build();
+
+ Parcel parcel = Parcel.obtain();
+ location.writeToParcel(parcel, 0);
+
+ parcel.setDataPosition(0);
+
+ WeatherLocation locationFromParcel = WeatherLocation.CREATOR.createFromParcel(parcel);
+
+ assertEquals(location, locationFromParcel);
+ assertEquals(location.getCityId(), locationFromParcel.getCityId());
+ assertEquals(location.getCity(), locationFromParcel.getCity());
+ assertEquals(location.getState(), locationFromParcel.getState());
+ assertEquals(location.getPostalCode(), locationFromParcel.getPostalCode());
+ assertEquals(location.getCountry(), locationFromParcel.getCountry());
+ assertEquals(location.getCountryId(), locationFromParcel.getCountryId());
+ }
+
+ @SmallTest
+ public void testUnravelFromParcelWithDefaultsOneArgConstructor() {
+ WeatherLocation location = new WeatherLocation.Builder(mCityName).build();
+ Parcel parcel = Parcel.obtain();
+ location.writeToParcel(parcel, 0);
+
+ parcel.setDataPosition(0);
+
+ WeatherLocation locationFromParcel = WeatherLocation.CREATOR.createFromParcel(parcel);
+
+ assertEquals(location, locationFromParcel);
+ assertEquals(location.getCityId(), locationFromParcel.getCityId());
+ assertEquals(location.getCity(), locationFromParcel.getCity());
+ assertEquals(location.getState(), locationFromParcel.getState());
+ assertEquals(location.getPostalCode(), locationFromParcel.getPostalCode());
+ assertEquals(location.getCountry(), locationFromParcel.getCountry());
+ assertEquals(location.getCountryId(), locationFromParcel.getCountryId());
+ }
+
+ @SmallTest
+ public void testUnravelFromParcelWithDefaultsTwoArgsConstructor() {
+ WeatherLocation location = new WeatherLocation.Builder(mCityId, mCityName).build();
+ Parcel parcel = Parcel.obtain();
+ location.writeToParcel(parcel, 0);
+
+ parcel.setDataPosition(0);
+
+ WeatherLocation locationFromParcel = WeatherLocation.CREATOR.createFromParcel(parcel);
+
+ assertEquals(location, locationFromParcel);
+ assertEquals(location.getCityId(), locationFromParcel.getCityId());
+ assertEquals(location.getCity(), locationFromParcel.getCity());
+ assertEquals(location.getState(), locationFromParcel.getState());
+ assertEquals(location.getPostalCode(), locationFromParcel.getPostalCode());
+ assertEquals(location.getCountry(), locationFromParcel.getCountry());
+ assertEquals(location.getCountryId(), locationFromParcel.getCountryId());
+ }
+
+
+ @SmallTest
+ public void testWeatherLocationBuilder() {
+ WeatherLocation location = new WeatherLocation.Builder(mCityId, mCityName)
+ .setState(mState).setPostalCode(mZipCode).setCountryId(mCountryId)
+ .setCountry(mCountry).build();
+
+ assertEquals(location.getCityId(), mCityId);
+ assertEquals(location.getCity(), mCityName);
+ assertEquals(location.getState(), mState);
+ assertEquals(location.getPostalCode(), mZipCode);
+ assertEquals(location.getCountryId(), mCountryId);
+ assertEquals(location.getCountry(), mCountry);
+ }
+}