Convert to Kotlin: AbstractExpressionSelectionTest

This commit is contained in:
Alexey Sedunov
2016-08-31 15:03:27 +03:00
parent 96a2c97aa2
commit a6e3aac7ca
@@ -14,50 +14,34 @@
* limitations under the License. * limitations under the License.
*/ */
package org.jetbrains.kotlin.idea; package org.jetbrains.kotlin.idea
import com.intellij.psi.PsiElement; import com.intellij.testFramework.LightCodeInsightTestCase
import com.intellij.testFramework.LightCodeInsightTestCase; import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils
import kotlin.Unit; import org.jetbrains.kotlin.idea.refactoring.IntroduceRefactoringException
import kotlin.jvm.functions.Function1; import org.jetbrains.kotlin.idea.refactoring.selectElement
import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils; import org.jetbrains.kotlin.test.KotlinTestUtils
import org.jetbrains.kotlin.idea.refactoring.IntroduceRefactoringException;
import org.jetbrains.kotlin.idea.refactoring.ElementSelectionUtilsKt;
import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.kotlin.test.KotlinTestUtils;
import java.util.Collections; abstract class AbstractExpressionSelectionTest : LightCodeInsightTestCase() {
override fun getTestDataPath() = ""
public abstract class AbstractExpressionSelectionTest extends LightCodeInsightTestCase { fun doTestExpressionSelection(path: String) {
configureByFile(path)
public void doTestExpressionSelection(@NotNull String path) throws Exception { val expectedExpression = KotlinTestUtils.getLastCommentInFile(getFile() as KtFile)
configureByFile(path);
final String expectedExpression = KotlinTestUtils.getLastCommentInFile((KtFile) getFile());
try { try {
ElementSelectionUtilsKt.selectElement( selectElement(
getEditor(), getEditor(),
(KtFile) getFile(), getFile() as KtFile,
Collections.singletonList(CodeInsightUtils.ElementKind.EXPRESSION), listOf(CodeInsightUtils.ElementKind.EXPRESSION)
new Function1<PsiElement, Unit>() { ) {
@Override assertNotNull("Selected expression mustn't be null", it)
public Unit invoke(PsiElement element) { assertEquals(expectedExpression, it?.text)
assertNotNull("Selected expression mustn't be null", element); }
assertEquals(expectedExpression, element.getText());
return Unit.INSTANCE;
}
}
);
} }
catch (IntroduceRefactoringException e) { catch (e: IntroduceRefactoringException) {
assertEquals(expectedExpression, ""); assertEquals(expectedExpression, "")
} }
} }
@NotNull
@Override
protected String getTestDataPath() {
return "";
}
} }