package org.diverse.pcm.io.wikipedia;

import org.diverse.pcm.api.java.PCM;
import org.diverse.pcm.io.wikipedia.WikipediaPageMiner;
import org.diverse.pcm.io.wikipedia.export.CSVExporter;
import org.diverse.pcm.io.wikipedia.export.HTMLExporter;
import org.diverse.pcm.io.wikipedia.export.PCMModelExporter;
import org.diverse.pcm.io.wikipedia.pcm.Matrix;
import org.diverse.pcm.io.wikipedia.pcm.Page;
import static org.junit.Assert.*;
import org.junit.Test;
import static scala.collection.JavaConversions.*;

import java.util.List;

/**
 * Created by gbecan on 19/11/14.
 */
public class WikipediaMinerTest {

    @Test
    public void test() {
        WikipediaPageMiner miner = new WikipediaPageMiner();

        // Parse article from Wikipedia
        String code = miner.getPageCodeFromWikipedia("Comparison_of_Nikon_DSLR_cameras");
        String preprocessedCode = miner.preprocess(code);
        Page page = miner.parse(preprocessedCode);


        // HTML export
        HTMLExporter htmlExporter = new HTMLExporter();
        String html = htmlExporter.export(page);
        assertNotNull(html);

        // CSV export
        CSVExporter csvExporter = new CSVExporter();
        String csv = csvExporter.export(page);
        assertNotNull(csv);

        // PCM model export
        PCMModelExporter pcmExporter = new PCMModelExporter();
        List<PCM> pcms = seqAsJavaList(pcmExporter.export(page));
        assertNotNull(pcms);

    }

}

@@ -291,32 +291,93 @@
 MModelExporter;%0A
+import org.diverse.pcm.io.wikipedia.export.WikiTextExporter;%0A
 import org.diver
@@ -1485,22 +1485,340 @@
 sert
-NotNull(pcms);
+False(pcms.isEmpty());%0A%0A        // Transform a list of PCM models into wikitext (markdown language for Wikipedia articles)%0A        WikiTextExporter wikitextExporter = new WikiTextExporter();%0A        for (PCM pcm : pcms) %7B%0A            String wikitext = wikitextExporter.toWikiText(pcm);%0A            assertNotNull(wikitext);%0A        %7D
 %0A%0A  

test for students