package org.wikipedia.dataclient;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.wikipedia.page.PageTitle;
import org.wikipedia.test.TestParcelUtil;
import org.wikipedia.test.TestRunner;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;

@RunWith(TestRunner.class) public class WikiSiteTest {
    @Test public void testEquals() {
        assertThat(WikiSite.forLanguageCode("en"), is(WikiSite.forLanguageCode("en")));

        assertThat(WikiSite.forLanguageCode("ta"), not(WikiSite.forLanguageCode("en")));
        assertThat(WikiSite.forLanguageCode("ta").equals("ta.wikipedia.org"), is(false));
    }

    @Test public void testNormalization() {
        assertThat("bm.wikipedia.org", is(WikiSite.forLanguageCode("bm").authority()));
    }

    @Test public void testIsSupportedSite() {
        assertThat(WikiSite.supportedAuthority("fr.wikipedia.org"), is(true));
        assertThat(WikiSite.supportedAuthority("fr.m.wikipedia.org"), is(true));
        assertThat(WikiSite.supportedAuthority("roa-rup.wikipedia.org"), is(true));

        assertThat(WikiSite.supportedAuthority("google.com"), is(false));
    }

    @Test public void testTitleForInternalLink() {
        WikiSite wiki = WikiSite.forLanguageCode("en");
        assertThat(new PageTitle("Main Page", wiki), is(wiki.titleForInternalLink("")));
        assertThat(new PageTitle("Main Page", wiki), is(wiki.titleForInternalLink("/wiki/")));
        assertThat(new PageTitle("wiki", wiki), is(wiki.titleForInternalLink("wiki")));
        assertThat(new PageTitle("wiki", wiki), is(wiki.titleForInternalLink("/wiki/wiki")));
        assertThat(new PageTitle("wiki/wiki", wiki), is(wiki.titleForInternalLink("/wiki/wiki/wiki")));
    }

    @Test public void testCtorParcel() throws Throwable {
        WikiSite wiki = WikiSite.forLanguageCode("test");
        TestParcelUtil.test(wiki);
    }
}
@@ -84,16 +84,102 @@
 unWith;%0A
+import org.wikipedia.json.GsonMarshaller;%0Aimport org.wikipedia.json.GsonUnmarshaller;%0A
 import o
@@ -478,16 +478,788 @@
 eTest %7B%0A
+    @Test public void testCtorParcel() throws Throwable %7B%0A        WikiSite subject = WikiSite.forLanguageCode(%22test%22);%0A        TestParcelUtil.test(subject);%0A    %7D%0A%0A    @Test public void testCtorAuthorityDefaultScheme() %7B%0A        WikiSite subject = new WikiSite(%22wikipedia.org%22);%0A        assertThat(subject.secureScheme(), is(true));%0A    %7D%0A%0A    @Test public void testUnmarshal() %7B%0A        WikiSite wiki = WikiSite.forLanguageCode(%22test%22);%0A        assertThat(GsonUnmarshaller.unmarshal(WikiSite.class, GsonMarshaller.marshal(wiki)), is(wiki));%0A    %7D%0A%0A    @Test public void testUnmarshalScheme() %7B%0A        WikiSite wiki = new WikiSite(false, %22wikipedia.org%22, %22%22);%0A        assertThat(GsonUnmarshaller.unmarshal(WikiSite.class, GsonMarshaller.marshal(wiki)), is(wiki));%0A    %7D%0A%0A
     @Tes
@@ -2659,164 +2659,6 @@
    %7D
-%0A%0A    @Test public void testCtorParcel() throws Throwable %7B%0A        WikiSite wiki = WikiSite.forLanguageCode(%22test%22);%0A        TestParcelUtil.test(wiki);%0A    %7D
 %0A%7D

add a couple WikiSite tests