void (@NotNull AnnotationHolder holder, @NotNull IntentionAction fix, @NotNull Function<? super AnnotationBuilder.FixBuilder, ? extends AnnotationBuilder.FixBuilder> good, @NotNull Function<? super AnnotationBuilder.FixBuilder, ? extends AnnotationBuilder.FixBuilder> bad) { try { AnnotationBuilder.FixBuilder builder = holder.newAnnotation(HighlightSeverity.ERROR, "xxx").newFix(fix); bad.apply(builder); builder.registerFix().create(); fail("Must have failed"); } catch (IllegalStateException|IllegalArgumentException ignored) { } AnnotationBuilder.FixBuilder builder = holder.newAnnotation(HighlightSeverity.ERROR, "xxx").newFix(fix); AnnotationBuilder.FixBuilder newBuilder = good.apply(builder); assertSame(newBuilder, builder); builder.registerFix().create(); }