Search in sources :

Example 6 with WeatherResult

use of com.octo.android.robospice.googlehttpclient.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<CurrenWeather> currents = new ArrayList<CurrenWeather>();
    CurrenWeather current_weather = new CurrenWeather();
    current_weather.setTemp(temp);
    current_weather.setTemp_unit(tempUnit);
    currents.add(current_weather);
    weather.setCurren_weather(currents);
    weatherRequestStatus.setWeather(weather);
    return weatherRequestStatus;
}
Also used : CurrenWeather(com.octo.android.robospice.googlehttpclient.test.model.CurrenWeather) Weather(com.octo.android.robospice.googlehttpclient.test.model.Weather) CurrenWeather(com.octo.android.robospice.googlehttpclient.test.model.CurrenWeather) WeatherResult(com.octo.android.robospice.googlehttpclient.test.model.WeatherResult) ArrayList(java.util.ArrayList)

Example 7 with WeatherResult

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

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

Example 8 with WeatherResult

use of com.octo.android.robospice.googlehttpclient.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);
    inFileObjectPersister.saveDataToCacheAndReturnData(weatherRequestStatus, FILE_NAME);
    // WHEN
    WeatherResult weatherReturned = inFileObjectPersister.loadDataFromCache(FILE_NAME, DurationInMillis.ALWAYS_RETURNED);
    // THEN
    assertEquals(TEST_TEMP, weatherReturned.getWeather().getCurren_weather().get(0).getTemp());
}
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