Package com.vladsch.flexmark.test.util
Class TestUtils
java.lang.Object
com.vladsch.flexmark.test.util.TestUtils
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final String
static final @NotNull CharPredicate
static final DataKey
<BiFunction<String, String, DataHolder>> static final String
static final char
static final String
static final int[]
private static final DataHolder
static final String
static final String
static final String
static final String
static final DataKey
<Collection<Extension>> static final String
static final char
static final @NotNull CharPredicate
static final String
static final char
static final String
static final char
static final DataHolder
static final String
static final String
static final String
static final String
static final DataKey
<Collection<Class<? extends Extension>>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> MutableDataSet
addOption
(DataHolder options, DataKey<T> key, T value) static void
addSpecExample
(boolean useTestExample, boolean includeExampleStart, boolean toVisibleSpecText, StringBuilder sb, String source, String html, String ast, String optionsSet, boolean includeExampleCoords, String section, int number) static void
addSpecExample
(boolean includeExampleStart, boolean toVisibleSpecText, StringBuilder sb, String source, String html, String ast, String optionsSet, boolean includeExampleCoords, String section, int number) static void
addSpecExample
(boolean includeExampleStart, StringBuilder sb, String source, String html, String ast, String optionsSet, boolean includeExampleCoords, String section, int number) static String
addSpecExample
(boolean includeExampleStart, String source, String html, String ast, String optionsSet) static void
addSpecExample
(CharSequence exampleBreak, CharSequence sectionBreak, boolean includeExampleStart, boolean toVisibleSpecText, Appendable out, CharSequence source, CharSequence html, CharSequence ast, CharSequence optionsSet, boolean includeExampleCoords, CharSequence section, int number) static void
addSpecExample
(CharSequence exampleBreakOpen, CharSequence htmlBreak, CharSequence astBreak, CharSequence exampleBreakClose, boolean includeExampleStart, boolean toVisibleSpecText, Appendable out, CharSequence source, CharSequence html, CharSequence ast, CharSequence optionsSet, boolean includeExampleCoords, CharSequence section, CharSequence number, CharSequence exampleKeyword, CharSequence optionsKeyword) addSpecSection
(@NotNull String headingLine, @NotNull String headingText, String[] sectionHeadings) static String
adjustedFileUrl
(@NotNull URL url) static void
appendBanner
(@NotNull StringBuilder out, @NotNull String banner) static void
appendBanner
(@NotNull StringBuilder out, @NotNull String banner, boolean addBlankLine) static void
appendBannerIfNeeded
(@NotNull StringBuilder out, @NotNull String banner) static @NotNull String
static @NotNull String
bannerText
(@NotNull String message) buildOptionsMap
(boolean ensureAllBuiltInPresent, @NotNull Object[][] options, @NotNull BiFunction<ExampleOption, Object[], T> factory) Build options map, optionally ensuring all built-ins are presentbuildOptionsMap
(@NotNull String[] options, @NotNull BiFunction<ExampleOption, Integer, T> factory) static @Nullable DataHolder
combineDefaultOptions
(@Nullable DataHolder[] defaultOptions) static DataHolder
customIntOption
(@NotNull String option, @Nullable String params, @NotNull Function<Integer, DataHolder> resolver) static DataHolder
customStringOption
(@NotNull String option, @Nullable String params, @NotNull Function<String, DataHolder> resolver) static @Nullable DataHolder[]
dataHolders
(@Nullable DataHolder other, @Nullable DataHolder[] overrides) static Pair
<BasedSequence, int[]> extractMarkup
(BasedSequence input) static CharSequence
static String
static @NotNull String
getAbsoluteSpecResourcePath
(@NotNull String testClassPath, @NotNull String resourceRootPath, @NotNull String resourcePath) static @NotNull String
getFormattedSection
(String section, int exampleNumber) static String
getFormattedTimingInfo
(int iterations, long start, long parse, long render) static String
getFormattedTimingInfo
(String section, int exampleNumber, int iterations, long start, long parse, long render) static DataHolder
getOptions
(@NotNull SpecExample example, @Nullable String optionSets, @NotNull Function<String, DataHolder> optionsProvider) process comma separated list of option sets and combine them for final set to usestatic @NotNull String
getResolvedSpecResourcePath
(@NotNull String testClassName, @NotNull String resourcePath) static @NotNull String
getRootDirectoryForModule
(@NotNull Class<?> resourceClass, @NotNull String moduleDirectoryName) static @NotNull String
getSpecResourceFileUrl
(@NotNull Class<?> resourceClass, @NotNull String resourcePath) getTestData
(@NotNull ResourceLocation location) static @NotNull String
getTestResourceRootDirectoryForModule
(@NotNull Class<?> resourceClass, @NotNull String moduleRootPackage) static @NotNull String
getUrlWithLineNumber
(@NotNull String fileUrl, int lineNumber) static SequenceBuilder
insertCaretMarkup
(BasedSequence sequence, int[] offsets) static @Nullable Map
<String, ? extends DataHolder> optionsMaps
(@Nullable Map<String, ? extends DataHolder> other, @Nullable Map<String, ? extends DataHolder> overrides) static DataHolder
processOption
(@NotNull Map<String, ? extends DataHolder> optionsMap, @NotNull String option) static String
Deprecated.static BasedSequence
stripIndent
(BasedSequence input, CharSequence sourceIndent) static void
throwIgnoredOption
(@NotNull SpecExample example, @NotNull String optionSets, @NotNull String option) static void
throwIllegalStateException
(@NotNull SpecExample example, @NotNull String option) static CharSequence
static String
static String
trimTrailingEOL
(String parseSource) static String
unShowTabs
(String s) Deprecated.
-
Field Details
-
MARKUP_CARET_CHAR
public static final char MARKUP_CARET_CHAR- See Also:
-
MARKUP_SELECTION_START_CHAR
public static final char MARKUP_SELECTION_START_CHAR- See Also:
-
MARKUP_SELECTION_END_CHAR
public static final char MARKUP_SELECTION_END_CHAR- See Also:
-
MARKUP_CARET
-
MARKUP_SELECTION_START
-
MARKUP_SELECTION_END
-
CARET_PREDICATE
-
MARKUP_PREDICATE
-
EMPTY_OFFSETS
public static final int[] EMPTY_OFFSETS -
DISABLED_OPTION_PREFIX_CHAR
public static final char DISABLED_OPTION_PREFIX_CHAR- See Also:
-
DISABLED_OPTION_PREFIX
-
EMBED_TIMED_OPTION_NAME
- See Also:
-
FAIL_OPTION_NAME
- See Also:
-
FILE_EOL_OPTION_NAME
- See Also:
-
IGNORE_OPTION_NAME
- See Also:
-
NO_FILE_EOL_OPTION_NAME
- See Also:
-
TIMED_ITERATIONS_OPTION_NAME
- See Also:
-
TIMED_OPTION_NAME
- See Also:
-
EMBED_TIMED
-
FAIL
-
IGNORE
-
NO_FILE_EOL
-
TIMED
-
TIMED_ITERATIONS
-
TIMED_FORMAT_STRING
- See Also:
-
INCLUDED_DOCUMENT
-
SOURCE_PREFIX
-
SOURCE_SUFFIX
-
SOURCE_INDENT
-
NO_FILE_EOL_FALSE
-
UNLOAD_EXTENSIONS
-
LOAD_EXTENSIONS
-
EMPTY_OPTIONS
-
CUSTOM_OPTION
-
FILE_PROTOCOL
- See Also:
-
BANNER_PADDING
- See Also:
-
BANNER_LENGTH
public static final int BANNER_LENGTH
-
-
Constructor Details
-
TestUtils
public TestUtils()
-
-
Method Details
-
processOption
public static DataHolder processOption(@NotNull @NotNull Map<String, ? extends DataHolder> optionsMap, @NotNull @NotNull String option) -
buildOptionsMap
@NotNull public static <T> @NotNull HashMap<String,T> buildOptionsMap(@NotNull @NotNull String[] options, @NotNull @NotNull BiFunction<ExampleOption, Integer, T> factory) -
buildOptionsMap
@NotNull public static <T> @NotNull HashMap<String,T> buildOptionsMap(boolean ensureAllBuiltInPresent, @NotNull @NotNull Object[][] options, @NotNull @NotNull BiFunction<ExampleOption, Object[], T> factory) Build options map, optionally ensuring all built-ins are present- Type Parameters:
T
- type of value in the map- Parameters:
ensureAllBuiltInPresent
- if true, throws IllegalStateException if some built-in options are missingoptions
- array of object arrays, each row represents option values with first element ([0]) of each row being an option string. Each row is passed to factory to allow creating custom options.factory
- factory creating a type from ExampleOption and given row of parameters- Returns:
- constructed hash map of option name
-
addSpecSection
-
getOptions
public static DataHolder getOptions(@NotNull @NotNull SpecExample example, @Nullable @Nullable String optionSets, @NotNull @NotNull Function<String, DataHolder> optionsProvider) process comma separated list of option sets and combine them for final set to use- Parameters:
example
- spec example instance for which options are being processedoptionSets
- comma separate list of option set namesoptionsProvider
- function to take a string option name and provide settings based on it- Returns:
- combined set from applying these options together
-
addOption
-
throwIllegalStateException
public static void throwIllegalStateException(@NotNull @NotNull SpecExample example, @NotNull @NotNull String option) -
throwIgnoredOption
public static void throwIgnoredOption(@NotNull @NotNull SpecExample example, @NotNull @NotNull String optionSets, @NotNull @NotNull String option) -
ast
-
stripIndent
-
addSpecExample
-
addSpecExample
-
addSpecExample
-
addSpecExample
-
addSpecExample
public static void addSpecExample(CharSequence exampleBreak, CharSequence sectionBreak, boolean includeExampleStart, boolean toVisibleSpecText, Appendable out, CharSequence source, CharSequence html, CharSequence ast, CharSequence optionsSet, boolean includeExampleCoords, CharSequence section, int number) -
addSpecExample
public static void addSpecExample(CharSequence exampleBreakOpen, CharSequence htmlBreak, CharSequence astBreak, CharSequence exampleBreakClose, boolean includeExampleStart, boolean toVisibleSpecText, Appendable out, CharSequence source, CharSequence html, CharSequence ast, CharSequence optionsSet, boolean includeExampleCoords, CharSequence section, CharSequence number, CharSequence exampleKeyword, CharSequence optionsKeyword) -
showTabs
Deprecated.- Parameters:
s
- text to convert to visible chars- Returns:
- spec test special chars converted to visible
-
toVisibleSpecText
- Parameters:
s
- text to convert to visible chars- Returns:
- spec test special chars converted to visible
-
toVisibleSpecText
- Parameters:
s
- text to convert to visible chars- Returns:
- spec test special chars converted to visible
-
unShowTabs
Deprecated.- Parameters:
s
- text to convert to from visible chars to normal- Returns:
- spec test special visible chars converted to normal
-
fromVisibleSpecText
- Parameters:
s
- text to convert to from visible chars to normal- Returns:
- spec test special visible chars converted to normal
-
fromVisibleSpecText
- Parameters:
s
- text to convert to from visible chars to normal- Returns:
- spec test special visible chars converted to normal
-
trimTrailingEOL
-
getFormattedTimingInfo
-
getFormattedTimingInfo
-
getFormattedSection
-
getResolvedSpecResourcePath
-
getAbsoluteSpecResourcePath
-
getSpecResourceFileUrl
-
getTestData
-
getUrlWithLineNumber
-
adjustedFileUrl
-
combineDefaultOptions
@Nullable public static @Nullable DataHolder combineDefaultOptions(@Nullable @Nullable DataHolder[] defaultOptions) -
optionsMaps
@Nullable public static @Nullable Map<String,? extends DataHolder> optionsMaps(@Nullable @Nullable Map<String, ? extends DataHolder> other, @Nullable @Nullable Map<String, ? extends DataHolder> overrides) -
dataHolders
@Nullable public static @Nullable DataHolder[] dataHolders(@Nullable @Nullable DataHolder other, @Nullable @Nullable DataHolder[] overrides) -
getTestResourceRootDirectoryForModule
-
getRootDirectoryForModule
-
customStringOption
public static DataHolder customStringOption(@NotNull @NotNull String option, @Nullable @Nullable String params, @NotNull @NotNull Function<String, DataHolder> resolver) -
customIntOption
public static DataHolder customIntOption(@NotNull @NotNull String option, @Nullable @Nullable String params, @NotNull @NotNull Function<Integer, DataHolder> resolver) -
insertCaretMarkup
-
extractMarkup
-
bannerText
-
appendBanner
public static void appendBanner(@NotNull @NotNull StringBuilder out, @NotNull @NotNull String banner) -
appendBanner
public static void appendBanner(@NotNull @NotNull StringBuilder out, @NotNull @NotNull String banner, boolean addBlankLine) -
appendBannerIfNeeded
public static void appendBannerIfNeeded(@NotNull @NotNull StringBuilder out, @NotNull @NotNull String banner)
-
toVisibleSpecText(String)