BAEL-3602 : Added test for formatted()

This commit is contained in:
sampada 2020-01-13 12:04:35 +05:30
parent 5d50eb7709
commit 64568471fc
1 changed files with 15 additions and 1 deletions

View File

@ -6,11 +6,13 @@ import org.junit.Test;
public class TextBlocksUnitTest { public class TextBlocksUnitTest {
private static final String JSON_STRING = "{\r\n" + "\"name\" : \"Baeldung\",\r\n" + "\"website\" : \"https://www.%s.com/\"\r\n" + "}";
@SuppressWarnings("preview") @SuppressWarnings("preview")
private static final String TEXT_BLOCK_JSON = """ private static final String TEXT_BLOCK_JSON = """
{ {
"name" : "Baeldung", "name" : "Baeldung",
"website" : "https://www.baeldung.com/" "website" : "https://www.%s.com/"
} }
"""; """;
@ -22,4 +24,16 @@ public class TextBlocksUnitTest {
assertThat(TEXT_BLOCK_JSON.length()).isGreaterThan(0); assertThat(TEXT_BLOCK_JSON.length()).isGreaterThan(0);
} }
@SuppressWarnings("removal")
@Test
public void whenTextBlocks_thenFormattedWorksAsFormat() {
assertThat(TEXT_BLOCK_JSON.formatted("baeldung")
.contains("www.baeldung.com")).isTrue();
assertThat(String.format(JSON_STRING, "baeldung")
.contains("www.baeldung.com")).isTrue();
}
} }