From 37e439c7874f5d6b0174aad4d210e3c60b78ab30 Mon Sep 17 00:00:00 2001 From: Lyla Date: Mon, 9 Feb 2015 16:05:57 -0800 Subject: [PATCH] 4.08 Adding weather with location to the uribuilder --- .../app/data/TestWeatherContract.java | 23 ++++++++++--------- .../sunshine/app/data/WeatherContract.java | 4 ++-- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/app/src/androidTest/java/com/example/android/sunshine/app/data/TestWeatherContract.java b/app/src/androidTest/java/com/example/android/sunshine/app/data/TestWeatherContract.java index b084d3697..6a2099814 100644 --- a/app/src/androidTest/java/com/example/android/sunshine/app/data/TestWeatherContract.java +++ b/app/src/androidTest/java/com/example/android/sunshine/app/data/TestWeatherContract.java @@ -15,6 +15,7 @@ */ package com.example.android.sunshine.app.data; +import android.net.Uri; import android.test.AndroidTestCase; /* @@ -30,15 +31,15 @@ public class TestWeatherContract extends AndroidTestCase { /* Students: Uncomment this out to test your weather location function. */ -// public void testBuildWeatherLocation() { -// Uri locationUri = WeatherContract.WeatherEntry.buildWeatherLocation(TEST_WEATHER_LOCATION); -// assertNotNull("Error: Null Uri returned. You must fill-in buildWeatherLocation in " + -// "WeatherContract.", -// locationUri); -// assertEquals("Error: Weather location not properly appended to the end of the Uri", -// TEST_WEATHER_LOCATION, locationUri.getLastPathSegment()); -// assertEquals("Error: Weather location Uri doesn't match our expected result", -// locationUri.toString(), -// "content://com.example.android.sunshine.app/weather/%2FNorth%20Pole"); -// } + public void testBuildWeatherLocation() { + Uri locationUri = WeatherContract.WeatherEntry.buildWeatherLocation(TEST_WEATHER_LOCATION); + assertNotNull("Error: Null Uri returned. You must fill-in buildWeatherLocation in " + + "WeatherContract.", + locationUri); + assertEquals("Error: Weather location not properly appended to the end of the Uri", + TEST_WEATHER_LOCATION, locationUri.getLastPathSegment()); + assertEquals("Error: Weather location Uri doesn't match our expected result", + locationUri.toString(), + "content://com.example.android.sunshine.app/weather/%2FNorth%20Pole"); + } } diff --git a/app/src/main/java/com/example/android/sunshine/app/data/WeatherContract.java b/app/src/main/java/com/example/android/sunshine/app/data/WeatherContract.java index 9b003430d..63387c4a8 100644 --- a/app/src/main/java/com/example/android/sunshine/app/data/WeatherContract.java +++ b/app/src/main/java/com/example/android/sunshine/app/data/WeatherContract.java @@ -131,10 +131,10 @@ public static Uri buildWeatherUri(long id) { } /* - Student: Fill in this buildWeatherLocation function + Student: This is the buildWeatherLocation function you filled in. */ public static Uri buildWeatherLocation(String locationSetting) { - return null; + return CONTENT_URI.buildUpon().appendPath(locationSetting).build(); } public static Uri buildWeatherLocationWithStartDate(