From 0a0abae955d2754acebcb44a0536970fe89bcfc1 Mon Sep 17 00:00:00 2001 From: Elizaveta Shashkova Date: Mon, 20 Mar 2017 16:03:23 +0300 Subject: [PATCH] Cleanup in Python Console tests --- .../env/python/console/PyConsoleTask.java | 54 +++++++------------ 1 file changed, 20 insertions(+), 34 deletions(-) diff --git a/python/testSrc/com/jetbrains/env/python/console/PyConsoleTask.java b/python/testSrc/com/jetbrains/env/python/console/PyConsoleTask.java index 2d629701194b..761c56f38ecd 100644 --- a/python/testSrc/com/jetbrains/env/python/console/PyConsoleTask.java +++ b/python/testSrc/com/jetbrains/env/python/console/PyConsoleTask.java @@ -84,36 +84,30 @@ public class PyConsoleTask extends PyExecutionFixtureTestTask { @Override public void tearDown() throws Exception { - UIUtil.invokeAndWaitIfNeeded(new Runnable() { - @Override - public void run() { - try { - if (myConsoleView != null) { - disposeConsole(); - myCommunication.waitForTerminate(); - } - PyConsoleTask.super.tearDown(); - } - catch (Exception e) { - throw new RuntimeException(e); + UIUtil.invokeAndWaitIfNeeded((Runnable)() -> { + try { + if (myConsoleView != null) { + disposeConsole(); + myCommunication.waitForTerminate(); } + super.tearDown(); + } + catch (Exception e) { + throw new RuntimeException(e); } }); } private void disposeConsole() throws InterruptedException { if (myCommunication != null) { - UIUtil.invokeAndWaitIfNeeded(new Runnable() { - @Override - public void run() { - try { - myCommunication.close(); - } - catch (Exception e) { - e.printStackTrace(); - } - myCommunication = null; + UIUtil.invokeAndWaitIfNeeded((Runnable)() -> { + try { + myCommunication.close(); } + catch (Exception e) { + e.printStackTrace(); + } + myCommunication = null; }); } @@ -324,12 +318,7 @@ public class PyConsoleTask extends PyExecutionFixtureTestTask { protected void exec(final String command) throws InterruptedException { waitForReady(); myCommandSemaphore.acquire(1); - UIUtil.invokeAndWaitIfNeeded(new Runnable() { - @Override - public void run() { - myConsoleView.executeInConsole(command); - } - }); + UIUtil.invokeAndWaitIfNeeded((Runnable)() -> myConsoleView.executeInConsole(command)); Assert.assertTrue(String.format("Command execution wasn't finished: `%s` \n" + "Output: %s", command, output()), waitFor(myCommandSemaphore)); myCommandSemaphore.release(); @@ -388,12 +377,9 @@ public class PyConsoleTask extends PyExecutionFixtureTestTask { public void addTextToEditor(final String text) { - UIUtil.invokeAndWaitIfNeeded(new Runnable() { - @Override - public void run() { - getConsoleView().setInputText(text); - PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); - } + UIUtil.invokeAndWaitIfNeeded((Runnable)() -> { + getConsoleView().setInputText(text); + PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); } ); }