From f4a2a381eae17b9f460aa149191dccbd2fdf4c26 Mon Sep 17 00:00:00 2001 From: lkerford Date: Tue, 22 Oct 2024 15:19:00 -0700 Subject: [PATCH] adding tests --- .../ReplaceDuplicateStringLiteralsTest.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/test/java/org/openrewrite/staticanalysis/ReplaceDuplicateStringLiteralsTest.java b/src/test/java/org/openrewrite/staticanalysis/ReplaceDuplicateStringLiteralsTest.java index f8e3e6958..8fc7e44a8 100644 --- a/src/test/java/org/openrewrite/staticanalysis/ReplaceDuplicateStringLiteralsTest.java +++ b/src/test/java/org/openrewrite/staticanalysis/ReplaceDuplicateStringLiteralsTest.java @@ -148,6 +148,44 @@ class A { ); } + @Test + void enumCollidesWithNewStringLiteral() { + rewriteRun( + //language=java + java( + """ + package org.foo; + enum TYPES { + VALUE, NUMBER, TEXT + } + + class A { + final String val1 = "types"; + final String val2 = "types"; + final String val3 = "types"; + TYPES type = TYPES.VALUE; + } + + """, + """ + package org.foo; + enum TYPES { + VALUE, NUMBER, TEXT + } + + class A { + private static final String TYPES_1 = "types"; + final String val1 = TYPES_1; + final String val2 = TYPES_1; + final String val3 = TYPES_1; + TYPES type = TYPES.VALUE; + } + + """ + ) + ); + } + @Test void fieldNameCollidesWithNewStringLiteral() { rewriteRun(