jenkins-bot has submitted this change and it was merged. Change subject: Hygiene: consolidate PageTests into PageTest ......................................................................
Hygiene: consolidate PageTests into PageTest Move PageTests into PageTest and convert to plain JUnit. Change-Id: Ia1cfbd35e8bd05c5f2e083ccba82145947c870ed --- D app/src/androidTest/java/org/wikipedia/page/PageTests.java M app/src/test/java/org/wikipedia/page/PageTest.java 2 files changed, 27 insertions(+), 47 deletions(-) Approvals: Mholloway: Looks good to me, approved jenkins-bot: Verified diff --git a/app/src/androidTest/java/org/wikipedia/page/PageTests.java b/app/src/androidTest/java/org/wikipedia/page/PageTests.java deleted file mode 100644 index a6e1ec5..0000000 --- a/app/src/androidTest/java/org/wikipedia/page/PageTests.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.wikipedia.page; - -import android.support.test.filters.SmallTest; - -import junit.framework.TestCase; - -import org.json.JSONObject; -import org.wikipedia.dataclient.WikiSite; - -import java.util.ArrayList; -import java.util.List; - -@SmallTest -public class PageTests extends TestCase { - - private static final int NUM_SECTIONS = 10; - - public void testJSONSerialization() throws Exception { - List<Section> sections = new ArrayList<>(); - Section headSection = new Section(0, 1, null, null, "Hi there!"); - sections.add(headSection); - for (int i = 1; i <= NUM_SECTIONS; i++) { - sections.add(new Section(i, 1, "Something " + i, "Something_" + i, "Content Something" + i)); - } - PageTitle title = new PageTitle(null, "Test", WikiSite.forLanguageCode("en")); - PageProperties props = new PageProperties(new JSONObject("{\"id\":15580374,\"displaytitle\":\"Test\",\"revision\":615503846,\"lastmodified\":\"2001-02-03T04:00:00Z\",\"editable\":true,\"mainpage\":true}")); - Page page = new Page(title, sections, props); - assertEquals(page, new Page(page.toJSON())); - } -} diff --git a/app/src/test/java/org/wikipedia/page/PageTest.java b/app/src/test/java/org/wikipedia/page/PageTest.java index 29afdb9..27d4169 100644 --- a/app/src/test/java/org/wikipedia/page/PageTest.java +++ b/app/src/test/java/org/wikipedia/page/PageTest.java @@ -1,15 +1,14 @@ package org.wikipedia.page; +import org.json.JSONObject; +import org.junit.Test; +import org.junit.runner.RunWith; import org.wikipedia.dataclient.WikiSite; import org.wikipedia.server.BasePageLeadTest; import org.wikipedia.test.TestRunner; -import org.json.JSONObject; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - import java.util.ArrayList; +import java.util.List; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; @@ -19,17 +18,11 @@ public class PageTest { private static final WikiSite WIKI = WikiSite.forLanguageCode("en"); - private PageTitle title; - private PageProperties props; - - @Before - public void setUp() throws Exception { - title = new PageTitle("Main page", WIKI, "//foo/thumb.jpg"); - props = new PageProperties(new JSONObject(BasePageLeadTest.getEnglishMainPageJson())); - } - @Test - public void testMediaWikiMarshalling() throws Exception { + public void testMediaWikiMarshalling() throws Throwable { + PageTitle title = new PageTitle("Main page", WIKI, "//foo/thumb.jpg"); + PageProperties props = new PageProperties(new JSONObject(BasePageLeadTest.getEnglishMainPageJson())); + Page page = new Page(title, new ArrayList<Section>(), props, Page.MEDIAWIKI_ORIGIN); assertThat(page.isFromRestBase(), is(false)); Page pageClone = new Page(page.toJSON()); @@ -37,11 +30,28 @@ } @Test - public void testRestBaseMarshalling() throws Exception { + public void testRestBaseMarshalling() throws Throwable { + PageTitle title = new PageTitle("Main page", WIKI, "//foo/thumb.jpg"); + PageProperties props = new PageProperties(new JSONObject(BasePageLeadTest.getEnglishMainPageJson())); + Page page = new Page(title, new ArrayList<Section>(), props, Page.RESTBASE_ORIGIN); Page pageClone = new Page(page.toJSON()); // = complete unmarshall(marshall(subject)) assertThat(pageClone, is(page)); assertThat(page.isFromRestBase(), is(true)); assertThat(pageClone.isFromRestBase(), is(true)); } -} + + @Test public void testConstructorJson() throws Exception { + List<Section> sections = new ArrayList<>(); + Section headSection = new Section(0, 1, null, null, "Hi there!"); + sections.add(headSection); + final int numSections = 10; + for (int i = 1; i <= numSections; i++) { + sections.add(new Section(i, 1, "Something " + i, "Something_" + i, "Content Something" + i)); + } + PageTitle title = new PageTitle(null, "Test", WikiSite.forLanguageCode("en")); + PageProperties props = new PageProperties(new JSONObject("{\"id\":15580374,\"displaytitle\":\"Test\",\"revision\":615503846,\"lastmodified\":\"2001-02-03T04:00:00Z\",\"editable\":true,\"mainpage\":true}")); + Page page = new Page(title, sections, props); + assertThat(page, is(new Page(page.toJSON()))); + } +} \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/317097 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ia1cfbd35e8bd05c5f2e083ccba82145947c870ed 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