Search in sources :

Example 21 with WeatherResult

use of com.octo.android.robospice.springandroid.test.model.json.WeatherResult in project robospice by stephanenicolas.

the class InFileWeatherPersisterTest method test_loadDataFromCache_expired.

public void test_loadDataFromCache_expired() throws Exception {
    // GIVEN
    WeatherResult weatherRequestStatus = buildWeather(TEST_TEMP, TEST_TEMP_UNIT);
    dataPersistenceManager.saveDataToCacheAndReturnData(weatherRequestStatus, FILE_NAME);
    File cachedFile = ((GsonObjectPersister<?>) dataPersistenceManager).getCacheFile(FILE_NAME);
    cachedFile.setLastModified(System.currentTimeMillis() - FIVE_SECONDS);
    // WHEN
    WeatherResult weatherReturned = dataPersistenceManager.loadDataFromCache(FILE_NAME, FIVE_SECONDS);
    // THEN
    assertNull(weatherReturned);
}
Also used : WeatherResult(com.octo.android.robospice.springandroid.test.model.json.WeatherResult) File(java.io.File)

Example 22 with WeatherResult

use of com.octo.android.robospice.springandroid.test.model.json.WeatherResult in project robospice by stephanenicolas.

the class InFileWeatherPersisterTest method test_loadDataFromCache_no_expiracy.

public void test_loadDataFromCache_no_expiracy() throws Exception {
    // GIVEN
    WeatherResult weatherRequestStatus = buildWeather(TEST_TEMP, TEST_TEMP_UNIT);
    dataPersistenceManager.saveDataToCacheAndReturnData(weatherRequestStatus, FILE_NAME);
    // WHEN
    WeatherResult weatherReturned = dataPersistenceManager.loadDataFromCache(FILE_NAME, DurationInMillis.ALWAYS_RETURNED);
    // THEN
    assertEquals(TEST_TEMP, weatherReturned.getWeather().getCurren_weather().get(0).getTemp());
}
Also used : WeatherResult(com.octo.android.robospice.springandroid.test.model.json.WeatherResult)

Example 23 with WeatherResult

use of com.octo.android.robospice.springandroid.test.model.json.WeatherResult in project robospice by stephanenicolas.

the class InFileWeatherPersisterTest method test_loadDataFromCache_no_expiracy.

public void test_loadDataFromCache_no_expiracy() throws Exception {
    // GIVEN
    WeatherResult weatherRequestStatus = buildWeather(TEST_TEMP, TEST_TEMP_UNIT);
    dataPersistenceManager.saveDataToCacheAndReturnData(weatherRequestStatus, FILE_NAME);
    // WHEN
    WeatherResult weatherReturned = dataPersistenceManager.loadDataFromCache(FILE_NAME, DurationInMillis.ALWAYS_RETURNED);
    // THEN
    assertEquals(TEST_TEMP, weatherReturned.getWeather().getCurren_weather().get(0).getTemp());
}
Also used : WeatherResult(com.octo.android.robospice.springandroid.test.model.json.WeatherResult)

Example 24 with WeatherResult

use of com.octo.android.robospice.springandroid.test.model.json.WeatherResult in project robospice by stephanenicolas.

the class InFileWeatherPersisterTest method test_loadAllDataFromCache_with_two_requests_in_cache.

public void test_loadAllDataFromCache_with_two_requests_in_cache() throws Exception {
    // GIVEN
    WeatherResult weatherRequestStatus = buildWeather(TEST_TEMP, TEST_TEMP_UNIT);
    dataPersistenceManager.saveDataToCacheAndReturnData(weatherRequestStatus, FILE_NAME);
    WeatherResult weatherRequestStatus2 = buildWeather(TEST_TEMP2, TEST_TEMP_UNIT);
    dataPersistenceManager.saveDataToCacheAndReturnData(weatherRequestStatus2, FILE_NAME2);
    // WHEN
    List<WeatherResult> listWeatherResult = dataPersistenceManager.loadAllDataFromCache();
    // THEN
    assertNotNull(listWeatherResult);
    assertEquals(2, listWeatherResult.size());
    assertTrue(listWeatherResult.contains(weatherRequestStatus));
    assertTrue(listWeatherResult.contains(weatherRequestStatus2));
}
Also used : WeatherResult(com.octo.android.robospice.springandroid.test.model.json.WeatherResult)

Aggregations

WeatherResult (com.octo.android.robospice.springandroid.test.model.json.WeatherResult)24 CurrenWeather (com.octo.android.robospice.springandroid.test.model.json.CurrenWeather)3 Weather (com.octo.android.robospice.springandroid.test.model.json.Weather)3 File (java.io.File)3 ArrayList (java.util.ArrayList)3