<commit_before>/*
 * Copyright 2000-2013 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jetbrains.plugins.gradle;

import com.intellij.ide.projectWizard.NewProjectWizardTestCase;
import com.intellij.ide.projectWizard.ProjectTypeStep;
import com.intellij.ide.util.projectWizard.ModuleWizardStep;
import com.intellij.ide.wizard.Step;
import com.intellij.openapi.project.Project;
import com.intellij.util.Consumer;

import java.util.List;

/**
 * @author <NAME>
 */
public class GradleProjectWizardTest extends NewProjectWizardTestCase {

  public void testGradleProject() throws Exception {
    Project project = createProject(new Consumer<Step>() {
      @Override
      public void consume(Step step) {
        if (step instanceof ProjectTypeStep) {
          assertTrue(((ProjectTypeStep)step).setSelectedTemplate("Gradle", null));
          List<ModuleWizardStep> steps = myWizard.getSequence().getSelectedSteps();
          assertEquals(3, steps.size());
        }
      }
    });
  }

  @Override
  protected void setUp() throws Exception {
    super.setUp();
    configureJdk();
  }
}<commit_msg>gradle: project wizard test fix (cherry picked from commit c047fa7)<commit_after>/*
 * Copyright 2000-2013 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jetbrains.plugins.gradle;

import com.intellij.ide.projectWizard.NewProjectWizardTestCase;
import com.intellij.ide.projectWizard.ProjectTypeStep;
import com.intellij.ide.util.projectWizard.ModuleWizardStep;
import com.intellij.ide.util.projectWizard.ProjectBuilder;
import com.intellij.ide.wizard.Step;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.Consumer;
import org.jetbrains.plugins.gradle.service.project.wizard.GradleModuleBuilder;

import java.util.List;

/**
 * @author <NAME>
 */
public class GradleProjectWizardTest extends NewProjectWizardTestCase {

  public void testGradleProject() throws Exception {
    final String projectName = "testProject";
    Project project = createProject(new Consumer<Step>() {
      @Override
      public void consume(Step step) {
        if (step instanceof ProjectTypeStep) {
          assertTrue(((ProjectTypeStep)step).setSelectedTemplate("Gradle", null));
          List<ModuleWizardStep> steps = myWizard.getSequence().getSelectedSteps();
          assertEquals(5, steps.size());
          final ProjectBuilder projectBuilder = myWizard.getProjectBuilder();
          assertInstanceOf(projectBuilder, GradleModuleBuilder.class);
          ((GradleModuleBuilder)projectBuilder).setName(projectName);
        }
      }
    });

    assertEquals(projectName, project.getName());
    Module[] modules = ModuleManager.getInstance(project).getModules();
    assertEquals(1, modules.length);
    final Module module = modules[0];
    assertTrue(ModuleRootManager.getInstance(module).isSdkInherited());
    assertEquals(projectName, module.getName());

    VirtualFile root = ProjectRootManager.getInstance(project).getContentRoots()[0];
    VirtualFile settingsScript = VfsUtilCore.findRelativeFile("settings.gradle", root);
    assertNotNull(settingsScript);
    assertEquals(String.format("rootProject.name = '%s'\n\n", projectName),
                 StringUtil.convertLineSeparators(VfsUtilCore.loadText(settingsScript)));

    VirtualFile buildScript = VfsUtilCore.findRelativeFile("build.gradle", root);
    assertNotNull(buildScript);
    assertEquals("apply plugin: 'java'\n" +
                 "\n" +
                 "sourceCompatibility = 1.5\n" +
                 "\n" +
                 "group '" + projectName + "'\n" +
                 "version '1.0-SNAPSHOT'\n" +
                 "\n" +
                 "repositories {\n" +
                 "    mavenCentral()\n" +
                 "}\n" +
                 "\n" +
                 "dependencies {\n" +
                 "    testCompile group: 'junit', name: 'junit', version: '4.11'\n" +
                 "}",
                 StringUtil.convertLineSeparators(VfsUtilCore.loadText(buildScript)));
  }

  @Override
  protected void setUp() throws Exception {
    super.setUp();
    configureJdk();
  }
}
{'fraction_non_alphanumeric': 0.10756393977870488, 'fraction_numerical': 0.007255577725376383, 'mean_word_length': 3.497553017944535, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5047637', 'n_tokens_mistral': 1562, 'n_tokens_neox': 1516, 'n_words': 375}