use of com.octo.android.robospice.retrofit.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);
final String fileName = "toto";
inFileObjectPersister.saveDataToCacheAndReturnData(weatherRequestStatus, fileName);
// WHEN
WeatherResult weatherReturned = inFileObjectPersister.loadDataFromCache(fileName, DurationInMillis.ONE_MINUTE);
// THEN
assertEquals(TEST_TEMP, weatherReturned.getWeather().getCurren_weather().get(0).getTemp());
}
use of com.octo.android.robospice.retrofit.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);
final String fileName = "toto";
inFileObjectPersister.saveDataToCacheAndReturnData(weatherRequestStatus, fileName);
File cachedFile = ((RetrofitObjectPersister<?>) inFileObjectPersister).getCacheFile(fileName);
final int secondsCountBackInTime = 5;
cachedFile.setLastModified(System.currentTimeMillis() - secondsCountBackInTime * DurationInMillis.ONE_SECOND);
// WHEN
WeatherResult weatherReturned = inFileObjectPersister.loadDataFromCache(fileName, DurationInMillis.ONE_SECOND);
// THEN
assertNull(weatherReturned);
}
use of com.octo.android.robospice.retrofit.test.model.WeatherResult in project robospice by stephanenicolas.
the class JsonObjectPersisterFactoryTest method buildWeather.
private WeatherResult buildWeather(String temp, String tempUnit) {
WeatherResult weatherRequestStatus = new WeatherResult();
Weather weather = new Weather();
List<Curren_weather> currents = new ArrayList<Curren_weather>();
Curren_weather current_weather = new Curren_weather();
current_weather.setTemp(temp);
current_weather.setTemp_unit(tempUnit);
currents.add(current_weather);
weather.setCurren_weather(currents);
weatherRequestStatus.setWeather(weather);
return weatherRequestStatus;
}
use of com.octo.android.robospice.retrofit.test.model.WeatherResult in project robospice by stephanenicolas.
the class JsonObjectPersisterFactoryTest method test_loadDataFromCache_no_expiracy.
public void test_loadDataFromCache_no_expiracy() throws Exception {
// GIVEN
WeatherResult weatherRequestStatus = buildWeather(TEST_TEMP, TEST_TEMP_UNIT);
final String fileName = "toto";
inFileObjectPersister.saveDataToCacheAndReturnData(weatherRequestStatus, fileName);
// WHEN
WeatherResult weatherReturned = inFileObjectPersister.loadDataFromCache(fileName, DurationInMillis.ALWAYS_RETURNED);
// THEN
assertEquals(TEST_TEMP, weatherReturned.getWeather().getCurren_weather().get(0).getTemp());
}
use of com.octo.android.robospice.retrofit.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());
}
Aggregations