mirror of
https://github.com/octoleo/plantuml.git
synced 2024-05-29 06:30:48 +00:00
c6cfd3cec6
For better readability and maintainability, use `@CsvSource` for: - Math tests - UrlBuilder tests _[FYI: `testGetUrl42` and `testGetUrl50` seems to be identical!, I suppress one]_
44 lines
2.9 KiB
Java
44 lines
2.9 KiB
Java
package net.sourceforge.plantuml;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
|
|
import org.junit.jupiter.params.ParameterizedTest;
|
|
import org.junit.jupiter.params.provider.CsvSource;
|
|
|
|
import net.sourceforge.plantuml.url.Url;
|
|
import net.sourceforge.plantuml.url.UrlBuilder;
|
|
import net.sourceforge.plantuml.url.UrlMode;
|
|
|
|
class UrlBuilderTest {
|
|
@ParameterizedTest
|
|
@CsvSource(value = {
|
|
" [[http://foo]], STRICT, http://foo, http://foo, http://foo ",
|
|
" [[http://foo{tooltip} text]], STRICT, http://foo, tooltip, text ",
|
|
" [[http://foo {tooltip} text]], STRICT, http://foo, tooltip, text ",
|
|
" [[http://foo {tooltip}]], STRICT, http://foo, tooltip, http://foo ",
|
|
" [[http://foo text]], STRICT, http://foo, http://foo, text ",
|
|
" [[ http://foo ]], STRICT, http://foo, http://foo, http://foo ",
|
|
" [[\"http://foo text\"]], STRICT, http://foo text, http://foo text, http://foo text ",
|
|
" start [[\"http://foo test\"]] end, ANYWHERE, http://foo test, http://foo test, http://foo test ",
|
|
" [[http://google.com{a nice toolip} <img:HelloWorld.png{scale=2}>]], STRICT, http://google.com, a nice toolip, <img:HelloWorld.png{scale=2}> ",
|
|
" [[http://google.com {a nice toolip} <img:HelloWorld.png{scale=2}>]], STRICT, http://google.com, a nice toolip, <img:HelloWorld.png{scale=2}> ",
|
|
" [[http://google.com <img:HelloWorld.png{scale=2}>]], STRICT, http://google.com, http://google.com, <img:HelloWorld.png{scale=2}> ",
|
|
" [[http://foo?dummy={123}&action=edit]], STRICT, http://foo?dummy={123}&action=edit, http://foo?dummy={123}&action=edit, http://foo?dummy={123}&action=edit",
|
|
" '[[http://www.plantuml.com{Json: {\"firstName\":\"Bob\", \"lastName\":\"Smith\"}}]]', STRICT, http://www.plantuml.com, 'Json: {\"firstName\":\"Bob\", \"lastName\":\"Smith\"}', http://www.plantuml.com",
|
|
" [[http://foo?dummy={123}z{}]], STRICT, http://foo?dummy=, 123}z{, http://foo?dummy= ",
|
|
" [[{tooltip} some text]], STRICT, '', tooltip, some text ",
|
|
" fromor [[www.google.com POST /session/csrStart]] end, ANYWHERE, www.google.com, www.google.com, POST /session/csrStart ",
|
|
" '[[ blaha(xyz,12){ tooltip } ]]', STRICT, 'blaha(xyz,12)', ' tooltip ', 'blaha(xyz,12)' ",
|
|
" '[[{Json: {\"firstName\":\"Bob\", \"lastName\":\"Smith\"}}]]', STRICT, '', 'Json: {\"firstName\":\"Bob\", \"lastName\":\"Smith\"}','' ",
|
|
" [[http://foo?dummy={123}{}]], STRICT, http://foo?dummy=, 123}{, http://foo?dummy= ",
|
|
" [[\"http://foo?dummy={123}\"{}]], STRICT, http://foo?dummy={123}, '', http://foo?dummy={123} ",
|
|
})
|
|
public void testUrl(String input, String urlMode, String urlLink, String tooltip, String label) {
|
|
final UrlBuilder b = new UrlBuilder(null, UrlMode.valueOf(urlMode));
|
|
final Url url = b.getUrl(input);
|
|
assertEquals(urlLink, url.getUrl(), "url");
|
|
assertEquals(tooltip, url.getTooltip(), "tooltip");
|
|
assertEquals(label, url.getLabel(), "label");
|
|
}
|
|
}
|