BAEL-3602 : Added test for formatted()

This commit is contained in:
sampada
2020-01-13 12:04:35 +05:30
parent 3f61fa10a9
commit d1db78f5c1

View File

@@ -6,11 +6,13 @@ import org.junit.Test;
public class TextBlocksUnitTest {
private static final String JSON_STRING = "{\r\n" + "\"name\" : \"Baeldung\",\r\n" + "\"website\" : \"https://www.%s.com/\"\r\n" + "}";
@SuppressWarnings("preview")
private static final String TEXT_BLOCK_JSON = """
{
"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);
}
@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();
}
}