private Weather buildWeather() { Weather weather = new Weather(); List<Curren_weather> currents = new ArrayList<Curren_weather>(); currents.add(TEST_TEMP); weather.setCurren_weather(currents); List<Forecast> forecasts = new ArrayList<Forecast>(); weather.setForecast(forecasts); return weather; }
public void test_saveDataAndReturnData() throws Exception { // GIVEN Weather weatherRequestStatus = buildWeather(); // WHEN Weather weatherReturned = dataPersistenceManager.saveDataToCacheAndReturnData(weatherRequestStatus, "weather.xml"); // THEN assertTrue(weatherReturned.getCurren_weather().contains(TEST_TEMP)); }
public void test_loadDataFromCache_not_expired() throws Exception { // GIVEN Weather weatherRequestStatus = buildWeather(); final String FILE_NAME = "toto"; dataPersistenceManager.saveDataToCacheAndReturnData(weatherRequestStatus, FILE_NAME); // WHEN Weather weatherReturned = dataPersistenceManager.loadDataFromCache(FILE_NAME, DurationInMillis.ONE_SECOND); // THEN assertTrue(weatherReturned.getCurren_weather().contains(TEST_TEMP)); }
public void test_saveDataAndReturnData_async() throws Exception { // GIVEN Weather weatherRequestStatus = buildWeather(); // WHEN dataPersistenceManager.setAsyncSaveEnabled(true); Weather weatherReturned = dataPersistenceManager.saveDataToCacheAndReturnData(weatherRequestStatus, "weather.xml"); // THEN ((SimpleSerializerObjectPersister<?>) dataPersistenceManager) .awaitForSaveAsyncTermination(500, TimeUnit.MILLISECONDS); assertTrue(weatherReturned.getCurren_weather().contains(TEST_TEMP)); }