void (@NotNull AnnotationHolder holder, @NotNull LocalQuickFix fix, @NotNull Function<? super AnnotationBuilder.FixBuilder, ? extends AnnotationBuilder.FixBuilder> good, @NotNull Function<? super AnnotationBuilder.FixBuilder, ? extends AnnotationBuilder.FixBuilder> bad) { ProblemDescriptor descriptor = new ProblemDescriptor() { @Override public PsiElement getPsiElement() { return null; } @Override public PsiElement getStartElement() { return null; } @Override public PsiElement getEndElement() { return null; } @Override public TextRange getTextRangeInElement() { return null; } @Override public int getLineNumber() { return 0; } @NotNull @Override public ProblemHighlightType getHighlightType() { return null; } @Override public boolean isAfterEndOfLine() { return false; } @Override public void setTextAttributes(TextAttributesKey key) { } @Nullable @Override public ProblemGroup getProblemGroup() { return null; } @Override public void setProblemGroup(@Nullable ProblemGroup problemGroup) { } @Override public boolean showTooltip() { return false; } @NotNull @Override public String getDescriptionTemplate() { return null; } @Override public @NotNull QuickFix @Nullable [] getFixes() { return QuickFix.EMPTY_ARRAY; } }; try { AnnotationBuilder.FixBuilder builder = holder.newAnnotation(HighlightSeverity.ERROR, "xxx").newLocalQuickFix(fix, descriptor); bad.apply(builder); builder.registerFix().create(); fail("Must have failed"); } catch (IllegalStateException|IllegalArgumentException ignored) { } AnnotationBuilder.FixBuilder builder = holder.newAnnotation(HighlightSeverity.ERROR, "xxx").newLocalQuickFix(fix, descriptor); AnnotationBuilder.FixBuilder newBuilder = good.apply(builder); assertSame(newBuilder, builder); builder.registerFix().create(); }