use of com.octo.android.robospice.ormlite.test.model.Weather in project robospice by stephanenicolas.
the class InDatabaseWeatherPersisterTest method buildWeather.
private Weather buildWeather(int id, CurrenWeather currenWeather) {
Weather weather = new Weather();
weather.setId(id);
List<CurrenWeather> currents = new ArrayList<CurrenWeather>();
currents.add(currenWeather);
weather.setListWeather(currents);
weather.setListForecast(null);
return weather;
}
use of com.octo.android.robospice.ormlite.test.model.Weather in project robospice by stephanenicolas.
the class InDatabaseWeatherPersisterTest method test_loadDataFromCache_not_expired.
public void test_loadDataFromCache_not_expired() throws Exception {
// GIVEN
Weather weatherRequestStatus = buildWeather(WEATHER_ID, TEST_TEMP);
dataPersistenceManager.saveDataToCacheAndReturnData(weatherRequestStatus, CACHE_KEY);
// WHEN
Weather weatherReturned = dataPersistenceManager.loadDataFromCache(CACHE_KEY, DurationInMillis.ONE_SECOND);
// THEN
assertTrue(weatherReturned.getListWeather().contains(TEST_TEMP));
}
use of com.octo.android.robospice.ormlite.test.model.Weather in project robospice by stephanenicolas.
the class InDatabaseWeatherPersisterTest method test_loadDataFromCache_no_expiracy.
public void test_loadDataFromCache_no_expiracy() throws Exception {
// GIVEN
Weather weatherRequestStatus = buildWeather(WEATHER_ID, TEST_TEMP);
dataPersistenceManager.saveDataToCacheAndReturnData(weatherRequestStatus, CACHE_KEY);
// WHEN
Weather weatherReturned = dataPersistenceManager.loadDataFromCache(CACHE_KEY, DurationInMillis.ALWAYS_RETURNED);
// THEN
assertEquals(WEATHER_ID, weatherReturned.getId());
assertTrue(weatherReturned.getListWeather().contains(TEST_TEMP));
}
use of com.octo.android.robospice.ormlite.test.model.Weather in project robospice by stephanenicolas.
the class InDatabaseWeatherPersisterTest method test_loadAllDataFromCache_with_two_requests_in_cache.
public void test_loadAllDataFromCache_with_two_requests_in_cache() throws Exception {
// GIVEN
Weather weatherRequestStatus = buildWeather(WEATHER_ID, TEST_TEMP);
dataPersistenceManager.saveDataToCacheAndReturnData(weatherRequestStatus, CACHE_KEY);
Weather weatherRequestStatus2 = buildWeather(WEATHER_ID2, TEST_TEMP2);
dataPersistenceManager.saveDataToCacheAndReturnData(weatherRequestStatus2, CACHE_KEY2);
// WHEN
List<Weather> listWeatherResult = dataPersistenceManager.loadAllDataFromCache();
// THEN
assertNotNull(listWeatherResult);
assertEquals(2, listWeatherResult.size());
assertTrue(listWeatherResult.contains(weatherRequestStatus));
assertTrue(listWeatherResult.contains(weatherRequestStatus2));
}
use of com.octo.android.robospice.ormlite.test.model.Weather in project robospice by stephanenicolas.
the class InDatabaseWeatherPersisterTest method test_notification.
public void test_notification() throws Exception {
// GIVEN
Weather weatherRequestStatus = buildWeather(WEATHER_ID, TEST_TEMP);
dataPersistenceManager.saveDataToCacheAndReturnData(weatherRequestStatus, CACHE_KEY3_STRING);
// THAN
assertTrue(mResolver.getNotificationUris().contains(NOTIFICATION_URI1));
assertTrue(mResolver.getNotificationUris().contains(NOTIFICATION_URI2));
}
Aggregations