Search in sources :

Example 1 with WeatherResult

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

the class JsonObjectPersisterFactoryTest method test_loadDataFromCache_not_expired.

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

Example 2 with WeatherResult

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

the class JsonObjectPersisterFactoryTest method test_loadDataFromCache_expired.

public void test_loadDataFromCache_expired() throws Exception {
    // GIVEN
    WeatherResult weatherRequestStatus = buildWeather(TEST_TEMP2, TEST_TEMP_UNIT);
    inFileObjectPersister.saveDataToCacheAndReturnData(weatherRequestStatus, FILE_NAME);
    File cachedFile = inFileObjectPersister.getCacheFile(FILE_NAME);
    cachedFile.setLastModified(System.currentTimeMillis() - FIVE_SECONDS);
    // WHEN
    WeatherResult weatherReturned = inFileObjectPersister.loadDataFromCache(FILE_NAME, DurationInMillis.ONE_SECOND);
    // THEN
    assertNull(weatherReturned);
}
Also used : WeatherResult(com.octo.android.robospice.googlehttpclient.test.model.WeatherResult) File(java.io.File)

Example 3 with WeatherResult

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

the class JsonObjectPersisterFactoryTest method test_saveDataAndReturnData.

public void test_saveDataAndReturnData() throws Exception {
    // GIVEN
    WeatherResult weatherRequestStatus = buildWeather(TEST_TEMP, TEST_TEMP_UNIT);
    // WHEN
    WeatherResult weatherReturned = inFileObjectPersister.saveDataToCacheAndReturnData(weatherRequestStatus, "weather.json");
    // THEN
    assertEquals(TEST_TEMP, weatherReturned.getWeather().getCurren_weather().get(0).getTemp());
}
Also used : WeatherResult(com.octo.android.robospice.googlehttpclient.test.model.WeatherResult)

Example 4 with WeatherResult

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

the class JsonObjectPersisterFactoryTest method test_loadAllDataFromCache_with_one_request_in_cache.

public void test_loadAllDataFromCache_with_one_request_in_cache() throws Exception {
    // GIVEN
    WeatherResult weatherRequestStatus = buildWeather(TEST_TEMP, TEST_TEMP_UNIT);
    inFileObjectPersister.saveDataToCacheAndReturnData(weatherRequestStatus, FILE_NAME);
    // WHEN
    List<WeatherResult> listWeatherResult = inFileObjectPersister.loadAllDataFromCache();
    // THEN
    assertNotNull(listWeatherResult);
    assertEquals(1, listWeatherResult.size());
    assertEquals(weatherRequestStatus, listWeatherResult.get(0));
}
Also used : WeatherResult(com.octo.android.robospice.googlehttpclient.test.model.WeatherResult)

Example 5 with WeatherResult

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

the class JsonObjectPersisterFactoryTest 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);
    inFileObjectPersister.saveDataToCacheAndReturnData(weatherRequestStatus, FILE_NAME);
    WeatherResult weatherRequestStatus2 = buildWeather(TEST_TEMP2, TEST_TEMP_UNIT);
    inFileObjectPersister.saveDataToCacheAndReturnData(weatherRequestStatus2, FILE_NAME2);
    // WHEN
    List<WeatherResult> listWeatherResult = inFileObjectPersister.loadAllDataFromCache();
    // THEN
    assertNotNull(listWeatherResult);
    assertEquals(2, listWeatherResult.size());
    assertTrue(listWeatherResult.contains(weatherRequestStatus));
    assertTrue(listWeatherResult.contains(weatherRequestStatus2));
}
Also used : WeatherResult(com.octo.android.robospice.googlehttpclient.test.model.WeatherResult)

Aggregations

WeatherResult (com.octo.android.robospice.googlehttpclient.test.model.WeatherResult)8 CurrenWeather (com.octo.android.robospice.googlehttpclient.test.model.CurrenWeather)1 Weather (com.octo.android.robospice.googlehttpclient.test.model.Weather)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1