From c62488ad749a11121ec595bb271dd28cf0666c2f Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 27 May 2015 15:25:54 +0300 Subject: [PATCH] lambdafication --- .../com/intellij/json/JsonFormattingTest.java | 71 ++++++------------- .../intellij/json/JsonStructureViewTest.java | 8 +-- 2 files changed, 24 insertions(+), 55 deletions(-) diff --git a/json/tests/test/com/intellij/json/JsonFormattingTest.java b/json/tests/test/com/intellij/json/JsonFormattingTest.java index f8d8d55f0691..ec1a87cec36e 100644 --- a/json/tests/test/com/intellij/json/JsonFormattingTest.java +++ b/json/tests/test/com/intellij/json/JsonFormattingTest.java @@ -7,7 +7,6 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.codeStyle.CommonCodeStyleSettings; import com.intellij.psi.formatter.FormatterTestCase; -import com.intellij.testFramework.IdeaTestCase; import com.intellij.testFramework.PlatformTestUtil; import com.intellij.testFramework.TestLoggerFactory; import com.intellij.util.ThrowableRunnable; @@ -23,7 +22,6 @@ public class JsonFormattingTest extends FormatterTestCase { @Override protected void setUp() throws Exception { - IdeaTestCase.initPlatformPrefix(); super.setUp(); } @@ -61,12 +59,9 @@ public class JsonFormattingTest extends FormatterTestCase { } public void testWrapping() throws Exception { - withPreservedSettings(new ThrowableRunnable() { - @Override - public void run() throws Exception { - getSettings().setRightMargin(JsonLanguage.INSTANCE, 20); - doTest(); - } + withPreservedSettings(() -> { + getSettings().setRightMargin(JsonLanguage.INSTANCE, 20); + doTest(); }); } @@ -81,68 +76,48 @@ public class JsonFormattingTest extends FormatterTestCase { } private void checkPropertyAlignment(@NotNull final PropertyAlignment alignmentType) throws Exception { - withPreservedSettings(new ThrowableRunnable() { - @Override - public void run() throws Exception { - getCustomSettings().PROPERTY_ALIGNMENT = alignmentType.getId(); - doTest(); - } + withPreservedSettings(() -> { + getCustomSettings().PROPERTY_ALIGNMENT = alignmentType.getId(); + doTest(); }); } public void testChopDownArrays() throws Exception { - withPreservedSettings(new ThrowableRunnable() { - @Override - public void run() throws Exception { - getCustomSettings().ARRAY_WRAPPING = WrapType.CHOP_DOWN_IF_LONG.getLegacyRepresentation(); - getSettings().setRightMargin(JsonLanguage.INSTANCE, 40); - doTest(); - } + withPreservedSettings(() -> { + getCustomSettings().ARRAY_WRAPPING = WrapType.CHOP_DOWN_IF_LONG.getLegacyRepresentation(); + getSettings().setRightMargin(JsonLanguage.INSTANCE, 40); + doTest(); }); } // IDEA-138902 public void testObjectsWithSingleProperty() throws Exception { - withPreservedSettings(new ThrowableRunnable() { - @Override - public void run() throws Exception { - doTest(); - } - }); + withPreservedSettings(this::doTest); } // Moved from JavaScript public void testWeb3830() throws Exception { - withPreservedSettings(new ThrowableRunnable() { - @Override - public void run() throws Exception { - CommonCodeStyleSettings.IndentOptions options = getIndentOptions(); - options.INDENT_SIZE = 8; - options.USE_TAB_CHARACTER = true; - options.TAB_SIZE = 8; - doTest(); - } + withPreservedSettings(() -> { + CommonCodeStyleSettings.IndentOptions options = getIndentOptions(); + options.INDENT_SIZE = 8; + options.USE_TAB_CHARACTER = true; + options.TAB_SIZE = 8; + doTest(); }); } public void testReformatJSon() throws Exception { - withPreservedSettings(new ThrowableRunnable() { - @Override - public void run() throws Exception { - getIndentOptions().INDENT_SIZE = 4; - doTest(); - } + withPreservedSettings(() -> { + getIndentOptions().INDENT_SIZE = 4; + doTest(); }); } public void testReformatJSon2() throws Exception { - withPreservedSettings(new ThrowableRunnable() { - @Override - public void run() throws Exception { - getIndentOptions().INDENT_SIZE = 4; - doTest(); - } + withPreservedSettings(() -> { + getIndentOptions().INDENT_SIZE = 4; + doTest(); }); } diff --git a/json/tests/test/com/intellij/json/JsonStructureViewTest.java b/json/tests/test/com/intellij/json/JsonStructureViewTest.java index e27e90aca6ee..3703e9915789 100644 --- a/json/tests/test/com/intellij/json/JsonStructureViewTest.java +++ b/json/tests/test/com/intellij/json/JsonStructureViewTest.java @@ -9,7 +9,6 @@ import com.intellij.lang.LanguageStructureViewBuilder; import com.intellij.openapi.fileEditor.FileEditor; import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.util.Disposer; -import com.intellij.util.Consumer; import com.intellij.util.PlatformIcons; import static com.intellij.testFramework.PlatformTestUtil.assertTreeEqual; @@ -21,12 +20,7 @@ public class JsonStructureViewTest extends JsonTestCase { private void doTest(final String expected) { myFixture.configureByFile("structureView/" + getTestName(false) + ".json"); - myFixture.testStructureView(new Consumer() { - @Override - public void consume(StructureViewComponent component) { - assertTreeEqual(component.getTree(), expected); - } - }); + myFixture.testStructureView(component -> assertTreeEqual(component.getTree(), expected)); } public void testPropertyOrderPreserved() {