本文整理汇总了Java中com.intellij.testFramework.MapDataContext类的典型用法代码示例。如果您正苦于以下问题:Java MapDataContext类的具体用法?Java MapDataContext怎么用?Java MapDataContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MapDataContext类属于com.intellij.testFramework包,在下文中一共展示了MapDataContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testAllInPackageForCommonAncestorModule
import com.intellij.testFramework.MapDataContext; //导入依赖的package包/类
public void testAllInPackageForCommonAncestorModule() throws IOException, ExecutionException {
disposeModule(getModule2());
addModule("module5", true);
Module ancestor = getModule1();
Module child1 = getModule2();
Module child2 = getModule3();
addDependency(ancestor, child1);
addDependency(ancestor, child2);
PsiPackage psiPackage = JavaPsiFacade.getInstance(myProject).findPackage("test1");
JUnitConfiguration configuration = createJUnitConfiguration(psiPackage, AllInPackageConfigurationProducer.class, new MapDataContext());
configuration.getPersistentData().setScope(TestSearchScope.WHOLE_PROJECT);
assertNotNull(configuration);
checkPackage(psiPackage.getQualifiedName(), configuration);
assertEmpty(configuration.getModules());
JavaParameters parameters = checkCanRun(configuration);
List<String> tests = extractAllInPackageTests(parameters, psiPackage);
String childTest1 = findClass(child1, "test1.TestB").getQualifiedName();
String childTest2 = findClass(child2, "test1.Test5").getQualifiedName();
String ancestorTest = findClass(ancestor, "test1.TestA").getQualifiedName();
CHECK.containsAll(tests, new Object[]{ancestorTest, childTest1, childTest2});
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:ConfigurationsTest.java
示例2: testAllInPackageForProject
import com.intellij.testFramework.MapDataContext; //导入依赖的package包/类
public void testAllInPackageForProject() throws IOException, ExecutionException {
// module1 -> module2 -> module3
// module5
addModule("module5");
addDependency(getModule1(), getModule2());
addDependency(getModule2(), getModule3());
String[][] outputs = new String[4][];
for (int i = 0; i < 4; i++) {
outputs[i] = addOutputs(getModule(i), i + 1);
}
PsiPackage defaultPackage = JavaPsiFacade.getInstance(myProject).findPackage("");
JUnitConfiguration configuration =
createJUnitConfiguration(defaultPackage, AllInPackageConfigurationProducer.class, new MapDataContext());
configuration.getPersistentData().setScope(TestSearchScope.WHOLE_PROJECT);
JavaParameters javaParameters = checkCanRun(configuration);
String classPath = javaParameters.getClassPath().getPathsString();
assertEquals(-1, classPath.indexOf(JarFileSystem.PROTOCOL_PREFIX));
assertEquals(-1, classPath.indexOf(LocalFileSystem.PROTOCOL_PREFIX));
for (int i = 0; i < 4; i++) {
checkContains(classPath, outputs[i][0]);
checkContains(classPath, outputs[i][1]);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:ConfigurationsTest.java
示例3: search
import com.intellij.testFramework.MapDataContext; //导入依赖的package包/类
protected List<PsiElement> search(VirtualFile file) throws IOException {
final MapDataContext context = createDataContext(file);
UsageTarget[] targets = UsageTargetUtil.findUsageTargets(new DataProvider() {
@Override
public Object getData(@NonNls String dataId) {
return context.getData(dataId);
}
});
PsiElement target = ((PsiElement2UsageTargetAdapter)targets[0]).getElement();
List<PsiReference> result = new ArrayList<PsiReference>(ReferencesSearch.search(target).findAll());
return ContainerUtil.map(result, new Function<PsiReference, PsiElement>() {
@Override
public PsiElement fun(PsiReference psiReference) {
return psiReference.getElement();
}
});
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:MavenDomTestCase.java
示例4: getActionEvent
import com.intellij.testFramework.MapDataContext; //导入依赖的package包/类
@NotNull
private TestActionEvent getActionEvent(VirtualFile virtualFile, AnAction action) {
MapDataContext context = new MapDataContext();
context.put(CommonDataKeys.VIRTUAL_FILE_ARRAY, new VirtualFile[]{virtualFile});
context.put(CommonDataKeys.PROJECT, getProject());
return new TestActionEvent(context, action);
}
开发者ID:medvector,项目名称:educational-plugin,代码行数:8,代码来源:CCTaskFileActionTest.java
示例5: getActionEvent
import com.intellij.testFramework.MapDataContext; //导入依赖的package包/类
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);
}
开发者ID:medvector,项目名称:educational-plugin,代码行数:8,代码来源:CCShowPreviewTest.java
示例6: testInAnnotationType
import com.intellij.testFramework.MapDataContext; //导入依赖的package包/类
public void testInAnnotationType() {
String name = getTestName(false);
configureByFile(BASE_DIR + "before" + name + ".java");
int offset = getEditor().getCaretModel().getOffset();
PsiElement context = getFile().findElementAt(offset);
final PsiClass aClass = PsiTreeUtil.getParentOfType(context, PsiClass.class);
assertTrue(aClass != null && aClass.isAnnotationType());
final JavaOverrideMethodsHandler handler = new JavaOverrideMethodsHandler();
assertTrue(handler.isValidFor(getEditor(), getFile()));
assertFalse(handler.isAvailableForQuickList(getEditor(), getFile(), new MapDataContext()));
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:OverrideImplement15Test.java
示例7: testRenameJUnitPackage
import com.intellij.testFramework.MapDataContext; //导入依赖的package包/类
public void testRenameJUnitPackage() throws IOException {
PsiPackage psiPackage = mySource.createPackage("pkg");
JUnitConfiguration configuration = createJUnitConfiguration(psiPackage, AllInPackageConfigurationProducer.class, new MapDataContext());
rename(psiPackage, "pkg2");
checkPackage("pkg2", configuration);
PsiPackage outer = mySource.createPackage("outerPkg");
move(JavaPsiFacade.getInstance(myProject).findPackage("pkg2"), outer.getQualifiedName());
checkPackage("outerPkg.pkg2", configuration);
rename(outer, "outer2");
checkPackage("outer2.pkg2", configuration);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:ConfigurationRefactoringsTest.java
示例8: createJUnitConfiguration
import com.intellij.testFramework.MapDataContext; //导入依赖的package包/类
@Override
protected JUnitConfiguration createJUnitConfiguration(@NotNull PsiElement psiElement,
@NotNull Class<? extends JUnitConfigurationProducer> producerClass,
@NotNull MapDataContext dataContext) {
final JUnitConfiguration configuration = super.createJUnitConfiguration(psiElement, producerClass, dataContext);
RunManagerEx.getInstanceEx(myProject).setTemporaryConfiguration(new RunnerAndConfigurationSettingsImpl(null, configuration, false));
return configuration;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:ConfigurationRefactoringsTest.java
示例9: createJUnitConfiguration
import com.intellij.testFramework.MapDataContext; //导入依赖的package包/类
protected JUnitConfiguration createJUnitConfiguration(@NotNull PsiElement psiElement,
@NotNull Class<? extends JUnitConfigurationProducer> producerClass,
@NotNull MapDataContext dataContext) {
ConfigurationContext context = createContext(psiElement, dataContext);
RunConfigurationProducer producer = RunConfigurationProducer.getInstance(producerClass);
assert producer != null;
ConfigurationFromContext fromContext = producer.createConfigurationFromContext(context);
assertNotNull(fromContext);
return (JUnitConfiguration)fromContext.getConfiguration();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:BaseConfigurationTestCase.java
示例10: createContext
import com.intellij.testFramework.MapDataContext; //导入依赖的package包/类
public ConfigurationContext createContext(@NotNull PsiElement psiClass, @NotNull MapDataContext dataContext) {
dataContext.put(CommonDataKeys.PROJECT, myProject);
if (LangDataKeys.MODULE.getData(dataContext) == null) {
dataContext.put(LangDataKeys.MODULE, ModuleUtilCore.findModuleForPsiElement(psiClass));
}
dataContext.put(Location.DATA_KEY, PsiLocation.fromPsiElement(psiClass));
return ConfigurationContext.getFromContext(dataContext);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:BaseConfigurationTestCase.java
示例11: testJUnitClassTest
import com.intellij.testFramework.MapDataContext; //导入依赖的package包/类
public void testJUnitClassTest() {
PsiClass psiClass = findClass(getModule1(), CLASS_NAME);
final MapDataContext dataContext = new MapDataContext();
JUnitConfiguration configuration = createJUnitConfiguration(psiClass, TestClassConfigurationProducer.class, dataContext);
checkTestObject(JUnitConfiguration.TEST_CLASS, configuration);
checkClassName(CLASS_NAME, configuration);
checkPackage(PACKAGE_NAME, configuration);
checkGeneretedName(configuration, SHORT_CLASS_NAME);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:ContextConfigurationTest.java
示例12: testRecreateJUnitClass
import com.intellij.testFramework.MapDataContext; //导入依赖的package包/类
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, TestClassConfigurationProducer.class, dataContext);
checkClassName(psiClass.getQualifiedName(), configuration);
assertEquals(Collections.singleton(getModule2()), new HashSet(Arrays.asList(configuration.getModules())));
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:ContextConfigurationTest.java
示例13: testJUnitPackage
import com.intellij.testFramework.MapDataContext; //导入依赖的package包/类
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());
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:ContextConfigurationTest.java
示例14: testJUnitDefaultPackage
import com.intellij.testFramework.MapDataContext; //导入依赖的package包/类
public void testJUnitDefaultPackage() {
PsiClass psiClass = findClass(getModule1(), CLASS_NAME);
PsiPackage psiPackage = JUnitUtil.getContainingPackage(psiClass);
PsiPackage defaultPackage = psiPackage.getParentPackage();
final Module module = ModuleUtil.findModuleForPsiElement(psiClass);
final MapDataContext dataContext = new MapDataContext();
dataContext.put(DataConstants.MODULE, module);
JUnitConfiguration configuration = createJUnitConfiguration(defaultPackage, AllInPackageConfigurationProducer.class, dataContext);
checkTestObject(JUnitConfiguration.TEST_PACKAGE, configuration);
checkPackage("", configuration);
checkGeneretedName(configuration, "All in " + module.getName());
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:ContextConfigurationTest.java
示例15: testCreateConfiguration
import com.intellij.testFramework.MapDataContext; //导入依赖的package包/类
public void testCreateConfiguration() throws IOException, ExecutionException {
Module module1 = getModule1();
PsiClass psiClass = findTestA(module1);
JUnitConfiguration configuration = createConfiguration(psiClass);
assertEquals(Collections.singleton(module1), ContainerUtilRt.newHashSet(configuration.getModules()));
checkClassName(psiClass.getQualifiedName(), configuration);
assertEquals(psiClass.getName(), configuration.getName());
checkTestObject(JUnitConfiguration.TEST_CLASS, configuration);
Module module2 = getModule2();
Assertion.compareUnordered(new Module[]{module1, module2}, configuration.getValidModules());
PsiClass innerTest = findClass(module1, INNER_TEST_NAME);
configuration = createJUnitConfiguration(innerTest, TestClassConfigurationProducer.class, new MapDataContext());
checkClassName(RT_INNER_TEST_NAME, configuration);
checkCanRun(configuration);
PsiMethod[] testMethod = innerTest.findMethodsByName("test", false);
assertEquals(1, testMethod.length);
configuration = createConfiguration(testMethod[0]);
checkClassName(RT_INNER_TEST_NAME, configuration);
checkMethodName("test", configuration);
checkTestObject(JUnitConfiguration.TEST_METHOD, configuration);
checkCanRun(configuration);
PsiMethod mainMethod = innerTest.findMethodsByName("main", false)[0];
ApplicationConfiguration appConfiguration = createConfiguration(mainMethod);
assertEquals(RT_INNER_TEST_NAME, appConfiguration.MAIN_CLASS_NAME);
checkCanRun(configuration);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:ConfigurationsTest.java
示例16: testTestClassPathWhenRunningConfigurations
import com.intellij.testFramework.MapDataContext; //导入依赖的package包/类
public void testTestClassPathWhenRunningConfigurations() throws IOException, ExecutionException {
addModule("module4", false);
Module module4 = getModule4();
assignJdk(module4);
addSourcePath(module4, "testSrc", true);
addSourcePath(module4, "src", false);
String output = setCompilerOutput(module4, "classes", false);
String testOuput = setCompilerOutput(module4, "testClasses", true);
ApplicationConfiguration applicationConfiguration = createConfiguration(findClass(module4, "Application"));
JavaParameters parameters = checkCanRun(applicationConfiguration);
String classPath = parameters.getClassPath().getPathsString();
checkDoesNotContain(classPath, testOuput);
checkContains(classPath, output);
JUnitConfiguration junitConfiguration =
createJUnitConfiguration(findClass(module4, "TestApplication"), TestClassConfigurationProducer.class, new MapDataContext());
parameters = checkCanRun(junitConfiguration);
classPath = parameters.getClassPath().getPathsString();
checkContains(classPath, testOuput);
checkContains(classPath, output);
applicationConfiguration.MAIN_CLASS_NAME = junitConfiguration.getPersistentData().getMainClassName();
classPath = checkCanRun(applicationConfiguration).getClassPath().getPathsString();
checkContains(classPath, testOuput);
checkContains(classPath, output);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:ConfigurationsTest.java
示例17: configureFile
import com.intellij.testFramework.MapDataContext; //导入依赖的package包/类
private void configureFile(String text) {
PsiFile psiFile = myFixture.configureByText("test.txt", text);
Document document = myFixture.getDocument(psiFile);
final Project project = getProject();
TextFieldWithAutoCompletionContributor.installCompletion(document, project,
new TaskAutoCompletionListProvider(project),
false);
document.putUserData(CommitMessage.DATA_CONTEXT_KEY, new MapDataContext());
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:TaskCompletionTest.java
示例18: doRename
import com.intellij.testFramework.MapDataContext; //导入依赖的package包/类
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);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:MavenDomTestCase.java
示例19: assertCannotRename
import com.intellij.testFramework.MapDataContext; //导入依赖的package包/类
protected void assertCannotRename() throws Exception {
MapDataContext context = createRenameDataContext(myProjectPom, "new name");
RenameHandler handler = RenameHandlerRegistry.getInstance().getRenameHandler(context);
if (handler == null) return;
try {
invokeRename(context, handler);
}
catch (CommonRefactoringUtil.RefactoringErrorHintException e) {
if (!e.getMessage().startsWith("Cannot perform refactoring.")) {
throw e;
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:MavenDomTestCase.java
示例20: createDataContext
import com.intellij.testFramework.MapDataContext; //导入依赖的package包/类
private MapDataContext createDataContext(VirtualFile f) throws IOException {
MapDataContext context = new MapDataContext();
context.put(CommonDataKeys.EDITOR, getEditor(f));
context.put(CommonDataKeys.PSI_FILE, getTestPsiFile(f));
context.put(CommonDataKeys.PSI_ELEMENT, TargetElementUtil.findTargetElement(getEditor(f),
TargetElementUtil.REFERENCED_ELEMENT_ACCEPTED
| TargetElementUtil.ELEMENT_NAME_ACCEPTED));
return context;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:MavenDomTestCase.java
注:本文中的com.intellij.testFramework.MapDataContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论