From 66eb977fec1de72e17264f33434f098af758d8c0 Mon Sep 17 00:00:00 2001 From: Nakul Joshi Date: Wed, 5 Jun 2024 12:03:00 -0700 Subject: [PATCH] Add test --- .../StringBuilderConstantParametersTests.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) 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