Search in sources :

Example 6 with WeatherResult

use of com.octo.android.robospice.retrofit.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);
    final String fileName = "toto";
    inFileObjectPersister.saveDataToCacheAndReturnData(weatherRequestStatus, fileName);
    WeatherResult weatherRequestStatus2 = buildWeather(TEST_TEMP2, TEST_TEMP_UNIT);
    final String fileName2 = "tutu";
    inFileObjectPersister.saveDataToCacheAndReturnData(weatherRequestStatus2, fileName2);
    inFileObjectPersister.removeDataFromCache(fileName2);
    // 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.retrofit.test.model.WeatherResult)

Example 7 with WeatherResult

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

the class RetrofitGsonSpiceServiceTest method test_addRequest_injects_request_factory.

public void test_addRequest_injects_request_factory() throws InterruptedException {
    // given
    spiceManager.start(getContext());
    RetrofitSpiceRequestStub retrofitSpiceRequestStub = new RetrofitSpiceRequestStub(WeatherResult.class);
    // when
    spiceManager.execute(retrofitSpiceRequestStub, new RequestListenerStub<WeatherResult>());
    retrofitSpiceRequestStub.await(REQUEST_COMPLETION_TIMEOUT);
    // test
    assertNotNull(retrofitSpiceRequestStub.getService());
}
Also used : WeatherResult(com.octo.android.robospice.retrofit.test.model.WeatherResult) RetrofitSpiceRequestStub(com.octo.android.robospice.retrofit.test.stub.RetrofitSpiceRequestStub)

Example 8 with WeatherResult

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

the class RetrofitJackson2SpiceServiceTest method test_addRequest_injects_request_factory.

public void test_addRequest_injects_request_factory() throws InterruptedException {
    // given
    spiceManager.start(getContext());
    RetrofitSpiceRequestStub retrofitSpiceRequestStub = new RetrofitSpiceRequestStub(WeatherResult.class);
    // when
    spiceManager.execute(retrofitSpiceRequestStub, new RequestListenerStub<WeatherResult>());
    retrofitSpiceRequestStub.await(REQUEST_COMPLETION_TIMEOUT);
    // test
    assertNotNull(retrofitSpiceRequestStub.getService());
}
Also used : WeatherResult(com.octo.android.robospice.retrofit.test.model.WeatherResult) RetrofitSpiceRequestStub(com.octo.android.robospice.retrofit.test.stub.RetrofitSpiceRequestStub)

Example 9 with WeatherResult

use of com.octo.android.robospice.retrofit.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);
    final String fileName = "toto";
    inFileObjectPersister.saveDataToCacheAndReturnData(weatherRequestStatus, fileName);
    // 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.retrofit.test.model.WeatherResult)

Example 10 with WeatherResult

use of com.octo.android.robospice.retrofit.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);
    final String fileName = "toto";
    inFileObjectPersister.saveDataToCacheAndReturnData(weatherRequestStatus, fileName);
    WeatherResult weatherRequestStatus2 = buildWeather(TEST_TEMP2, TEST_TEMP_UNIT);
    final String fileName2 = "tutu";
    inFileObjectPersister.saveDataToCacheAndReturnData(weatherRequestStatus2, fileName2);
    // 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.retrofit.test.model.WeatherResult)

Aggregations

WeatherResult (com.octo.android.robospice.retrofit.test.model.WeatherResult)10 RetrofitSpiceRequestStub (com.octo.android.robospice.retrofit.test.stub.RetrofitSpiceRequestStub)2 Curren_weather (com.octo.android.robospice.retrofit.test.model.Curren_weather)1 Weather (com.octo.android.robospice.retrofit.test.model.Weather)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1