
package org.immutables.generator;

import com.google.common.base.Joiner;
import org.junit.Ignore;
import org.junit.Test;
import static org.immutables.check.Checkers.*;

public class PostprocessingMachineTest {
  private static final Joiner LINES = Joiner.on('\n');

  @Ignore
  @Test
  public void imports() {
    CharSequence rewrited = PostprocessingMachine.rewrite(
        LINES.join("package start;",
            "import java.util.List;",
            "import some.Some.Nested;",
            "class My extends java.util.Set {",
            "  private java.util.Map<java.lang.String, Integer> map = com.google.common.collect.Maps.newHashMap();",
            "}"));

    check(rewrited).hasToString(
        LINES.join("package start;",
            "import com.google.common.collect.Maps;",
            "import java.util.List;",
            "import java.util.Map;",
            "import java.util.Set;",
            "import some.Some.Nested;",
            "class My extends Set {",
            "  private Map<String, Integer> map = Maps.newHashMap();",
            "}"));
  }

  @Ignore
  @Test
  public void lineComment() {
    CharSequence rewrited = PostprocessingMachine.rewrite(
        LINES.join("package start;",
            "import java.util.List;",
            "class My extends java.util.Set {",
            "// comment",
            "// comment with fully qualified class name java.until.Map",
            "}"));

    check(rewrited).hasToString(
        LINES.join("package start;",
            "import java.util.List;",
            "import java.util.Set;",
            "class My extends Set {",
            "// comment",
            "// comment with fully qualified class name java.until.Map",
            "}"));
  }

  @Ignore
  @Test
  public void blockComment() {
    CharSequence rewrited = PostprocessingMachine.rewrite(
        LINES.join("package start;",
            "import java.util.List;",
            "class My extends java.util.Set {",
            "/* class name in block comment java.until.Map.get()*/",
            "/**",
            "class name in block comment java.until.Map.get()",
            "**/",
            "}"));

    check(rewrited).hasToString(
        LINES.join("package start;",
            "import java.util.List;",
            "import java.util.Set;",
            "class My extends Set {",
            "/* class name in block comment java.until.Map.get()*/",
            "/**",
            "class name in block comment java.until.Map.get()",
            "**/",
            "}"));
  }

  @Ignore
  @Test
  public void javaLangImports() {
    CharSequence rewrited = PostprocessingMachine.rewrite(
        LINES.join("package start;",
            "class My extends java.lang.Throwable {}"));

    check(rewrited).hasToString(
        LINES.join("package start;",
            "class My extends Throwable {}"));

    rewrited = PostprocessingMachine.rewrite(
        LINES.join("package start;",
            "class Throwable extends java.lang.Throwable {}"));

    check(rewrited).hasToString(
        LINES.join("package start;",
            "class Throwable extends java.lang.Throwable {}"));
  }

  @Ignore
  @Test
  public void currentPackageImport() {
    CharSequence rewrited = PostprocessingMachine.rewrite(
        LINES.join("package start;",
            "class My extends start.Utils {}"));

    check(rewrited).hasToString(
        LINES.join("package start;",
            "class My extends Utils {}"));

    rewrited = PostprocessingMachine.rewrite(
        LINES.join("package start;",
            "class Throwable extends start.Utils {",
            "  private class Utils {}",
            "}"));

    check(rewrited).hasToString(
        LINES.join("package start;",
            "class Throwable extends start.Utils {",
            "  private class Utils {}",
            "}"));
  }

  @Ignore
  @Test
  public void staticImport() {
    CharSequence rewrited = PostprocessingMachine.rewrite(LINES.join(
        "import static org.immutables.check.Checkers.*;",
        "class My extends java.util.Set {}"));

    check(rewrited).hasToString(LINES.join(
        "import java.util.Set;",
        "import static org.immutables.check.Checkers.*;",
        "class My extends Set {}"));
  }

  @Ignore
  @Test
  public void conflictResolution() {
    CharSequence rewrited = PostprocessingMachine.rewrite(
        "class Set extends java.util.Set {}");

    check(rewrited).hasToString(
        "class Set extends java.util.Set {}");

    rewrited = PostprocessingMachine.rewrite(LINES.join(
        "import my.Set;",
        "class X {",
        "  my.Set same(Set set);",
        "}"));

    check(rewrited).hasToString(LINES.join(
        "import my.Set;",
        "class X {",
        "  Set same(Set set);",
        "}"));
  }

  @Test
  public void fullyQualifiedWithSpaces() {
    CharSequence rewrited = PostprocessingMachine.rewrite(LINES.join(
        "class X {",
        "  private java.util.Map<java.lang.String, Integer> map = ",
        "    com.google.common.collect",
        "      .Maps.newHashMap();",
        "}"));

    check(rewrited).hasToString(LINES.join(
        "import java.util.Map;",
        "class X {",
        "  private Map<String, Integer> map = ",
        "    com.google.common.collect",
        "      .Maps.newHashMap();",
        "}"));

  }
}

@@ -71,33 +71,8 @@
 er;%0A
-import org.junit.Ignore;%0A
 impo
@@ -90,16 +90,16 @@
 t.Test;%0A
+
 import s
@@ -235,26 +235,16 @@
 '%5Cn');%0A%0A
-  @Ignore%0A
   @Test%0A
@@ -1033,34 +1033,24 @@
 %22%7D%22));%0A  %7D%0A%0A
-  @Ignore%0A
   @Test%0A  pu
@@ -1678,34 +1678,24 @@
 %22%7D%22));%0A  %7D%0A%0A
-  @Ignore%0A
   @Test%0A  pu
@@ -2468,34 +2468,24 @@
 %22%7D%22));%0A  %7D%0A%0A
-  @Ignore%0A
   @Test%0A  pu
@@ -3069,34 +3069,24 @@
 %7B%7D%22));%0A  %7D%0A%0A
-  @Ignore%0A
   @Test%0A  pu
@@ -3759,34 +3759,24 @@
 %22%7D%22));%0A  %7D%0A%0A
-  @Ignore%0A
   @Test%0A  pu
@@ -4159,18 +4159,8 @@
  %7D%0A%0A
-  @Ignore%0A
   @T

enable tests