listen for rename of test category (IDEA-144086)
[idea/community.git] / plugins / junit / src / com / intellij / execution / junit / JUnitConfiguration.java
index 64b8ddb7a04ac900be8f540f330d1e78a2250e96..bcf5ce81514614aadcc46a2bb65643aa36eced1e 100644 (file)
@@ -28,7 +28,6 @@ import com.intellij.execution.junit2.ui.properties.JUnitConsoleProperties;
 import com.intellij.execution.runners.ExecutionEnvironment;
 import com.intellij.execution.runners.ExecutionEnvironmentBuilder;
 import com.intellij.execution.testframework.TestSearchScope;
-import com.intellij.execution.testframework.sm.runner.SMRunnerConsolePropertiesProvider;
 import com.intellij.execution.testframework.sm.runner.SMTRunnerConsoleProperties;
 import com.intellij.openapi.components.PathMacroManager;
 import com.intellij.openapi.module.Module;
@@ -111,6 +110,23 @@ public class JUnitConfiguration extends JavaTestConfigurationBase {
       restoreOriginalModule(originalModule);
     }
   };
+  
+  final RefactoringListeners.Accessor<PsiClass> myCategory = new RefactoringListeners.Accessor<PsiClass>() {
+    @Override
+    public void setName(@NotNull final String qualifiedName) {
+      setCategory(qualifiedName);
+    }
+
+    @Override
+    public PsiClass getPsiElement() {
+      return getConfigurationModule().findClass(myData.getCategory());
+    }
+
+    @Override
+    public void setPsiElement(final PsiClass psiClass) {
+      setCategory(JavaExecutionUtil.getRuntimeQualifiedName(psiClass));
+    }
+  };
   public boolean ALTERNATIVE_JRE_PATH_ENABLED;
   public String ALTERNATIVE_JRE_PATH;
 
@@ -282,6 +298,12 @@ public class JUnitConfiguration extends JavaTestConfigurationBase {
     if (shouldUpdateName) setGeneratedName();
   }
 
+  public void setCategory(String categoryName) {
+    final boolean shouldUpdateName = isGeneratedName();
+    myData.setCategoryName(categoryName);
+    if (shouldUpdateName) setGeneratedName();
+  }
+
   public void beMethodConfiguration(final Location<PsiMethod> methodLocation) {
     setModule(myData.setTestMethod(methodLocation));
     setGeneratedName();