use of org.wikipedia.dataclient.mwapi.MwQueryResponse in project apps-android-wikipedia by wikimedia.
the class GalleryItemClientTest method testRequestSuccessForVideo.
@Test
@SuppressWarnings("checkstyle:magicnumber")
public void testRequestSuccessForVideo() throws Throwable {
enqueueFromFile("gallery_item_video.json");
Callback cb = mock(Callback.class);
Call<MwQueryResponse> call = request(cb, true);
server().takeRequest();
ArgumentCaptor<GalleryItem> captor = ArgumentCaptor.forClass(GalleryItem.class);
// noinspection unchecked
verify(cb).success(eq(call), captor.capture());
// noinspection unchecked
GalleryItem galleryItem = captor.getValue();
assertThat(galleryItem != null, is(true));
assertThat(String.valueOf(galleryItem.getHeight()), is("720"));
assertThat(String.valueOf(galleryItem.getWidth()), is("400"));
assertThat(galleryItem.getThumbUrl(), is("https://upload.wikimedia.org/wikipedia/commons/thumb/e/eb/Wood_cleaving_-_2016.webm/400px--Wood_cleaving_-_2016.webm.jpg"));
assertThat(galleryItem.getMimeType(), is("video/webm"));
assertThat(galleryItem.getUrl(), is("https://upload.wikimedia.org/wikipedia/commons/e/eb/Wood_cleaving_-_2016.webm"));
assertThat(galleryItem.getDerivatives().size(), is(11));
}
use of org.wikipedia.dataclient.mwapi.MwQueryResponse in project apps-android-wikipedia by wikimedia.
the class GalleryItemClientTest method testRequestResponseMalformed.
@Test
public void testRequestResponseMalformed() throws Throwable {
server().enqueue("'");
GalleryItemClient.Callback cb = mock(GalleryItemClient.Callback.class);
Call<MwQueryResponse> call = request(cb, false);
server().takeRequest();
assertCallbackFailure(call, cb, MalformedJsonException.class);
}
use of org.wikipedia.dataclient.mwapi.MwQueryResponse in project apps-android-wikipedia by wikimedia.
the class GalleryItemClientTest method testRequestResponseApiError.
@Test
public void testRequestResponseApiError() throws Throwable {
enqueueFromFile("api_error.json");
GalleryItemClient.Callback cb = mock(GalleryItemClient.Callback.class);
Call<MwQueryResponse> call = request(cb, false);
server().takeRequest();
assertCallbackFailure(call, cb, MwException.class);
}
use of org.wikipedia.dataclient.mwapi.MwQueryResponse in project apps-android-wikipedia by wikimedia.
the class GalleryItemClientTest method testRequestResponseFailure.
@Test
public void testRequestResponseFailure() throws Throwable {
enqueue404();
GalleryItemClient.Callback cb = mock(GalleryItemClient.Callback.class);
Call<MwQueryResponse> call = request(cb, false);
server().takeRequest();
assertCallbackFailure(call, cb, HttpStatusException.class);
}
use of org.wikipedia.dataclient.mwapi.MwQueryResponse in project apps-android-wikipedia by wikimedia.
the class DescriptionClientTest method testRequestSuccess.
@Test
public void testRequestSuccess() throws Throwable {
enqueueFromFile("reading_list_page_info.json");
DescriptionClient.Callback cb = mock(DescriptionClient.Callback.class);
Call<MwQueryResponse> call = request(cb);
server().takeRequest();
ArgumentCaptor<List> captor = ArgumentCaptor.forClass(List.class);
verify(cb).success(eq(call), captor.capture());
List<MwQueryPage> result = captor.getValue();
MwQueryPage biden = result.get(0);
MwQueryPage obama = result.get(1);
assertThat(biden.title(), is("Joe Biden"));
assertThat(biden.description(), is("47th Vice President of the United States"));
assertThat(obama.title(), is("Barack Obama"));
assertThat(obama.description(), is("44th President of the United States of America"));
}
Aggregations