package de.hsmannheim.iws2014.analyzers;

import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.queryparser.simple.SimpleQueryParser;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.RAMDirectory;
import org.junit.Test;

import java.io.IOException;
import java.util.Arrays;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

public class PiglatinTest {

    private String[] terms = new String[] {
            "foobar", "gumba", "trantual", "alfredolino", "ugulu", "bla"
    };

    @Test
    public void test_without_analyzer() throws Exception {
         RAMDirectory dir = new RAMDirectory();
         CustomAnalyzingIndexer indexer = new CustomAnalyzingIndexer(new StandardAnalyzer(), dir);
         indexer.index(Arrays.asList(terms));

         TopDocs foobar = contentSearch("foobar", dir);
         assertThat(foobar.totalHits, is(equalTo(1)));

         TopDocs oobarfay = contentSearch("oobarfay", dir);
         assertThat(oobarfay.totalHits, is(equalTo(0)));
     }

    @Test
    public void test_with_pig_lating_analyzer() throws Exception {
        RAMDirectory dir = new RAMDirectory();
        CustomAnalyzingIndexer indexer = new CustomAnalyzingIndexer(new PigLatinAnalyzer(), dir);
        indexer.index(Arrays.asList(terms));

        TopDocs foobar = contentSearch("foobar", dir);
        assertThat(foobar.totalHits, is(equalTo(0)));

        TopDocs oobarfay = contentSearch("oobarfay", dir);
        assertThat(oobarfay.totalHits, is(equalTo(1)));
    }

    private static TopDocs contentSearch(String query, Directory directory) throws IOException {
        IndexSearcher indexSearcher = new IndexSearcher(DirectoryReader.open(directory));
        SimpleQueryParser queryParser = new SimpleQueryParser(new StandardAnalyzer(), "content");
        return indexSearcher.search(queryParser.parse(query), 1000);
    }
}

@@ -31,24 +31,115 @@
 analyzers;%0A%0A
+import com.sun.corba.se.impl.orb.ParserTable;%0Aimport org.apache.commons.lang3.StringUtils;%0A
 import org.a
@@ -1838,24 +1838,303 @@
 )));%0A    %7D%0A%0A
+    @Test%0A    public void test_conversion() throws Exception %7B%0A        StringBuffer sb = new StringBuffer();%0A        for (String term : terms) %7B%0A            sb.append(term).append(%22 %22);%0A        %7D%0A        AnalyzerUtils.displayTokens(new PigLatinAnalyzer(), sb.toString());%0A    %7D%0A%0A
     private 

Add new test