Skip to content

Commit 6456847

Browse files
author
sampada
committed
BAEL-3602 : Added test for formatted()
1 parent 5d50eb7 commit 6456847

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

core-java-modules/core-java-13/src/test/java/com/baeldung/newfeatures/TextBlocksUnitTest.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66

77
public class TextBlocksUnitTest {
88

9+
private static final String JSON_STRING = "{\r\n" + "\"name\" : \"Baeldung\",\r\n" + "\"website\" : \"https://www.%s.com/\"\r\n" + "}";
10+
911
@SuppressWarnings("preview")
1012
private static final String TEXT_BLOCK_JSON = """
1113
{
1214
"name" : "Baeldung",
13-
"website" : "https://www.baeldung.com/"
15+
"website" : "https://www.%s.com/"
1416
}
1517
""";
1618

@@ -22,4 +24,16 @@ public void whenTextBlocks_thenStringOperationsWork() {
2224
assertThat(TEXT_BLOCK_JSON.length()).isGreaterThan(0);
2325

2426
}
27+
28+
@SuppressWarnings("removal")
29+
@Test
30+
public void whenTextBlocks_thenFormattedWorksAsFormat() {
31+
assertThat(TEXT_BLOCK_JSON.formatted("baeldung")
32+
.contains("www.baeldung.com")).isTrue();
33+
34+
assertThat(String.format(JSON_STRING, "baeldung")
35+
.contains("www.baeldung.com")).isTrue();
36+
37+
}
38+
2539
}

0 commit comments

Comments
 (0)