Search in sources :

Example 6 with Weather

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;
}
Also used : CurrenWeather(com.octo.android.robospice.ormlite.test.model.CurrenWeather) Weather(com.octo.android.robospice.ormlite.test.model.Weather) CurrenWeather(com.octo.android.robospice.ormlite.test.model.CurrenWeather) ArrayList(java.util.ArrayList)

Example 7 with 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));
}
Also used : CurrenWeather(com.octo.android.robospice.ormlite.test.model.CurrenWeather) Weather(com.octo.android.robospice.ormlite.test.model.Weather)

Example 8 with Weather

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));
}
Also used : CurrenWeather(com.octo.android.robospice.ormlite.test.model.CurrenWeather) Weather(com.octo.android.robospice.ormlite.test.model.Weather)

Example 9 with Weather

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));
}
Also used : CurrenWeather(com.octo.android.robospice.ormlite.test.model.CurrenWeather) Weather(com.octo.android.robospice.ormlite.test.model.Weather)

Example 10 with Weather

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));
}
Also used : CurrenWeather(com.octo.android.robospice.ormlite.test.model.CurrenWeather) Weather(com.octo.android.robospice.ormlite.test.model.Weather)

Aggregations

CurrenWeather (com.octo.android.robospice.ormlite.test.model.CurrenWeather)10 Weather (com.octo.android.robospice.ormlite.test.model.Weather)10 ArrayList (java.util.ArrayList)1