use of com.intellij.testFramework.MapDataContext 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.testFramework.MapDataContext in project intellij-community by JetBrains.
the class RenameModuleTest method testRename.
public void testRename() throws Exception {
String moduleName = "module";
String newModuleName = "moduleA";
Module module = createModule(moduleName);
assertEquals(moduleName, module.getName());
MapDataContext context = new MapDataContext();
context.put(LangDataKeys.MODULE_CONTEXT, module);
final RenameHandler renameHandler = RenameHandlerRegistry.getInstance().getRenameHandler(context);
assertNotNull(renameHandler);
Messages.setTestInputDialog(new TestInputDialog() {
@Override
public String show(String message) {
return null;
}
@Override
public String show(String message, @Nullable InputValidator validator) {
assertNotNull(validator);
boolean canClose = validator.canClose(newModuleName);
assertTrue(canClose);
return newModuleName;
}
});
renameHandler.invoke(myProject, PsiElement.EMPTY_ARRAY, context);
assertEquals(newModuleName, module.getName());
}
use of com.intellij.testFramework.MapDataContext in project intellij-community by JetBrains.
the class MavenDomTestCase method doRename.
protected void doRename(final VirtualFile f, String value) throws IOException {
final MapDataContext context = createRenameDataContext(f, value);
final RenameHandler renameHandler = RenameHandlerRegistry.getInstance().getRenameHandler(context);
assertNotNull(renameHandler);
invokeRename(context, renameHandler);
}
use of com.intellij.testFramework.MapDataContext in project intellij-community by JetBrains.
the class CCShowPreviewTest method getActionEvent.
TestActionEvent getActionEvent(AnAction action, PsiFile psiFile) {
MapDataContext context = new MapDataContext();
context.put(CommonDataKeys.PSI_FILE, psiFile);
context.put(CommonDataKeys.PROJECT, getProject());
context.put(LangDataKeys.MODULE, myFixture.getModule());
return new TestActionEvent(context, action);
}
use of com.intellij.testFramework.MapDataContext in project android by JetBrains.
the class TestConfigurationTesting method createContext.
@NotNull
public static ConfigurationContext createContext(@NotNull Project project, @NotNull PsiElement psiElement) {
MapDataContext dataContext = new MapDataContext();
dataContext.put(CommonDataKeys.PROJECT, project);
if (LangDataKeys.MODULE.getData(dataContext) == null) {
dataContext.put(LangDataKeys.MODULE, ModuleUtilCore.findModuleForPsiElement(psiElement));
}
dataContext.put(Location.DATA_KEY, PsiLocation.fromPsiElement(psiElement));
return ConfigurationContext.getFromContext(dataContext);
}
Aggregations