Search in sources :

Example 1 with Callback

use of org.wikipedia.random.RandomSummaryClient.Callback in project apps-android-wikipedia by wikimedia.

the class RandomSummaryClientTest method testRequestEligible.

@Test
public void testRequestEligible() throws Throwable {
    enqueueFromFile("rb_page_summary_valid.json");
    Callback cb = mock(Callback.class);
    Call<RbPageSummary> call = request(cb);
    server().takeRequest();
    assertCallbackSuccess(call, cb);
}
Also used : Callback(org.wikipedia.random.RandomSummaryClient.Callback) RbPageSummary(org.wikipedia.dataclient.restbase.page.RbPageSummary) Test(org.junit.Test) MockWebServerTest(org.wikipedia.test.MockWebServerTest)

Example 2 with Callback

use of org.wikipedia.random.RandomSummaryClient.Callback in project apps-android-wikipedia by wikimedia.

the class RandomSummaryClientTest method testRequestFailure.

@Test
public void testRequestFailure() throws Throwable {
    enqueue404();
    Callback cb = mock(Callback.class);
    Call<RbPageSummary> call = request(cb);
    server().takeRequest();
    assertCallbackFailure(call, cb, IOException.class);
}
Also used : Callback(org.wikipedia.random.RandomSummaryClient.Callback) RbPageSummary(org.wikipedia.dataclient.restbase.page.RbPageSummary) Test(org.junit.Test) MockWebServerTest(org.wikipedia.test.MockWebServerTest)

Example 3 with Callback

use of org.wikipedia.random.RandomSummaryClient.Callback in project apps-android-wikipedia by wikimedia.

the class RandomSummaryClientTest method testRequestMalformed.

@Test
public void testRequestMalformed() throws Throwable {
    enqueueFromFile("rb_page_summary_malformed.json");
    Callback cb = mock(Callback.class);
    Call<RbPageSummary> call = request(cb);
    server().takeRequest();
    assertCallbackFailure(call, cb, JsonParseException.class);
}
Also used : Callback(org.wikipedia.random.RandomSummaryClient.Callback) RbPageSummary(org.wikipedia.dataclient.restbase.page.RbPageSummary) Test(org.junit.Test) MockWebServerTest(org.wikipedia.test.MockWebServerTest)

Aggregations

Test (org.junit.Test)3 RbPageSummary (org.wikipedia.dataclient.restbase.page.RbPageSummary)3 Callback (org.wikipedia.random.RandomSummaryClient.Callback)3 MockWebServerTest (org.wikipedia.test.MockWebServerTest)3