Niedzielski has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/333455 )
Change subject: Hygiene: rename some MediaWiki action API response types ...................................................................... Hygiene: rename some MediaWiki action API response types • Add MobileView or Query to MediaWiki action API response types to indicate the request type. It's a little verbose but it's easy to understand intended use case • Rename MwApiException to MwException, MwApiResponsePage to MwQueryPage, NearbyPageMwResponse to MwQueryNearbyPage Change-Id: I5f9b150c5a05428476aab1cec12ff2983c494c44 --- M app/src/main/java/org/wikipedia/createaccount/CreateAccountClient.java M app/src/main/java/org/wikipedia/createaccount/CreateAccountInfoClient.java R app/src/main/java/org/wikipedia/dataclient/mwapi/MwException.java R app/src/main/java/org/wikipedia/dataclient/mwapi/MwQueryNearbyPage.java R app/src/main/java/org/wikipedia/dataclient/mwapi/MwQueryPage.java A app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwMobileViewPageCombo.java R app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwMobileViewPageLead.java R app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwMobileViewPageRemaining.java D app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwPageCombo.java M app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwPageService.java R app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwQueryPageSummary.java M app/src/main/java/org/wikipedia/edit/preview/Wikitext.java M app/src/main/java/org/wikipedia/edit/preview/WikitextClient.java M app/src/main/java/org/wikipedia/feed/becauseyouread/BecauseYouReadClient.java M app/src/main/java/org/wikipedia/language/LangLinks.java M app/src/main/java/org/wikipedia/language/LangLinksClient.java M app/src/main/java/org/wikipedia/nearby/Nearby.java M app/src/main/java/org/wikipedia/nearby/NearbyClient.java M app/src/main/java/org/wikipedia/nearby/NearbyPage.java M app/src/main/java/org/wikipedia/search/SearchResult.java M app/src/main/java/org/wikipedia/search/SearchResults.java M app/src/test/java/org/wikipedia/createaccount/CreateAccountClientTest.java M app/src/test/java/org/wikipedia/createaccount/CreateAccountInfoClientTest.java M app/src/test/java/org/wikipedia/dataclient/restbase/RbPageLeadTest.java M app/src/test/java/org/wikipedia/edit/preview/WikitextClientTest.java M app/src/test/java/org/wikipedia/language/LangLinksClientTest.java M app/src/test/java/org/wikipedia/nearby/NearbyClientTest.java M app/src/test/java/org/wikipedia/server/BasePageLeadTest.java R app/src/test/java/org/wikipedia/server/mwapi/MwMobileViewPageLeadTest.java 29 files changed, 100 insertions(+), 100 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/apps/android/wikipedia refs/changes/55/333455/1 diff --git a/app/src/main/java/org/wikipedia/createaccount/CreateAccountClient.java b/app/src/main/java/org/wikipedia/createaccount/CreateAccountClient.java index 45ede87..5bfce24 100644 --- a/app/src/main/java/org/wikipedia/createaccount/CreateAccountClient.java +++ b/app/src/main/java/org/wikipedia/createaccount/CreateAccountClient.java @@ -6,7 +6,7 @@ import org.wikipedia.Constants; import org.wikipedia.dataclient.WikiSite; -import org.wikipedia.dataclient.mwapi.MwApiException; +import org.wikipedia.dataclient.mwapi.MwException; import org.wikipedia.dataclient.retrofit.MwCachedService; import org.wikipedia.dataclient.retrofit.RetrofitException; @@ -56,7 +56,7 @@ cb.failure(call, new CreateAccountException(result.message())); } } else if (response.body().hasError()) { - cb.failure(call, new MwApiException(response.body().getError())); + cb.failure(call, new MwException(response.body().getError())); } else { cb.failure(call, new IOException("An unknown error occurred.")); } diff --git a/app/src/main/java/org/wikipedia/createaccount/CreateAccountInfoClient.java b/app/src/main/java/org/wikipedia/createaccount/CreateAccountInfoClient.java index 7f65b78..2b9021e 100644 --- a/app/src/main/java/org/wikipedia/createaccount/CreateAccountInfoClient.java +++ b/app/src/main/java/org/wikipedia/createaccount/CreateAccountInfoClient.java @@ -4,7 +4,7 @@ import android.support.annotation.VisibleForTesting; import org.wikipedia.dataclient.WikiSite; -import org.wikipedia.dataclient.mwapi.MwApiException; +import org.wikipedia.dataclient.mwapi.MwException; import org.wikipedia.dataclient.mwapi.MwQueryResponse; import org.wikipedia.dataclient.retrofit.MwCachedService; import org.wikipedia.dataclient.retrofit.RetrofitException; @@ -41,7 +41,7 @@ String captchaId = response.body().query().captchaId(); cb.success(call, new CreateAccountInfoResult(token, captchaId)); } else if (response.body().hasError()) { - cb.failure(call, new MwApiException(response.body().getError())); + cb.failure(call, new MwException(response.body().getError())); } else { cb.failure(call, new IOException("An unknown error occurred.")); } diff --git a/app/src/main/java/org/wikipedia/dataclient/mwapi/MwApiException.java b/app/src/main/java/org/wikipedia/dataclient/mwapi/MwException.java similarity index 78% rename from app/src/main/java/org/wikipedia/dataclient/mwapi/MwApiException.java rename to app/src/main/java/org/wikipedia/dataclient/mwapi/MwException.java index 641f892..97fb546 100644 --- a/app/src/main/java/org/wikipedia/dataclient/mwapi/MwApiException.java +++ b/app/src/main/java/org/wikipedia/dataclient/mwapi/MwException.java @@ -3,10 +3,10 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; -public class MwApiException extends RuntimeException { +public class MwException extends RuntimeException { @SuppressWarnings("unused") @NonNull private final MwServiceError error; - public MwApiException(@NonNull MwServiceError error) { + public MwException(@NonNull MwServiceError error) { this.error = error; } diff --git a/app/src/main/java/org/wikipedia/dataclient/mwapi/NearbyPageMwResponse.java b/app/src/main/java/org/wikipedia/dataclient/mwapi/MwQueryNearbyPage.java similarity index 95% rename from app/src/main/java/org/wikipedia/dataclient/mwapi/NearbyPageMwResponse.java rename to app/src/main/java/org/wikipedia/dataclient/mwapi/MwQueryNearbyPage.java index 3433656..455bb93 100644 --- a/app/src/main/java/org/wikipedia/dataclient/mwapi/NearbyPageMwResponse.java +++ b/app/src/main/java/org/wikipedia/dataclient/mwapi/MwQueryNearbyPage.java @@ -8,7 +8,7 @@ import java.util.Collections; import java.util.List; -public class NearbyPageMwResponse extends MwApiResponsePage { +public class MwQueryNearbyPage extends MwQueryPage { @SuppressWarnings("unused") @Nullable private List<Coordinates> coordinates; @Nullable public List<Coordinates> coordinates() { diff --git a/app/src/main/java/org/wikipedia/dataclient/mwapi/MwApiResponsePage.java b/app/src/main/java/org/wikipedia/dataclient/mwapi/MwQueryPage.java similarity index 97% rename from app/src/main/java/org/wikipedia/dataclient/mwapi/MwApiResponsePage.java rename to app/src/main/java/org/wikipedia/dataclient/mwapi/MwQueryPage.java index 265b926..f7ee9d7 100644 --- a/app/src/main/java/org/wikipedia/dataclient/mwapi/MwApiResponsePage.java +++ b/app/src/main/java/org/wikipedia/dataclient/mwapi/MwQueryPage.java @@ -12,7 +12,7 @@ /** * A class representing a standard page object as returned by the MediaWiki API. */ -public class MwApiResponsePage extends BaseModel { +public class MwQueryPage extends BaseModel { @SuppressWarnings("unused") private int pageid; @SuppressWarnings("unused") private int ns; @SuppressWarnings("unused,NullableProblems") @NonNull private String title; diff --git a/app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwMobileViewPageCombo.java b/app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwMobileViewPageCombo.java new file mode 100644 index 0000000..2abaf41 --- /dev/null +++ b/app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwMobileViewPageCombo.java @@ -0,0 +1,11 @@ +package org.wikipedia.dataclient.mwapi.page; + +import org.wikipedia.dataclient.page.PageCombo; + +/** + * Combines MwMobileViewPageLead and MwMobileViewPageRemaining Gson POJOs for mobileview API. + * In mobileview API the implementation is basically the same as MwMobileViewPageLead. + * The class name "Page" was already used, and is very entrenched in this code base. + */ +public class MwMobileViewPageCombo extends MwMobileViewPageLead implements PageCombo { +} diff --git a/app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwPageLead.java b/app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwMobileViewPageLead.java similarity index 99% rename from app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwPageLead.java rename to app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwMobileViewPageLead.java index e4a1ae6..2da5c2f 100644 --- a/app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwPageLead.java +++ b/app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwMobileViewPageLead.java @@ -25,7 +25,7 @@ /** * Gson POJO for loading the first stage of page content. */ -public class MwPageLead implements PageLead { +public class MwMobileViewPageLead implements PageLead { @SuppressWarnings("unused") private MwServiceError error; @SuppressWarnings("unused") private Mobileview mobileview; diff --git a/app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwPageRemaining.java b/app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwMobileViewPageRemaining.java similarity index 93% rename from app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwPageRemaining.java rename to app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwMobileViewPageRemaining.java index 6573824..70ad9dc 100644 --- a/app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwPageRemaining.java +++ b/app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwMobileViewPageRemaining.java @@ -12,7 +12,7 @@ /** * Gson POJO for loading remaining page content. */ -public class MwPageRemaining implements PageRemaining { +public class MwMobileViewPageRemaining implements PageRemaining { @SuppressWarnings("unused") @Nullable private Mobileview mobileview; @Override diff --git a/app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwPageCombo.java b/app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwPageCombo.java deleted file mode 100644 index 0b301ef..0000000 --- a/app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwPageCombo.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.wikipedia.dataclient.mwapi.page; - -import org.wikipedia.dataclient.page.PageCombo; - -/** - * Combines MwPageLead and MwPageRemaining Gson POJOs for mobileview API. - * In mobileview API the implementation is basically the same as MwPageLead. - * The class name "Page" was already used, and is very entrenched in this code base. - */ -public class MwPageCombo extends MwPageLead implements PageCombo { -} diff --git a/app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwPageService.java b/app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwPageService.java index e4032a6..dd6f506 100644 --- a/app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwPageService.java +++ b/app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwPageService.java @@ -39,8 +39,8 @@ @Override public void pageSummary(String title, final PageSummary.Callback cb) { - Call<MwPageSummary> call = service.pageSummary(title); - call.enqueue(new Callback<MwPageSummary>() { + Call<MwQueryPageSummary> call = service.pageSummary(title); + call.enqueue(new Callback<MwQueryPageSummary>() { /** * Invoked for a received HTTP response. * <p/> @@ -48,7 +48,7 @@ * Call {@link Response#isSuccessful()} to determine if the response indicates success. */ @Override - public void onResponse(Call<MwPageSummary> call, Response<MwPageSummary> response) { + public void onResponse(Call<MwQueryPageSummary> call, Response<MwQueryPageSummary> response) { if (response.isSuccessful()) { responseHeaderHandler.onHeaderCheck(response); cb.success(response.body()); @@ -62,7 +62,7 @@ * exception occurred creating the request or processing the response. */ @Override - public void onFailure(Call<MwPageSummary> call, Throwable t) { + public void onFailure(Call<MwQueryPageSummary> call, Throwable t) { cb.failure(t); } }); @@ -71,10 +71,10 @@ @Override public void pageLead(String title, int leadImageThumbWidth, boolean noImages, final PageLead.Callback cb) { - Call<MwPageLead> call = service.pageLead(title, leadImageThumbWidth, optional(noImages)); - call.enqueue(new Callback<MwPageLead>() { + Call<MwMobileViewPageLead> call = service.pageLead(title, leadImageThumbWidth, optional(noImages)); + call.enqueue(new Callback<MwMobileViewPageLead>() { @Override - public void onResponse(Call<MwPageLead> call, Response<MwPageLead> response) { + public void onResponse(Call<MwMobileViewPageLead> call, Response<MwMobileViewPageLead> response) { if (response.isSuccessful()) { responseHeaderHandler.onHeaderCheck(response); cb.success(response.body()); @@ -84,7 +84,7 @@ } @Override - public void onFailure(Call<MwPageLead> call, Throwable t) { + public void onFailure(Call<MwMobileViewPageLead> call, Throwable t) { cb.failure(t); } }); @@ -92,10 +92,10 @@ @Override public void pageRemaining(String title, boolean noImages, final PageRemaining.Callback cb) { - Call<MwPageRemaining> call = service.pageRemaining(title, optional(noImages)); - call.enqueue(new Callback<MwPageRemaining>() { + Call<MwMobileViewPageRemaining> call = service.pageRemaining(title, optional(noImages)); + call.enqueue(new Callback<MwMobileViewPageRemaining>() { @Override - public void onResponse(Call<MwPageRemaining> call, Response<MwPageRemaining> response) { + public void onResponse(Call<MwMobileViewPageRemaining> call, Response<MwMobileViewPageRemaining> response) { if (response.isSuccessful()) { RbSwitch.INSTANCE.onMwSuccess(); cb.success(response.body()); @@ -105,15 +105,15 @@ } @Override - public void onFailure(Call<MwPageRemaining> call, Throwable t) { + public void onFailure(Call<MwMobileViewPageRemaining> call, Throwable t) { cb.failure(t); } }); } @Override - public MwPageCombo pageCombo(String title, boolean noImages) throws IOException { - Response<MwPageCombo> rsp = service.pageCombo(title, optional(noImages)).execute(); + public MwMobileViewPageCombo pageCombo(String title, boolean noImages) throws IOException { + Response<MwMobileViewPageCombo> rsp = service.pageCombo(title, optional(noImages)).execute(); if (rsp.isSuccessful() && !rsp.body().hasError()) { return rsp.body(); } @@ -143,7 +143,7 @@ * Gets the lead section and initial metadata of a given title. * * @param title the page title with prefix if necessary - * @return a Retrofit Call which provides the populated MwPageLead object in #success + * @return a Retrofit Call which provides the populated MwMobileViewPageLead object in #success */ /* Here's the rationale for this API call: @@ -162,7 +162,7 @@ @GET("w/api.php?action=query&format=json&formatversion=2&prop=extracts%7Cpageimages" + "&redirects=true&exsentences=5&explaintext=true&piprop=thumbnail%7Cname" + "&pithumbsize=" + Constants.PREFERRED_THUMB_SIZE) - Call<MwPageSummary> pageSummary(@Query("titles") String title); + Call<MwQueryPageSummary> pageSummary(@Query("titles") String title); /** * Gets the lead section and initial metadata of a given title. @@ -177,9 +177,9 @@ + "%7Cdescription%7Clastmodified%7Cnormalizedtitle%7Cdisplaytitle%7Cprotection" + "%7Ceditable%7Cpageprops&pageprops=wikibase_item&onlyrequestedsections=1" + "§ions=0§ionprop=toclevel%7Cline%7Canchor&noheadings=true") - Call<MwPageLead> pageLead(@Query("page") String title, - @Query("thumbsize") int leadImageThumbWidth, - @Query("noimages") Boolean noImages); + Call<MwMobileViewPageLead> pageLead(@Query("page") String title, + @Query("thumbsize") int leadImageThumbWidth, + @Query("noimages") Boolean noImages); /** * Gets the remaining sections of a given title. @@ -190,8 +190,8 @@ @GET("w/api.php?action=mobileview&format=json&prop=" + "text%7Csections&onlyrequestedsections=1§ions=1-" + "§ionprop=toclevel%7Cline%7Canchor&noheadings=true") - Call<MwPageRemaining> pageRemaining(@Query("page") String title, - @Query("noimages") Boolean noImages); + Call<MwMobileViewPageRemaining> pageRemaining(@Query("page") String title, + @Query("noimages") Boolean noImages); /** * Gets all page content of a given title -- for refreshing a saved page @@ -205,7 +205,7 @@ + "%7Clastmodified%7Cnormalizedtitle%7Cdisplaytitle%7Cprotection%7Ceditable" + "%7Cpageprops&pageprops=wikibase_item&onlyrequestedsections=1§ions=all" + "§ionprop=toclevel%7Cline%7Canchor&noheadings=true") - Call<MwPageCombo> pageCombo(@Query("page") String title, - @Query("noimages") Boolean noImages); + Call<MwMobileViewPageCombo> pageCombo(@Query("page") String title, + @Query("noimages") Boolean noImages); } } diff --git a/app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwPageSummary.java b/app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwQueryPageSummary.java similarity index 97% rename from app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwPageSummary.java rename to app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwQueryPageSummary.java index 79fea94..265d85a 100644 --- a/app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwPageSummary.java +++ b/app/src/main/java/org/wikipedia/dataclient/mwapi/page/MwQueryPageSummary.java @@ -9,7 +9,7 @@ /** * Useful for link previews coming from MW API. */ -public class MwPageSummary implements PageSummary { +public class MwQueryPageSummary implements PageSummary { @SuppressWarnings("unused") private MwServiceError error; @SuppressWarnings("unused") @Nullable private MwQuery query; diff --git a/app/src/main/java/org/wikipedia/edit/preview/Wikitext.java b/app/src/main/java/org/wikipedia/edit/preview/Wikitext.java index ed3afa0..53dd32f 100644 --- a/app/src/main/java/org/wikipedia/edit/preview/Wikitext.java +++ b/app/src/main/java/org/wikipedia/edit/preview/Wikitext.java @@ -2,7 +2,7 @@ import android.support.annotation.Nullable; -import org.wikipedia.dataclient.mwapi.MwApiResponsePage; +import org.wikipedia.dataclient.mwapi.MwQueryPage; import org.wikipedia.model.BaseModel; import java.util.Iterator; @@ -10,14 +10,14 @@ public class Wikitext extends BaseModel { @SuppressWarnings("unused,NullableProblems,MismatchedQueryAndUpdateOfCollection") @Nullable - private Map<String, MwApiResponsePage> pages; + private Map<String, MwQueryPage> pages; @Nullable String wikitext() { if (pages == null) { return null; } - Iterator<Map.Entry<String, MwApiResponsePage>> i = pages.entrySet().iterator(); - MwApiResponsePage page = i.next().getValue(); + Iterator<Map.Entry<String, MwQueryPage>> i = pages.entrySet().iterator(); + MwQueryPage page = i.next().getValue(); if (page == null || page.revisions() == null || page.revisions().get(0) == null) { diff --git a/app/src/main/java/org/wikipedia/edit/preview/WikitextClient.java b/app/src/main/java/org/wikipedia/edit/preview/WikitextClient.java index b8880b7..2ce1120 100644 --- a/app/src/main/java/org/wikipedia/edit/preview/WikitextClient.java +++ b/app/src/main/java/org/wikipedia/edit/preview/WikitextClient.java @@ -7,7 +7,7 @@ import com.google.gson.JsonParseException; import org.wikipedia.dataclient.WikiSite; -import org.wikipedia.dataclient.mwapi.MwApiException; +import org.wikipedia.dataclient.mwapi.MwException; import org.wikipedia.dataclient.mwapi.MwQueryResponse; import org.wikipedia.dataclient.retrofit.MwCachedService; import org.wikipedia.dataclient.retrofit.RetrofitException; @@ -35,7 +35,7 @@ public void onResponse(Call<MwQueryResponse<Wikitext>> call, Response<MwQueryResponse<Wikitext>> response) { if (response.isSuccessful()) { if (response.body().hasError()) { - cb.failure(call, new MwApiException(response.body().getError())); + cb.failure(call, new MwException(response.body().getError())); return; } else if (response.body().query().wikitext() == null) { Throwable t = new JsonParseException("Error parsing wikitext from query response"); diff --git a/app/src/main/java/org/wikipedia/feed/becauseyouread/BecauseYouReadClient.java b/app/src/main/java/org/wikipedia/feed/becauseyouread/BecauseYouReadClient.java index 60eaf69..532c2e6 100644 --- a/app/src/main/java/org/wikipedia/feed/becauseyouread/BecauseYouReadClient.java +++ b/app/src/main/java/org/wikipedia/feed/becauseyouread/BecauseYouReadClient.java @@ -9,8 +9,8 @@ import org.wikipedia.Constants; import org.wikipedia.WikipediaApp; import org.wikipedia.dataclient.WikiSite; -import org.wikipedia.dataclient.mwapi.MwApiException; -import org.wikipedia.dataclient.mwapi.MwApiResponsePage; +import org.wikipedia.dataclient.mwapi.MwException; +import org.wikipedia.dataclient.mwapi.MwQueryPage; import org.wikipedia.dataclient.mwapi.MwQueryResponse; import org.wikipedia.dataclient.retrofit.MwCachedService; import org.wikipedia.dataclient.retrofit.RetrofitException; @@ -100,7 +100,7 @@ } cb.success(Collections.singletonList((Card) new BecauseYouReadCard(entry, itemCards))); } else if (pages.hasError()) { - cb.error(new MwApiException(pages.getError())); + cb.error(new MwException(pages.getError())); } else { cb.error(new IOException("Error fetching suggestions.")); } @@ -119,7 +119,7 @@ static class Pages { @SuppressWarnings("unused") @SerializedName("pages") - private List<MwApiResponsePage> pages; + private List<MwQueryPage> pages; public SearchResults results(WikiSite wiki) { return new SearchResults(pages, wiki); } diff --git a/app/src/main/java/org/wikipedia/language/LangLinks.java b/app/src/main/java/org/wikipedia/language/LangLinks.java index c1950ba..c06f520 100644 --- a/app/src/main/java/org/wikipedia/language/LangLinks.java +++ b/app/src/main/java/org/wikipedia/language/LangLinks.java @@ -4,7 +4,7 @@ import android.support.annotation.Nullable; import org.wikipedia.dataclient.WikiSite; -import org.wikipedia.dataclient.mwapi.MwApiResponsePage; +import org.wikipedia.dataclient.mwapi.MwQueryPage; import org.wikipedia.page.PageTitle; import java.util.ArrayList; @@ -13,19 +13,19 @@ import java.util.Map; class LangLinks { - @SuppressWarnings("unused") @Nullable private Map<String, MwApiResponsePage> pages; + @SuppressWarnings("unused") @Nullable private Map<String, MwQueryPage> pages; @NonNull List<PageTitle> langLinks() { List<PageTitle> result = new ArrayList<>(); if (pages == null) { return result; } - Iterator<Map.Entry<String, MwApiResponsePage>> i = pages.entrySet().iterator(); - MwApiResponsePage page = i.next().getValue(); + Iterator<Map.Entry<String, MwQueryPage>> i = pages.entrySet().iterator(); + MwQueryPage page = i.next().getValue(); if (page.langLinks() == null) { return result; } - for (MwApiResponsePage.LangLink langLink : page.langLinks()) { + for (MwQueryPage.LangLink langLink : page.langLinks()) { result.add(new PageTitle(langLink.localizedTitle(), WikiSite.forLanguageCode(langLink.lang()))); } return result; diff --git a/app/src/main/java/org/wikipedia/language/LangLinksClient.java b/app/src/main/java/org/wikipedia/language/LangLinksClient.java index d9af06f..3a8f4c1 100644 --- a/app/src/main/java/org/wikipedia/language/LangLinksClient.java +++ b/app/src/main/java/org/wikipedia/language/LangLinksClient.java @@ -4,7 +4,7 @@ import android.support.annotation.VisibleForTesting; import org.wikipedia.dataclient.WikiSite; -import org.wikipedia.dataclient.mwapi.MwApiException; +import org.wikipedia.dataclient.mwapi.MwException; import org.wikipedia.dataclient.mwapi.MwQueryResponse; import org.wikipedia.dataclient.retrofit.MwCachedService; import org.wikipedia.dataclient.retrofit.RetrofitException; @@ -45,7 +45,7 @@ cb.success(call, response.body().query().langLinks()); } else if (response.body().hasError()) { String errorTitle = response.body().getError().getTitle(); - cb.failure(call, new MwApiException(response.body().getError())); + cb.failure(call, new MwException(response.body().getError())); L.e("API error fetching langlinks: " + errorTitle); } else { cb.failure(call, new IOException("An unknown error occurred.")); diff --git a/app/src/main/java/org/wikipedia/nearby/Nearby.java b/app/src/main/java/org/wikipedia/nearby/Nearby.java index 795b5c5..c03b794 100644 --- a/app/src/main/java/org/wikipedia/nearby/Nearby.java +++ b/app/src/main/java/org/wikipedia/nearby/Nearby.java @@ -3,14 +3,14 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import org.wikipedia.dataclient.mwapi.NearbyPageMwResponse; +import org.wikipedia.dataclient.mwapi.MwQueryNearbyPage; import java.util.ArrayList; import java.util.List; import java.util.Map; class Nearby { - @SuppressWarnings("unused") @Nullable private Map<String, NearbyPageMwResponse> pages; + @SuppressWarnings("unused") @Nullable private Map<String, MwQueryNearbyPage> pages; @NonNull List<NearbyPage> list() { List<NearbyPage> result = new ArrayList<>(); @@ -19,7 +19,7 @@ return result; } - for (Map.Entry<String, NearbyPageMwResponse> entry : pages.entrySet()) { + for (Map.Entry<String, MwQueryNearbyPage> entry : pages.entrySet()) { NearbyPage page = new NearbyPage(entry.getValue()); if (page.getLocation() != null) { result.add(page); diff --git a/app/src/main/java/org/wikipedia/nearby/NearbyClient.java b/app/src/main/java/org/wikipedia/nearby/NearbyClient.java index 57cb69d..19dbb9f 100644 --- a/app/src/main/java/org/wikipedia/nearby/NearbyClient.java +++ b/app/src/main/java/org/wikipedia/nearby/NearbyClient.java @@ -5,7 +5,7 @@ import org.wikipedia.Constants; import org.wikipedia.dataclient.WikiSite; -import org.wikipedia.dataclient.mwapi.MwApiException; +import org.wikipedia.dataclient.mwapi.MwException; import org.wikipedia.dataclient.mwapi.MwQueryResponse; import org.wikipedia.dataclient.retrofit.MwCachedService; import org.wikipedia.dataclient.retrofit.RetrofitException; @@ -53,7 +53,7 @@ if (response.body().success()) { cb.success(call, new NearbyResult(response.body().query().list())); } else if (response.body().hasError()) { - cb.failure(call, new MwApiException(response.body().getError())); + cb.failure(call, new MwException(response.body().getError())); } else { cb.success(call, new NearbyResult(new ArrayList<NearbyPage>())); } diff --git a/app/src/main/java/org/wikipedia/nearby/NearbyPage.java b/app/src/main/java/org/wikipedia/nearby/NearbyPage.java index 7203692..0af8582 100644 --- a/app/src/main/java/org/wikipedia/nearby/NearbyPage.java +++ b/app/src/main/java/org/wikipedia/nearby/NearbyPage.java @@ -5,7 +5,7 @@ import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; -import org.wikipedia.dataclient.mwapi.NearbyPageMwResponse; +import org.wikipedia.dataclient.mwapi.MwQueryNearbyPage; import java.util.List; @@ -17,10 +17,10 @@ /** calculated externally */ private int distance; - NearbyPage(@NonNull NearbyPageMwResponse page) { + NearbyPage(@NonNull MwQueryNearbyPage page) { title = page.title(); thumbUrl = page.thumbUrl(); - List<NearbyPageMwResponse.Coordinates> coordinates = page.coordinates(); + List<MwQueryNearbyPage.Coordinates> coordinates = page.coordinates(); if (coordinates != null && !coordinates.isEmpty()) { location = new Location(title); location.setLatitude(page.coordinates().get(0).lat()); diff --git a/app/src/main/java/org/wikipedia/search/SearchResult.java b/app/src/main/java/org/wikipedia/search/SearchResult.java index 91a1c5a..0389d48 100644 --- a/app/src/main/java/org/wikipedia/search/SearchResult.java +++ b/app/src/main/java/org/wikipedia/search/SearchResult.java @@ -7,14 +7,14 @@ import android.text.TextUtils; import org.wikipedia.dataclient.WikiSite; -import org.wikipedia.dataclient.mwapi.MwApiResponsePage; +import org.wikipedia.dataclient.mwapi.MwQueryPage; import org.wikipedia.page.PageTitle; public class SearchResult implements Parcelable { private PageTitle pageTitle; private final String redirectFrom; - public SearchResult(@NonNull MwApiResponsePage page, @NonNull WikiSite wiki) { + public SearchResult(@NonNull MwQueryPage page, @NonNull WikiSite wiki) { this(new PageTitle(page.title(), wiki, page.thumbUrl(), page.description())); } diff --git a/app/src/main/java/org/wikipedia/search/SearchResults.java b/app/src/main/java/org/wikipedia/search/SearchResults.java index 1982c4a..1efa115 100644 --- a/app/src/main/java/org/wikipedia/search/SearchResults.java +++ b/app/src/main/java/org/wikipedia/search/SearchResults.java @@ -4,7 +4,7 @@ import org.wikipedia.Constants; import org.wikipedia.dataclient.WikiSite; -import org.wikipedia.dataclient.mwapi.MwApiResponsePage; +import org.wikipedia.dataclient.mwapi.MwQueryPage; import org.wikipedia.page.PageTitle; import org.wikipedia.util.ReleaseUtil; import org.wikipedia.util.log.L; @@ -32,9 +32,9 @@ /** * Constructor for a list of Retrofit results from BecauseYouReadTask. */ - public SearchResults(List<MwApiResponsePage> pages, WikiSite wiki) { + public SearchResults(List<MwQueryPage> pages, WikiSite wiki) { List<SearchResult> searchResults = new ArrayList<>(); - for (MwApiResponsePage page : pages) { + for (MwQueryPage page : pages) { searchResults.add(new SearchResult(page, wiki)); } this.results = searchResults; diff --git a/app/src/test/java/org/wikipedia/createaccount/CreateAccountClientTest.java b/app/src/test/java/org/wikipedia/createaccount/CreateAccountClientTest.java index d8dbb31..7c79e6d 100644 --- a/app/src/test/java/org/wikipedia/createaccount/CreateAccountClientTest.java +++ b/app/src/test/java/org/wikipedia/createaccount/CreateAccountClientTest.java @@ -5,7 +5,7 @@ import com.google.gson.stream.MalformedJsonException; import org.junit.Test; -import org.wikipedia.dataclient.mwapi.MwApiException; +import org.wikipedia.dataclient.mwapi.MwException; import org.wikipedia.dataclient.retrofit.RetrofitException; import org.wikipedia.test.MockWebServerTest; @@ -48,7 +48,7 @@ Call<CreateAccountResponse> call = request(cb); server().takeRequest(); - assertCallbackFailure(call, cb, MwApiException.class); + assertCallbackFailure(call, cb, MwException.class); } @Test public void testRequestResponse404() throws Throwable { diff --git a/app/src/test/java/org/wikipedia/createaccount/CreateAccountInfoClientTest.java b/app/src/test/java/org/wikipedia/createaccount/CreateAccountInfoClientTest.java index b803ea0..6d2773e 100644 --- a/app/src/test/java/org/wikipedia/createaccount/CreateAccountInfoClientTest.java +++ b/app/src/test/java/org/wikipedia/createaccount/CreateAccountInfoClientTest.java @@ -5,7 +5,7 @@ import com.google.gson.stream.MalformedJsonException; import org.junit.Test; -import org.wikipedia.dataclient.mwapi.MwApiException; +import org.wikipedia.dataclient.mwapi.MwException; import org.wikipedia.dataclient.mwapi.MwQueryResponse; import org.wikipedia.dataclient.retrofit.RetrofitException; import org.wikipedia.test.MockWebServerTest; @@ -39,7 +39,7 @@ Call<MwQueryResponse<CreateAccountInfo>> call = request(cb); server().takeRequest(); - assertCallbackFailure(call, cb, MwApiException.class); + assertCallbackFailure(call, cb, MwException.class); } @Test public void testRequestResponse404() throws Throwable { diff --git a/app/src/test/java/org/wikipedia/dataclient/restbase/RbPageLeadTest.java b/app/src/test/java/org/wikipedia/dataclient/restbase/RbPageLeadTest.java index 7fcdcb5..89aab23 100644 --- a/app/src/test/java/org/wikipedia/dataclient/restbase/RbPageLeadTest.java +++ b/app/src/test/java/org/wikipedia/dataclient/restbase/RbPageLeadTest.java @@ -2,7 +2,7 @@ import org.junit.Test; import org.junit.runner.RunWith; -import org.wikipedia.dataclient.mwapi.page.MwPageLead; +import org.wikipedia.dataclient.mwapi.page.MwMobileViewPageLead; import org.wikipedia.dataclient.restbase.page.RbPageLead; import org.wikipedia.server.BasePageLeadTest; import org.wikipedia.test.TestRunner; @@ -42,8 +42,8 @@ */ @Test public void testError() throws Exception { - MwPageLead pageLead = unmarshal(MwPageLead.class, getErrorJson()); - MwPageLead.Mobileview props = pageLead.getMobileview(); + MwMobileViewPageLead pageLead = unmarshal(MwMobileViewPageLead.class, getErrorJson()); + MwMobileViewPageLead.Mobileview props = pageLead.getMobileview(); verifyError(pageLead, props); } } diff --git a/app/src/test/java/org/wikipedia/edit/preview/WikitextClientTest.java b/app/src/test/java/org/wikipedia/edit/preview/WikitextClientTest.java index 6a4f136..cc525e1 100644 --- a/app/src/test/java/org/wikipedia/edit/preview/WikitextClientTest.java +++ b/app/src/test/java/org/wikipedia/edit/preview/WikitextClientTest.java @@ -6,7 +6,7 @@ import org.junit.Test; import org.wikipedia.dataclient.WikiSite; -import org.wikipedia.dataclient.mwapi.MwApiException; +import org.wikipedia.dataclient.mwapi.MwException; import org.wikipedia.dataclient.mwapi.MwQueryResponse; import org.wikipedia.dataclient.retrofit.RetrofitException; import org.wikipedia.page.PageTitle; @@ -43,7 +43,7 @@ Call<MwQueryResponse<Wikitext>> call = request(cb); server().takeRequest(); - assertCallbackFailure(call, cb, MwApiException.class); + assertCallbackFailure(call, cb, MwException.class); } @Test public void testRequestResponse404() throws Throwable { diff --git a/app/src/test/java/org/wikipedia/language/LangLinksClientTest.java b/app/src/test/java/org/wikipedia/language/LangLinksClientTest.java index 51a98e1..2ff3481 100644 --- a/app/src/test/java/org/wikipedia/language/LangLinksClientTest.java +++ b/app/src/test/java/org/wikipedia/language/LangLinksClientTest.java @@ -6,7 +6,7 @@ import org.junit.Test; import org.wikipedia.dataclient.WikiSite; -import org.wikipedia.dataclient.mwapi.MwApiException; +import org.wikipedia.dataclient.mwapi.MwException; import org.wikipedia.dataclient.mwapi.MwQueryResponse; import org.wikipedia.dataclient.retrofit.RetrofitException; import org.wikipedia.page.PageTitle; @@ -56,7 +56,7 @@ Call<MwQueryResponse<LangLinks>> call = request(cb); server().takeRequest(); - assertCallbackFailure(call, cb, MwApiException.class); + assertCallbackFailure(call, cb, MwException.class); } @Test public void testRequestResponseFailure() throws Throwable { diff --git a/app/src/test/java/org/wikipedia/nearby/NearbyClientTest.java b/app/src/test/java/org/wikipedia/nearby/NearbyClientTest.java index 3f40fec..067e9b9 100644 --- a/app/src/test/java/org/wikipedia/nearby/NearbyClientTest.java +++ b/app/src/test/java/org/wikipedia/nearby/NearbyClientTest.java @@ -6,7 +6,7 @@ import org.junit.Test; import org.mockito.ArgumentCaptor; -import org.wikipedia.dataclient.mwapi.MwApiException; +import org.wikipedia.dataclient.mwapi.MwException; import org.wikipedia.dataclient.mwapi.MwQueryResponse; import org.wikipedia.dataclient.retrofit.RetrofitException; import org.wikipedia.test.MockWebServerTest; @@ -101,7 +101,7 @@ Call<MwQueryResponse<Nearby>> call = request(cb); server().takeRequest(); - assertCallbackFailure(call, cb, MwApiException.class); + assertCallbackFailure(call, cb, MwException.class); } @Test public void testRequestResponseFailure() throws Throwable { diff --git a/app/src/test/java/org/wikipedia/server/BasePageLeadTest.java b/app/src/test/java/org/wikipedia/server/BasePageLeadTest.java index d96974d..7b3633e 100644 --- a/app/src/test/java/org/wikipedia/server/BasePageLeadTest.java +++ b/app/src/test/java/org/wikipedia/server/BasePageLeadTest.java @@ -3,7 +3,7 @@ import android.support.annotation.NonNull; import org.wikipedia.dataclient.mwapi.MwServiceError; -import org.wikipedia.dataclient.mwapi.page.MwPageLead; +import org.wikipedia.dataclient.mwapi.page.MwMobileViewPageLead; import org.wikipedia.dataclient.page.PageLeadProperties; import static org.hamcrest.CoreMatchers.equalTo; @@ -95,7 +95,7 @@ + "}}"; } - protected void verifyError(MwPageLead pageLead, MwPageLead.Mobileview mv) { + protected void verifyError(MwMobileViewPageLead pageLead, MwMobileViewPageLead.Mobileview mv) { assertThat(mv, equalTo(null)); MwServiceError error = pageLead.getError(); assertThat(pageLead.hasError(), is(true)); diff --git a/app/src/test/java/org/wikipedia/server/mwapi/MwPageLeadTest.java b/app/src/test/java/org/wikipedia/server/mwapi/MwMobileViewPageLeadTest.java similarity index 63% rename from app/src/test/java/org/wikipedia/server/mwapi/MwPageLeadTest.java rename to app/src/test/java/org/wikipedia/server/mwapi/MwMobileViewPageLeadTest.java index 9b87ecb..381e94a 100644 --- a/app/src/test/java/org/wikipedia/server/mwapi/MwPageLeadTest.java +++ b/app/src/test/java/org/wikipedia/server/mwapi/MwMobileViewPageLeadTest.java @@ -2,7 +2,7 @@ import org.junit.Test; import org.junit.runner.RunWith; -import org.wikipedia.dataclient.mwapi.page.MwPageLead; +import org.wikipedia.dataclient.mwapi.page.MwMobileViewPageLead; import org.wikipedia.server.BasePageLeadTest; import org.wikipedia.test.TestRunner; @@ -13,24 +13,24 @@ * Note the ApiService uses formatversion=2 for requests which return booleans in the responses. */ @RunWith(TestRunner.class) -public class MwPageLeadTest extends BasePageLeadTest { +public class MwMobileViewPageLeadTest extends BasePageLeadTest { private String wrapInMobileview(String json) { return "{\"mobileview\":" + json + "}"; } @Test public void testEnglishMainPage() throws Exception { - MwPageLead pageLead = unmarshal(MwPageLead.class, wrapInMobileview(getEnglishMainPageJson())); - MwPageLead.Mobileview props = pageLead.getMobileview(); + MwMobileViewPageLead pageLead = unmarshal(MwMobileViewPageLead.class, wrapInMobileview(getEnglishMainPageJson())); + MwMobileViewPageLead.Mobileview props = pageLead.getMobileview(); verifyEnglishMainPage(props); } @Test public void testUnprotectedDisambiguationPage() throws Exception { - MwPageLead pageLead = unmarshal(MwPageLead.class, + MwMobileViewPageLead pageLead = unmarshal(MwMobileViewPageLead.class, wrapInMobileview(getUnprotectedDisambiguationPageJson())); - MwPageLead.Mobileview props = pageLead.getMobileview(); + MwMobileViewPageLead.Mobileview props = pageLead.getMobileview(); verifyUnprotectedDisambiguationPage(props); } @@ -40,9 +40,9 @@ */ @Test public void testProtectedButNoEditProtectionPage() throws Exception { - MwPageLead pageLead = unmarshal(MwPageLead.class, + MwMobileViewPageLead pageLead = unmarshal(MwMobileViewPageLead.class, wrapInMobileview(getProtectedButNoEditProtectionPageJson())); - MwPageLead.Mobileview props = pageLead.getMobileview(); + MwMobileViewPageLead.Mobileview props = pageLead.getMobileview(); verifyProtectedNoEditProtectionPage(props); } @@ -51,8 +51,8 @@ */ @Test public void testError() throws Exception { - MwPageLead pageLead = unmarshal(MwPageLead.class, getErrorJson()); - MwPageLead.Mobileview props = pageLead.getMobileview(); + MwMobileViewPageLead pageLead = unmarshal(MwMobileViewPageLead.class, getErrorJson()); + MwMobileViewPageLead.Mobileview props = pageLead.getMobileview(); verifyError(pageLead, props); } } \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/333455 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5f9b150c5a05428476aab1cec12ff2983c494c44 Gerrit-PatchSet: 1 Gerrit-Project: apps/android/wikipedia Gerrit-Branch: master Gerrit-Owner: Niedzielski <sniedziel...@wikimedia.org> Gerrit-Reviewer: Sniedzielski <sniedziel...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits