From 69e04d5ac0ebe9cff0d102fe74305100975aaedc Mon Sep 17 00:00:00 2001 From: ashleyfrieze Date: Mon, 31 Jan 2022 03:49:04 +0000 Subject: [PATCH] BAEL-5354 Add improvement to cover JDK11 solution to the repeated string problem (#11756) --- .../core-java-string-algorithms-3/pom.xml | 3 ++- .../RepeatedCharacterStringUnitTest.java | 12 ++++++++++++ core-java-modules/pom.xml | 1 - pom.xml | 1 + 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/core-java-modules/core-java-string-algorithms-3/pom.xml b/core-java-modules/core-java-string-algorithms-3/pom.xml index c140fce584..dc8ad3851d 100644 --- a/core-java-modules/core-java-string-algorithms-3/pom.xml +++ b/core-java-modules/core-java-string-algorithms-3/pom.xml @@ -49,8 +49,9 @@ + 11 + 11 1.7 3.12.0 - \ No newline at end of file diff --git a/core-java-modules/core-java-string-algorithms-3/src/test/java/com/baeldung/repeatedcharstring/RepeatedCharacterStringUnitTest.java b/core-java-modules/core-java-string-algorithms-3/src/test/java/com/baeldung/repeatedcharstring/RepeatedCharacterStringUnitTest.java index 42697c781e..81e78e8fd0 100644 --- a/core-java-modules/core-java-string-algorithms-3/src/test/java/com/baeldung/repeatedcharstring/RepeatedCharacterStringUnitTest.java +++ b/core-java-modules/core-java-string-algorithms-3/src/test/java/com/baeldung/repeatedcharstring/RepeatedCharacterStringUnitTest.java @@ -19,6 +19,18 @@ class RepeatedCharacterStringUnitTest { private static final String EXPECTED_STRING = "aaaaaaa"; private static final int N = 7; + @Test + void givenSingleCharacterString_whenRepeat_thenStringCreated() { + String newString = "a".repeat(N); + assertEquals(EXPECTED_STRING, newString); + } + + @Test + void givenMultiCharacterString_whenRepeat_thenStringCreated() { + String newString = "-->".repeat(5); + assertEquals("-->-->-->-->-->", newString); + } + @Test void givenString_whenStringBuilderUsed_thenStringCreated() { StringBuilder builder = new StringBuilder(N); diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index d9da5a845b..809aa72966 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -107,7 +107,6 @@ core-java-streams-4 core-java-string-algorithms core-java-string-algorithms-2 - core-java-string-algorithms-3 core-java-string-apis core-java-string-conversions core-java-string-conversions-2 diff --git a/pom.xml b/pom.xml index a5b6b31022..f2a230357c 100644 --- a/pom.xml +++ b/pom.xml @@ -1333,6 +1333,7 @@ core-java-modules/core-java-io-conversions-2 core-java-modules/core-java-jpms core-java-modules/core-java-os + core-java-modules/core-java-string-algorithms-3 core-java-modules/core-java-string-operations-3 core-java-modules/core-java-string-operations-4 core-java-modules/core-java-time-measurements