use of com.intellij.psi.PsiPackage in project intellij-community by JetBrains.
the class ContextConfigurationTest method testJUnitPackage.
public void testJUnitPackage() {
PsiClass psiClass = findClass(getModule1(), CLASS_NAME);
PsiPackage psiPackage = JUnitUtil.getContainingPackage(psiClass);
final MapDataContext dataContext = new MapDataContext();
final Module module = ModuleUtil.findModuleForPsiElement(psiClass);
dataContext.put(DataConstants.MODULE, module);
JUnitConfiguration configuration = createJUnitConfiguration(psiPackage, AllInPackageConfigurationProducer.class, dataContext);
checkTestObject(JUnitConfiguration.TEST_PACKAGE, configuration);
checkPackage(PACKAGE_NAME, configuration);
checkGeneretedName(configuration, PACKAGE_NAME + " in " + module.getName());
}
use of com.intellij.psi.PsiPackage in project intellij-community by JetBrains.
the class ContextConfigurationTest method testJUnitGeneratedName.
public void testJUnitGeneratedName() {
PsiClass psiClass = findClass(getModule1(), CLASS_NAME);
PsiPackage psiPackage = JUnitUtil.getContainingPackage(psiClass);
JUnitConfiguration configuration = new JUnitConfiguration(null, myProject, JUnitConfigurationType.getInstance().getConfigurationFactories()[0]);
JUnitConfiguration.Data data = configuration.getPersistentData();
data.PACKAGE_NAME = psiPackage.getQualifiedName();
data.TEST_OBJECT = JUnitConfiguration.TEST_PACKAGE;
assertEquals(PACKAGE_NAME, configuration.suggestedName());
data.PACKAGE_NAME = "not.existing.pkg";
assertEquals("not.existing.pkg", configuration.suggestedName());
data.TEST_OBJECT = JUnitConfiguration.TEST_CLASS;
data.MAIN_CLASS_NAME = psiClass.getQualifiedName();
assertEquals(SHORT_CLASS_NAME, configuration.suggestedName());
data.MAIN_CLASS_NAME = "not.existing.TestClass";
assertEquals("TestClass", configuration.suggestedName());
data.MAIN_CLASS_NAME = "pkg.TestClass.";
assertEquals("pkg.TestClass.", configuration.suggestedName());
data.MAIN_CLASS_NAME = "TestClass";
assertEquals("TestClass", configuration.suggestedName());
data.TEST_OBJECT = JUnitConfiguration.TEST_METHOD;
data.MAIN_CLASS_NAME = psiClass.getQualifiedName();
data.METHOD_NAME = METHOD_NAME;
assertEquals(SHORT_CLASS_NAME + "." + METHOD_NAME, configuration.suggestedName());
data.MAIN_CLASS_NAME = "not.existing.TestClass";
assertEquals("TestClass." + METHOD_NAME, configuration.suggestedName());
}
use of com.intellij.psi.PsiPackage in project intellij-community by JetBrains.
the class ContextConfigurationTest method testRecreateJUnitClass.
public void testRecreateJUnitClass() throws IOException {
createEmptyModule();
addDependency(getModule2(), getModule1());
PsiClass psiClass = findClass(getModule1(), CLASS_NAME);
PsiPackage psiPackage = JUnitUtil.getContainingPackage(psiClass);
JUnitConfiguration configuration = createJUnitConfiguration(psiPackage, AllInPackageConfigurationProducer.class, new MapDataContext());
configuration.getPersistentData().setScope(TestSearchScope.MODULE_WITH_DEPENDENCIES);
configuration.setModule(getModule2());
MapDataContext dataContext = new MapDataContext();
dataContext.put(DataConstantsEx.RUNTIME_CONFIGURATION, configuration);
configuration = createJUnitConfiguration(psiClass, TestInClassConfigurationProducer.class, dataContext);
checkClassName(psiClass.getQualifiedName(), configuration);
assertEquals(Collections.singleton(getModule2()), new HashSet(Arrays.asList(configuration.getModules())));
}
use of com.intellij.psi.PsiPackage in project intellij-community by JetBrains.
the class BasePackageParameterFactory method detectParameterValue.
@Override
public String detectParameterValue(Project project) {
PsiPackage root = JavaPsiFacade.getInstance(project).findPackage("");
if (root == null)
return null;
String name = getBasePackage(root, GlobalSearchScope.projectScope(project)).getQualifiedName();
return StringUtil.isEmpty(name) ? null : name;
}
use of com.intellij.psi.PsiPackage in project intellij-community by JetBrains.
the class JavaTestFrameworkRunnableState method spansMultipleModules.
protected boolean spansMultipleModules(final String qualifiedName) {
if (qualifiedName != null) {
final Project project = getConfiguration().getProject();
final PsiPackage aPackage = JavaPsiFacade.getInstance(project).findPackage(qualifiedName);
if (aPackage != null) {
final TestSearchScope scope = getScope();
if (scope != null) {
final SourceScope sourceScope = scope.getSourceScope(getConfiguration());
if (sourceScope != null) {
final GlobalSearchScope configurationSearchScope = GlobalSearchScopesCore.projectTestScope(project).intersectWith(sourceScope.getGlobalSearchScope());
final PsiDirectory[] directories = aPackage.getDirectories(configurationSearchScope);
return directories.length > 1;
}
}
}
}
return false;
}
Aggregations