Search in sources :

Example 1 with Weather

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

the class InDatabaseWeatherPersisterTest method test_cacheKey_can_be_string_when_object_type_has_int_id.

public void test_cacheKey_can_be_string_when_object_type_has_int_id() throws Exception {
    // GIVEN
    Weather weatherRequestStatus = buildWeather(WEATHER_ID, TEST_TEMP);
    dataPersistenceManager.saveDataToCacheAndReturnData(weatherRequestStatus, CACHE_KEY3_STRING);
    // WHEN
    Weather weatherReturned = dataPersistenceManager.loadDataFromCache(CACHE_KEY3_STRING, DurationInMillis.ALWAYS_RETURNED);
    List<Weather> listWeatherResult = dataPersistenceManager.loadAllDataFromCache();
    // THEN
    assertNotNull(listWeatherResult);
    assertEquals(1, listWeatherResult.size());
    assertTrue(listWeatherResult.contains(weatherRequestStatus));
    assertEquals(WEATHER_ID, weatherReturned.getId());
}
Also used : CurrenWeather(com.octo.android.robospice.ormlite.test.model.CurrenWeather) Weather(com.octo.android.robospice.ormlite.test.model.Weather)

Example 2 with Weather

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

the class InDatabaseWeatherPersisterTest method test_loadAllDataFromCache_with_one_request_in_cache.

public void test_loadAllDataFromCache_with_one_request_in_cache() throws Exception {
    // GIVEN
    Weather weatherRequestStatus = buildWeather(WEATHER_ID, TEST_TEMP);
    dataPersistenceManager.saveDataToCacheAndReturnData(weatherRequestStatus, CACHE_KEY);
    // WHEN
    List<Weather> listWeatherResult = dataPersistenceManager.loadAllDataFromCache();
    // THEN
    assertNotNull(listWeatherResult);
    assertEquals(1, listWeatherResult.size());
    assertEquals(weatherRequestStatus, listWeatherResult.get(0));
}
Also used : CurrenWeather(com.octo.android.robospice.ormlite.test.model.CurrenWeather) Weather(com.octo.android.robospice.ormlite.test.model.Weather)

Example 3 with Weather

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

the class InDatabaseWeatherPersisterTest method test_loadDataFromCache_expired.

public void test_loadDataFromCache_expired() throws Exception {
    // GIVEN
    Weather weatherRequestStatus = buildWeather(WEATHER_ID, TEST_TEMP);
    dataPersistenceManager.saveDataToCacheAndReturnData(weatherRequestStatus, CACHE_KEY);
    Thread.sleep(DurationInMillis.ONE_SECOND);
    // WHEN
    Weather weatherReturned = dataPersistenceManager.loadDataFromCache(CACHE_KEY, DurationInMillis.ONE_SECOND);
    // THEN
    assertNull(weatherReturned);
}
Also used : CurrenWeather(com.octo.android.robospice.ormlite.test.model.CurrenWeather) Weather(com.octo.android.robospice.ormlite.test.model.Weather)

Example 4 with Weather

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

the class InDatabaseWeatherPersisterTest method test_saveDataAndReturnData.

public void test_saveDataAndReturnData() throws Exception {
    // GIVEN
    Weather weatherRequestStatus = buildWeather(WEATHER_ID, TEST_TEMP);
    // WHEN
    Weather weatherReturned = dataPersistenceManager.saveDataToCacheAndReturnData(weatherRequestStatus, 1);
    // 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 5 with Weather

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

the class InDatabaseWeatherPersisterTest 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(WEATHER_ID, TEST_TEMP);
    dataPersistenceManager.saveDataToCacheAndReturnData(weatherRequestStatus, CACHE_KEY);
    Weather weatherRequestStatus2 = buildWeather(WEATHER_ID2, TEST_TEMP2);
    dataPersistenceManager.saveDataToCacheAndReturnData(weatherRequestStatus2, CACHE_KEY2);
    dataPersistenceManager.removeDataFromCache(CACHE_KEY2);
    // WHEN
    List<Weather> listWeatherResult = dataPersistenceManager.loadAllDataFromCache();
    // THEN
    assertNotNull(listWeatherResult);
    assertEquals(1, listWeatherResult.size());
    assertTrue(listWeatherResult.contains(weatherRequestStatus));
    assertFalse(listWeatherResult.contains(weatherRequestStatus2));
}
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