/* LanguageTool, a natural language style checker 
 * Copyright (C) 2013 Daniel Naber (http://www.danielnaber.de)
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
 * USA
 */
package org.languagetool.synthesis;

import org.junit.Test;
import org.languagetool.AnalyzedToken;
import org.languagetool.language.German;

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

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;

public class GermanSynthesizerTest {

  private final GermanSynthesizer synthesizer = new GermanSynthesizer(new German());

  @Test
  public void testSynthesize() throws IOException {
    assertThat(synth("Äußerung", "SUB:NOM:PLU:FEM"), is("[Äußerungen]"));
    assertThat(synth("Äußerung", "SUB:NOM:PLU:MAS"), is("[]"));
    assertThat(synth("Haus", "SUB:AKK:PLU:NEU"), is("[Häuser]"));
    assertThat(synth("Haus", ".*", true), is("[Häuser, Haus, Häusern, Haus, Hause, Häuser, Hauses, Häuser, Haus]"));
  }

  @Test
  public void testSynthesizeCompounds() throws IOException {
    assertThat(synth("Regelsystem", "SUB:NOM:PLU:NEU"), is("[Regelsysteme]"));
    assertThat(synth("Regelsystem", "SUB:DAT:PLU:NEU"), is("[Regelsystemen]"));
    assertThat(synth("Regelsystem", ".*:PLU:.*", true), is("[Regelsysteme, Regelsystemen]"));
    assertThat(synth("Kühlschrankversuch", ".*:PLU:.*", true), is("[Kühlschrankversuche, Kühlschrankversuchen]"));
  }

  @Test
  public void testMorfologikBug() throws IOException {
    // see https://github.com/languagetool-org/languagetool/issues/586
    assertThat(synth("anfragen", "VER:1:PLU:KJ1:SFT:NEB"), is("[anfragen, Anfragen]"));
  }

  private String synth(String word, String posTag) throws IOException {
    return Arrays.toString(synthesizer.synthesize(dummyToken(word), posTag));
  }

  private String synth(String word, String posTag, boolean regEx) throws IOException {
    return Arrays.toString(synthesizer.synthesize(dummyToken(word), posTag, regEx));
  }

  private AnalyzedToken dummyToken(String tokenStr) {
    return new AnalyzedToken(tokenStr, tokenStr, tokenStr);
  }
}

@@ -887,24 +887,49 @@
 synthesis;%0A%0A
+import org.junit.Ignore;%0A
 import org.j
@@ -1281,16 +1281,426 @@
 an());%0A%0A
+  @Ignore(%22for interactive debugging only%22)%0A  @Test%0A  public void testSynthesizeX() throws IOException %7B%0A    String token = %22musst%22;%0A    String lemma = %22m%C3%BCssen%22;%0A    String posTag = %22VER:MOD:2:SIN:PR%C3%84%22;%0A    String targetPosTag = %22.*:PRT.*%22;%0A    String%5B%5D result = synthesizer.synthesize(new AnalyzedToken(token, posTag, lemma), targetPosTag, true);%0A    System.out.println(%22=%3E %22 + Arrays.toString(result));%0A  %7D%0A%0A
   @Test%0A

add code for easier interactive debugging