diff --git a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/StringBuilderConstantParametersTests.java b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/StringBuilderConstantParametersTests.java index d132f1a9b..d22b28faf 100644 --- a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/StringBuilderConstantParametersTests.java +++ b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/StringBuilderConstantParametersTests.java @@ -311,6 +311,30 @@ public void suggestedFixHandlesAddition() { .doTest(BugCheckerRefactoringTestHelper.TestMode.TEXT_MATCH); } + @Test + public void suggestedFixHandlesMethodCalledOnBuilt() { + RefactoringValidator.of(StringBuilderConstantParameters.class, getClass()) + .addInputLines( + "Test.java", + "class Test {", + " String f() {", + " return new StringBuilder()", + " .append(\"foo\")", + " .append(\"bar\")", + " .toString()", + " .toLowerCase();", + " }", + "}") + .addOutputLines( + "Test.java", + "class Test {", + " String f() {", + " return (\"foo\" + \"bar\").toLowerCase();", + " }", + "}") + .doTest(); + } + @Test public void negativeDynamicStringBuilder() { compilationHelper