use of org.jetbrains.idea.maven.dom.intentions.ChooseFileIntentionAction in project intellij-community by JetBrains.
the class MavenDependencyCompletionAndResolutionTest method testChooseFileIntentionForSystemDependency.
public void testChooseFileIntentionForSystemDependency() throws Throwable {
createProjectPom("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<dependencies>" + " <dependency><caret>" + " <groupId>xxx</groupId>" + " <artifactId>xxx</artifactId>" + " <version>xxx</version>" + " <scope>system</system>" + " </dependency>" + "</dependencies>");
IntentionAction action = getIntentionAtCaret("Choose File");
assertNotNull(action);
String libPath = myIndicesFixture.getRepositoryHelper().getTestDataPath("local1/junit/junit/4.0/junit-4.0.jar");
final VirtualFile libFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(libPath);
((ChooseFileIntentionAction) ((IntentionActionWrapper) action).getDelegate()).setFileChooser(() -> new VirtualFile[] { libFile });
XmlCodeStyleSettings xmlSettings = CodeStyleSettingsManager.getInstance(myProject).getCurrentSettings().getCustomSettings(XmlCodeStyleSettings.class);
int prevValue = xmlSettings.XML_TEXT_WRAP;
try {
// prevent file path from wrapping.
xmlSettings.XML_TEXT_WRAP = CommonCodeStyleSettings.DO_NOT_WRAP;
myFixture.launchAction(action);
} finally {
xmlSettings.XML_TEXT_WRAP = prevValue;
((ChooseFileIntentionAction) ((IntentionActionWrapper) action).getDelegate()).setFileChooser(null);
}
MavenDomProjectModel model = MavenDomUtil.getMavenDomProjectModel(myProject, myProjectPom);
MavenDomDependency dep = model.getDependencies().getDependencies().get(0);
assertEquals(findPsiFile(libFile), dep.getSystemPath().getValue());
}
Aggregations