From d00d7de338ab9ded0995b0c33980eeaa787d6e85 Mon Sep 17 00:00:00 2001 From: "Anna.Kozlova" Date: Wed, 19 Oct 2016 17:17:22 +0200 Subject: [PATCH] Revert: ActionHint#findAndCheck now accepts String errorMessage instead of infoSupplier (IDEA-CR-14399) (a61024f6a3e6aff56f061d707108fb205752c300) --- .../codeInsight/daemon/quickFix/OrderEntryTest.java | 2 +- .../intellij/codeInsight/daemon/quickFix/ActionHint.java | 9 +++++---- .../daemon/quickFix/LightQuickFixTestCase.java | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/OrderEntryTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/OrderEntryTest.java index 5768afa9a718..d6cf7e6a9ad0 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/OrderEntryTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/OrderEntryTest.java @@ -100,7 +100,7 @@ public class OrderEntryTest extends DaemonAnalyzerTestCase { private IntentionAction findActionAndCheck(final ActionHint actionHint, Collection infosBefore) { List actions = LightQuickFixTestCase.getAvailableActions(getEditor(), getFile()); - return actionHint.findAndCheck(actions, "Infos: " + infosBefore); + return actionHint.findAndCheck(actions, () -> "Infos: " + infosBefore); } public void testAddDependency() throws Exception { diff --git a/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/ActionHint.java b/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/ActionHint.java index b0bc698ad4c6..425a6558ba4e 100644 --- a/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/ActionHint.java +++ b/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/ActionHint.java @@ -25,6 +25,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Collection; +import java.util.function.Supplier; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -71,19 +72,19 @@ public class ActionHint { * if this ActionHint asserts that no action should be present. * * @param actions actions collection to search inside - * @param errorMessage an additional error message which will be appended to exception message if check fails + * @param infoSupplier a supplier which provides additional info which will be appended to exception message if check fails * @return the action or null * @throws AssertionError if no action is found, but it should present, or if action is found, but it should not present. */ @Nullable - public IntentionAction findAndCheck(@NotNull Collection actions, @NotNull String errorMessage) { + public IntentionAction findAndCheck(Collection actions, Supplier infoSupplier) { IntentionAction result = actions.stream().filter(t -> t.getText().equals(myExpectedText)).findFirst().orElse(null); if(result == null && myShouldPresent) { fail("Action with text '" + myExpectedText + "' not found\nAvailable actions: " + actions.stream().map(IntentionAction::getText).collect(Collectors.joining(", ", "[", "]\n")) + - errorMessage); + infoSupplier.get()); } else if(result != null && !myShouldPresent) { - fail("Action with text '" + myExpectedText + "' is present, but should not\n" + errorMessage); + fail("Action with text '" + myExpectedText + "' is present, but should not\n" + infoSupplier.get()); } return result; } diff --git a/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixTestCase.java b/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixTestCase.java index 7abf74ec5e7b..19ec879a4f35 100644 --- a/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixTestCase.java +++ b/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixTestCase.java @@ -103,7 +103,7 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase String testName, QuickFixTestCase quickFix) throws Exception { IntentionAction action = actionHint.findAndCheck(quickFix.getAvailableActions(), - "Test: "+testFullPath+"\nInfos: "+quickFix.doHighlighting()); + () -> "Test: "+testFullPath+"\nInfos: "+quickFix.doHighlighting()); if (action != null) { String text = action.getText(); quickFix.invoke(action); @@ -157,7 +157,7 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase } protected IntentionAction findActionAndCheck(@NotNull ActionHint hint, String testFullPath) { - return hint.findAndCheck(getAvailableActions(), "Test: "+testFullPath); + return hint.findAndCheck(getAvailableActions(), () -> "Test: "+testFullPath); } protected IntentionAction findActionWithText(@NotNull String text) {