Files
openide/java/java-tests/testSrc/com/intellij/codeInsight/JavaSurroundWithTest.java
Dmitry Jemerov 9c8e2379be Move Java-specific part of SurroundWithTest to java-tests module
GitOrigin-RevId: fd78bb663c7e48c87f1dae25b6a04571aa62cf50
2022-05-02 16:17:23 +00:00

43 lines
1.5 KiB
Java

// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.codeInsight;
import com.intellij.JavaTestUtil;
import com.intellij.codeInsight.generation.surroundWith.JavaWithIfElseExpressionSurrounder;
import com.intellij.codeInsight.generation.surroundWith.JavaWithRunnableSurrounder;
import com.intellij.codeInsight.generation.surroundWith.JavaWithTryCatchSurrounder;
import com.intellij.codeInsight.generation.surroundWith.SurroundWithHandler;
import com.intellij.lang.surroundWith.Surrounder;
import com.intellij.testFramework.LightJavaCodeInsightTestCase;
import org.jetbrains.annotations.NotNull;
public class JavaSurroundWithTest extends LightJavaCodeInsightTestCase {
@Override
protected @NotNull String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
}
public void testTryCatch1() {
doTest(new JavaWithTryCatchSurrounder());
}
public void testRunnable() {
doTest(new JavaWithRunnableSurrounder());
}
public void testBlockedByPSI() {
doTest(new JavaWithIfElseExpressionSurrounder());
}
private void doTest(Surrounder handler) {
String baseName = getBaseName();
configureByFile(baseName + "." + "java");
SurroundWithHandler.invoke(getProject(), getEditor(), getFile(), handler);
checkResultByFile(baseName + "_after." + "java");
}
private String getBaseName() {
return "/codeInsight/surroundWith/" + getTestName(false);
}
}