jenkins-bot has submitted this change and it was merged.

Change subject: Hygiene: convert ParcelableTest to JUnit 4
......................................................................


Hygiene: convert ParcelableTest to JUnit 4

Change-Id: I1838c694c92e230a7c07c5a43f62738f3a9f10ac
---
M app/src/androidTest/java/org/wikipedia/test/ParcelableTest.java
1 file changed, 26 insertions(+), 24 deletions(-)

Approvals:
  Mholloway: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/app/src/androidTest/java/org/wikipedia/test/ParcelableTest.java 
b/app/src/androidTest/java/org/wikipedia/test/ParcelableTest.java
index 0abb6cb..759f650 100644
--- a/app/src/androidTest/java/org/wikipedia/test/ParcelableTest.java
+++ b/app/src/androidTest/java/org/wikipedia/test/ParcelableTest.java
@@ -4,9 +4,9 @@
 import android.os.Parcelable;
 import android.support.test.filters.SmallTest;
 
-import junit.framework.TestCase;
 
 import org.json.JSONObject;
+import org.junit.Test;
 import org.wikipedia.ParcelableLruCache;
 import org.wikipedia.dataclient.WikiSite;
 import org.wikipedia.history.HistoryEntry;
@@ -14,41 +14,33 @@
 import org.wikipedia.page.PageTitle;
 import org.wikipedia.pageimages.PageImage;
 
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
 @SmallTest
-public class ParcelableTest extends TestCase {
-
-    private void parcelAndTestObjects(Parcelable p) throws Exception {
-        Parcel parcel = Parcel.obtain();
-        p.writeToParcel(parcel, 0);
-
-        parcel.setDataPosition(0);
-        Parcelable.Creator<?> creator = (Parcelable.Creator<?>) 
p.getClass().getField("CREATOR").get(null);
-        Parcelable newObject = (Parcelable) creator.createFromParcel(parcel);
-        assertEquals(p, newObject);
-    }
-
-    public void testPageTitle() throws Exception {
+public class ParcelableTest {
+    @Test public void testPageTitle() throws Throwable {
         PageTitle title = new PageTitle(null, "Test", 
WikiSite.forLanguageCode("en"));
         parcelAndTestObjects(title);
     }
 
-    public void testPageTitleTalk() throws Exception {
+    @Test public void testPageTitleTalk() throws Throwable {
         WikiSite wiki = WikiSite.forLanguageCode("en");
         PageTitle origTitle = new PageTitle("Talk", "India", wiki);
         parcelAndTestObjects(origTitle);
     }
 
-    public void testWikiSite() throws Exception {
+    @Test public void testWikiSite() throws Throwable {
         WikiSite wiki = WikiSite.forLanguageCode("en");
         parcelAndTestObjects(wiki);
     }
 
-    public void testPageProperties() throws Exception {
+    @Test public void testPageProperties() throws Throwable {
         PageProperties props = new PageProperties(new 
JSONObject("{\"protection\":{\"edit\":[\"autoconfirmed\"],\"move\":[\"sysop\"]},\"id\":15580374,\"displaytitle\":\"Something\",\"revision\":615503846,\"lastmodified\":\"\",\"editable\":false,\"mainpage\":false}"));
         parcelAndTestObjects(props);
     }
 
-    public void testLruCache() throws Exception {
+    @Test public void testLruCache() throws Throwable {
         ParcelableLruCache<WikiSite> oldCache = new ParcelableLruCache<>(2, 
WikiSite.class);
         oldCache.put("english", WikiSite.forLanguageCode("en"));
         oldCache.put("tamil", WikiSite.forLanguageCode("ta"));
@@ -61,13 +53,13 @@
         //noinspection unchecked
         ParcelableLruCache<WikiSite> newCache = (ParcelableLruCache<WikiSite>) 
creator.createFromParcel(parcel);
 
-        assertEquals(newCache.maxSize(), oldCache.maxSize());
-        assertEquals(newCache.size(), oldCache.size());
-        assertEquals(newCache.get("english"), oldCache.get("english"));
-        assertEquals(newCache.get("tamil"), oldCache.get("tamil"));
+        assertThat(newCache.maxSize(), is(oldCache.maxSize()));
+        assertThat(newCache.size(), is(oldCache.size()));
+        assertThat(newCache.get("english"), is(oldCache.get("english")));
+        assertThat(newCache.get("tamil"), is(oldCache.get("tamil")));
     }
 
-    public void testHistoryEntry() throws Exception {
+    @Test public void testHistoryEntry() throws Throwable {
         WikiSite wiki = WikiSite.forLanguageCode("en");
         PageTitle title = new PageTitle("Talk", "India", wiki);
         HistoryEntry historyEntry = new HistoryEntry(title, 
HistoryEntry.SOURCE_EXTERNAL_LINK);
@@ -75,11 +67,21 @@
         parcelAndTestObjects(historyEntry);
     }
 
-    public void testPageImage() throws Exception {
+    @Test public void testPageImage() throws Throwable {
         WikiSite wiki = WikiSite.forLanguageCode("en");
         PageTitle title = new PageTitle("Talk", "India", wiki);
         PageImage pageImage = new PageImage(title, "Testing image");
 
         parcelAndTestObjects(pageImage);
     }
+
+    private void parcelAndTestObjects(Parcelable p) throws Throwable {
+        Parcel parcel = Parcel.obtain();
+        p.writeToParcel(parcel, 0);
+
+        parcel.setDataPosition(0);
+        Parcelable.Creator<?> creator = (Parcelable.Creator<?>) 
p.getClass().getField("CREATOR").get(null);
+        Parcelable newObject = (Parcelable) creator.createFromParcel(parcel);
+        assertThat(p, is(newObject));
+    }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/317098
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I1838c694c92e230a7c07c5a43f62738f3a9f10ac
Gerrit-PatchSet: 2
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Niedzielski <sniedziel...@wikimedia.org>
Gerrit-Reviewer: BearND <bsitzm...@wikimedia.org>
Gerrit-Reviewer: Brion VIBBER <br...@wikimedia.org>
Gerrit-Reviewer: Dbrant <dbr...@wikimedia.org>
Gerrit-Reviewer: Mholloway <mhollo...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to