From dad0e8cf5e31b84a8e26a1081aa03742a6584502 Mon Sep 17 00:00:00 2001 From: Bipin kumar Date: Sun, 25 Jun 2023 18:19:11 +0530 Subject: [PATCH] Java-20326: Changes made for replacing strSubstitutor with stringSubstitutor (#14301) --- .../core-java-string-operations-4/pom.xml | 6 ++++++ .../namedformatting/NamedFormatterUnitTest.java | 10 +++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/core-java-modules/core-java-string-operations-4/pom.xml b/core-java-modules/core-java-string-operations-4/pom.xml index cc755cf470..5cd1bd3c56 100644 --- a/core-java-modules/core-java-string-operations-4/pom.xml +++ b/core-java-modules/core-java-string-operations-4/pom.xml @@ -29,6 +29,11 @@ commons-lang3 ${apache-commons-lang3.version} + + org.apache.commons + commons-text + ${apache-commons-text.version} + org.assertj assertj-core @@ -56,6 +61,7 @@ 4.1 5.3.13 3.12.0 + 1.10.0 \ No newline at end of file diff --git a/core-java-modules/core-java-string-operations-4/src/test/java/com/baeldung/namedformatting/NamedFormatterUnitTest.java b/core-java-modules/core-java-string-operations-4/src/test/java/com/baeldung/namedformatting/NamedFormatterUnitTest.java index 843aaac0b5..a278041b8b 100644 --- a/core-java-modules/core-java-string-operations-4/src/test/java/com/baeldung/namedformatting/NamedFormatterUnitTest.java +++ b/core-java-modules/core-java-string-operations-4/src/test/java/com/baeldung/namedformatting/NamedFormatterUnitTest.java @@ -1,6 +1,6 @@ package com.baeldung.namedformatting; -import org.apache.commons.text.StrSubstitutor; +import org.apache.commons.text.StringSubstitutor; import org.junit.jupiter.api.Test; import java.util.HashMap; @@ -12,20 +12,20 @@ class NamedFormatterUnitTest { private static final String TEMPLATE = "Text: [${text}] Number: [${number}] Text again: [${text}]"; @Test - void givenTemplateWithNamedParam_whenCallingCommonsTextStrSubstitutor_shouldGetExpectedResult() { + void givenTemplateWithNamedParam_whenCallingCommonsTextStringSubstitutor_shouldGetExpectedResult() { Map params = new HashMap<>(); params.put("text", "It's awesome!"); params.put("number", 42); - String result = StrSubstitutor.replace(TEMPLATE, params, "${", "}"); + String result = StringSubstitutor.replace(TEMPLATE, params, "${", "}"); assertThat(result).isEqualTo("Text: [It's awesome!] Number: [42] Text again: [It's awesome!]"); } @Test - void givenTemplateWithNamedParam_whenCallingCommonsTextStrSubstitutorWithParameterNames_shouldNotWorkAsExpected() { + void givenTemplateWithNamedParam_whenCallingCommonsTextStringSubstitutorWithParameterNames_shouldNotWorkAsExpected() { Map params = new HashMap<>(); params.put("text", "'${number}' is a placeholder."); params.put("number", 42); - String result = StrSubstitutor.replace(TEMPLATE, params, "${", "}"); + String result = StringSubstitutor.replace(TEMPLATE, params, "${", "}"); assertThat(result).isNotEqualTo("Text: ['${number}' is a placeholder.] Number: [42] Text again: ['${number}' is a placeholder.]");