public void testDiscouraedDefaultPackage() throws Exception {
   GroovyRuntime.removeGroovyNature(fJProject.getProject());
   NewClassWizardPage wizardPage = new NewClassWizardPage();
   wizardPage.setPackageFragmentRoot(fSourceFolder, true);
   assertStatus(
       IStatus.WARNING, "The use of the default package is discouraged.", wizardPage.getStatus());
 }
 public void testNotGroovyProject() throws Exception {
   GroovyRuntime.removeGroovyNature(fJProject.getProject());
   IPackageFragment frag = fProject.createPackage("test1");
   NewClassWizardPage wizardPage = new NewClassWizardPage();
   wizardPage.setPackageFragmentRoot(fSourceFolder, true);
   wizardPage.setPackageFragment(frag, true);
   assertStatus(
       IStatus.WARNING,
       "is not a groovy project.  Groovy Nature will be added to project upon completion.",
       wizardPage.getStatus());
 }
 public void testExclusionFilters() throws Exception {
   IPackageFragmentRoot root =
       fProject.createSourceFolder("other", null, new IPath[] {new Path("**/*.groovy")});
   IPackageFragment frag = root.createPackageFragment("p", true, null);
   NewClassWizardPage wizardPage = new NewClassWizardPage();
   wizardPage.setPackageFragmentRoot(root, true);
   wizardPage.setPackageFragment(frag, true);
   wizardPage.setTypeName("Nuthin", true);
   assertStatus(
       IStatus.ERROR,
       "Cannot create Groovy type because of exclusion patterns on the source folder.",
       wizardPage.getStatus());
 }
  public void testCreateGroovyClass2() throws Exception {
    IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null);

    NewClassWizardPage wizardPage = new NewClassWizardPage();
    wizardPage.setPackageFragmentRoot(fSourceFolder, true);
    wizardPage.setPackageFragment(pack1, true);
    wizardPage.setEnclosingTypeSelection(false, true);
    wizardPage.setTypeName("E", true);

    wizardPage.setSuperClass("ArrayList", true);

    List<String> interfaces = new ArrayList<String>();
    wizardPage.setSuperInterfaces(interfaces, true);

    wizardPage.setMethodStubSelection(false, false, false, true);
    wizardPage.setAddComments(true, true);
    wizardPage.enableCommentControl(true);

    wizardPage.createType(new NullProgressMonitor());

    String actual = wizardPage.getCreatedType().getCompilationUnit().getSource();

    StringBuffer buf = new StringBuffer();
    buf.append("/**\n");
    buf.append(" * File\n");
    buf.append(" */\n");
    buf.append("package test1\n");
    buf.append("\n");
    buf.append("import java.util.ArrayList\n");
    buf.append("\n");
    buf.append("/**\n");
    buf.append(" * Type\n");
    buf.append(" */\n");
    buf.append("class E extends ArrayList {\n");
    buf.append("    /* class body */\n");
    buf.append("}\n");
    String expected = buf.toString();

    assertEqualLines(expected, actual);
  }
  public void _testCreateGroovyClass2GenericSuper() throws Exception {
    // FIXKDV: this test fails/crashes in Groovy.
    //      cause: problems resolving generic types?
    IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null);

    NewClassWizardPage wizardPage = new NewClassWizardPage();
    wizardPage.setPackageFragmentRoot(fSourceFolder, true);
    wizardPage.setPackageFragment(pack1, true);
    wizardPage.setEnclosingTypeSelection(false, true);
    wizardPage.setTypeName("E", true);

    wizardPage.setSuperClass("java.util.ArrayList<String>", true);

    List<String> interfaces = new ArrayList<String>();
    wizardPage.setSuperInterfaces(interfaces, true);

    wizardPage.setMethodStubSelection(false, false, false, true);
    wizardPage.setAddComments(true, true);
    wizardPage.enableCommentControl(true);

    wizardPage.createType(null);

    String actual = wizardPage.getCreatedType().getCompilationUnit().getSource();

    StringBuffer buf = new StringBuffer();
    buf.append("/**\n");
    buf.append(" * File\n");
    buf.append(" */\n");
    buf.append("package test1;\n");
    buf.append("\n");
    buf.append("import java.util.ArrayList;\n");
    buf.append("\n");
    buf.append("/**\n");
    buf.append(" * Type\n");
    buf.append(" */\n");
    buf.append("class E extends ArrayList<String> {\n");
    buf.append("    /* class body */\n");
    buf.append("}\n");
    String expected = buf.toString();

    assertEqualLines(expected, actual);
  }