コード例 #1
0
 public void bePatternConfiguration(List<PsiClass> classes, PsiMethod method) {
   data.TEST_OBJECT = TestType.PATTERN.getType();
   final String suffix;
   if (method != null) {
     data.METHOD_NAME = method.getName();
     suffix = "," + data.METHOD_NAME;
   } else {
     suffix = "";
   }
   LinkedHashSet<String> patterns = new LinkedHashSet<String>();
   for (PsiClass pattern : classes) {
     patterns.add(JavaExecutionUtil.getRuntimeQualifiedName(pattern) + suffix);
   }
   data.setPatterns(patterns);
   final Module module =
       RunConfigurationProducer.getInstance(TestNGPatternConfigurationProducer.class)
           .findModule(this, getConfigurationModule().getModule(), patterns);
   if (module == null) {
     data.setScope(TestSearchScope.WHOLE_PROJECT);
     setModule(null);
   } else {
     setModule(module);
   }
   setGeneratedName();
 }
コード例 #2
0
 @Nullable
 public PsiPackage getPsiElement() {
   final String qualifiedName = data.getPackageName();
   return qualifiedName != null
       ? JavaPsiFacade.getInstance(getProject()).findPackage(qualifiedName)
       : null;
 }
コード例 #3
0
 @Nullable
 public PsiClass getPsiElement() {
   final String qualifiedName = data.getMainClassName();
   return qualifiedName != null
       ? JavaPsiFacade.getInstance(getProject())
           .findClass(qualifiedName, GlobalSearchScope.allScope(project))
       : null;
 }
コード例 #4
0
 @Override
 protected ModuleBasedConfiguration createInstance() {
   try {
     return new TestNGConfiguration(
         getName(),
         getProject(),
         (TestData) data.clone(),
         TestNGConfigurationType.getInstance().getConfigurationFactories()[0]);
   } catch (CloneNotSupportedException e) {
     // can't happen right?
     e.printStackTrace();
   }
   return null;
 }
コード例 #5
0
  @Nullable
  public RefactoringElementListener getRefactoringElementListener(final PsiElement element) {
    if (data.TEST_OBJECT.equals(TestType.PACKAGE.getType())) {
      if (!(element instanceof PsiPackage)) return null;
      final RefactoringElementListener listener =
          RefactoringListeners.getListener((PsiPackage) element, myPackage);
      return RunConfigurationExtension.wrapRefactoringElementListener(element, this, listener);
    } else if (data.TEST_OBJECT.equals(TestType.CLASS.getType())) {
      if (!(element instanceof PsiClass) && !(element instanceof PsiPackage)) return null;
      final RefactoringElementListener listener =
          RefactoringListeners.getClassOrPackageListener(element, myClass);
      return RunConfigurationExtension.wrapRefactoringElementListener(element, this, listener);
    } else if (data.TEST_OBJECT.equals(TestType.METHOD.getType())) {
      if (!(element instanceof PsiMethod)) {
        final RefactoringElementListener listener =
            RefactoringListeners.getClassOrPackageListener(element, myClass);
        return RunConfigurationExtension.wrapRefactoringElementListener(element, this, listener);
      }
      final PsiMethod method = (PsiMethod) element;
      if (!method.getName().equals(data.getMethodName())) return null;
      if (!method.getContainingClass().equals(myClass.getPsiElement())) return null;
      class Listener extends RefactoringElementAdapter implements UndoRefactoringElementListener {
        public void elementRenamedOrMoved(@NotNull final PsiElement newElement) {
          data.setTestMethod(PsiLocation.fromPsiElement((PsiMethod) newElement));
        }

        @Override
        public void undoElementMovedOrRenamed(
            @NotNull PsiElement newElement, @NotNull String oldQualifiedName) {
          final int methodIdx = oldQualifiedName.indexOf("#") + 1;
          if (methodIdx <= 0 || methodIdx >= oldQualifiedName.length()) return;
          data.METHOD_NAME = oldQualifiedName.substring(methodIdx);
        }
      }
      return RunConfigurationExtension.wrapRefactoringElementListener(
          element, this, new Listener());
    }
    return null;
  }
コード例 #6
0
 public void setEnvs(@NotNull Map<String, String> envs) {
   data.setEnvs(envs);
 }
コード例 #7
0
 public void setMethodConfiguration(Location<PsiMethod> location) {
   setModule(data.setTestMethod(location));
   setGeneratedName();
 }
コード例 #8
0
 @Override
 public Collection<Module> getValidModules() {
   // TODO add handling for package
   return JavaRunConfigurationModule.getModulesForClass(getProject(), data.getMainClassName());
 }
コード例 #9
0
 public void setClassConfiguration(PsiClass psiclass) {
   setModule(data.setMainClass(psiclass));
   data.TEST_OBJECT = TestType.CLASS.getType();
   setGeneratedName();
 }
コード例 #10
0
 public void setPackageConfiguration(Module module, PsiPackage pkg) {
   data.setPackage(pkg);
   setModule(module);
   data.TEST_OBJECT = TestType.PACKAGE.getType();
   setGeneratedName();
 }
コード例 #11
0
 public String getRunClass() {
   return !data.TEST_OBJECT.equals(TestType.CLASS.getType())
           && !data.TEST_OBJECT.equals(TestType.METHOD.getType())
       ? null
       : data.getMainClassName();
 }
コード例 #12
0
 public String getPackage() {
   return !data.TEST_OBJECT.equals(TestType.PACKAGE.getType()) ? null : data.getPackageName();
 }
コード例 #13
0
 public void setVMParameters(String value) {
   data.setVMParameters(value);
 }
コード例 #14
0
 public void setPassParentEnvs(boolean passParentEnvs) {
   data.PASS_PARENT_ENVS = passParentEnvs;
 }
コード例 #15
0
 public String getVMParameters() {
   return data.getVMParameters();
 }
コード例 #16
0
 public String getWorkingDirectory() {
   return data.getWorkingDirectory(project);
 }
コード例 #17
0
 public void setWorkingDirectory(String value) {
   data.setWorkingDirectory(value);
 }
コード例 #18
0
 public String getProgramParameters() {
   return data.getProgramParameters();
 }
コード例 #19
0
 public void setProgramParameters(String value) {
   data.setProgramParameters(value);
 }
コード例 #20
0
 public void setName(final String qualifiedName) {
   final boolean generatedName = isGeneratedName();
   data.MAIN_CLASS_NAME = qualifiedName;
   if (generatedName) setGeneratedName();
 }
コード例 #21
0
 @NotNull
 public Map<String, String> getEnvs() {
   return data.getEnvs();
 }