Search in sources :

Example 1 with Weather

use of com.octo.android.robospice.springandroid.test.model.xml.Weather in project robospice by stephanenicolas.

the class InFileWeatherPersisterTest method test_removeDataFromCache_when_two_requests_in_cache_and_one_removed.

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

Example 2 with Weather

use of com.octo.android.robospice.springandroid.test.model.xml.Weather in project robospice by stephanenicolas.

the class InFileWeatherPersisterTest method test_loadDataFromCache_expired.

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

Example 3 with Weather

use of com.octo.android.robospice.springandroid.test.model.xml.Weather 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
    Weather weatherRequestStatus = buildWeather(TEST_TEMP);
    dataPersistenceManager.saveDataToCacheAndReturnData(weatherRequestStatus, FILE_NAME);
    Weather weatherRequestStatus2 = buildWeather(TEST_TEMP2);
    dataPersistenceManager.saveDataToCacheAndReturnData(weatherRequestStatus2, FILE_NAME2);
    // WHEN
    List<Weather> listWeatherResult = dataPersistenceManager.loadAllDataFromCache();
    // THEN
    assertNotNull(listWeatherResult);
    assertEquals(2, listWeatherResult.size());
    assertTrue(listWeatherResult.contains(weatherRequestStatus));
    assertTrue(listWeatherResult.contains(weatherRequestStatus2));
}
Also used : Weather(com.octo.android.robospice.springandroid.test.model.xml.Weather)

Example 4 with Weather

use of com.octo.android.robospice.springandroid.test.model.xml.Weather in project robospice by stephanenicolas.

the class InFileWeatherPersisterTest method test_loadDataFromCache_not_expired.

public void test_loadDataFromCache_not_expired() throws Exception {
    // GIVEN
    Weather weatherRequestStatus = buildWeather(TEST_TEMP);
    dataPersistenceManager.saveDataToCacheAndReturnData(weatherRequestStatus, FILE_NAME);
    // WHEN
    Weather weatherReturned = dataPersistenceManager.loadDataFromCache(FILE_NAME, FIVE_SECONDS);
    // THEN
    assertTrue(weatherReturned.getListWeather().contains(TEST_TEMP));
}
Also used : Weather(com.octo.android.robospice.springandroid.test.model.xml.Weather)

Example 5 with Weather

use of com.octo.android.robospice.springandroid.test.model.xml.Weather in project robospice by stephanenicolas.

the class InFileWeatherPersisterTest method test_loadDataFromCache_no_expiracy.

public void test_loadDataFromCache_no_expiracy() throws Exception {
    // GIVEN
    Weather weatherRequestStatus = buildWeather(TEST_TEMP);
    dataPersistenceManager.saveDataToCacheAndReturnData(weatherRequestStatus, FILE_NAME);
    // WHEN
    Weather weatherReturned = dataPersistenceManager.loadDataFromCache(FILE_NAME, DurationInMillis.ALWAYS_RETURNED);
    // THEN
    assertTrue(weatherReturned.getListWeather().contains(TEST_TEMP));
}
Also used : Weather(com.octo.android.robospice.springandroid.test.model.xml.Weather)

Aggregations

Weather (com.octo.android.robospice.springandroid.test.model.xml.Weather)8 Curren_weather (com.octo.android.robospice.springandroid.test.model.xml.Curren_weather)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1