Revert: ActionHint#findAndCheck now accepts String errorMessage instead of infoSupplier (IDEA-CR-14399) (a61024f6a3)

This commit is contained in:
Anna.Kozlova
2016-10-19 17:18:24 +02:00
parent 6c24cc78be
commit d00d7de338
3 changed files with 8 additions and 7 deletions
@@ -100,7 +100,7 @@ public class OrderEntryTest extends DaemonAnalyzerTestCase {
private IntentionAction findActionAndCheck(final ActionHint actionHint, Collection<HighlightInfo> infosBefore) {
List<IntentionAction> actions = LightQuickFixTestCase.getAvailableActions(getEditor(), getFile());
return actionHint.findAndCheck(actions, "Infos: " + infosBefore);
return actionHint.findAndCheck(actions, () -> "Infos: " + infosBefore);
}
public void testAddDependency() throws Exception {
@@ -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<IntentionAction> actions, @NotNull String errorMessage) {
public IntentionAction findAndCheck(Collection<IntentionAction> actions, Supplier<String> 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;
}
@@ -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) {