File tree Expand file tree Collapse file tree
core-java-modules/core-java-13/src/test/java/com/baeldung/newfeatures Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66
77public 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}
You can’t perform that action at this time.
0 commit comments