Class TestUtils
java.lang.Object
com.vladsch.flexmark.test.util.TestUtils
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final Stringstatic final @NotNull CharPredicatestatic final DataKey<BiFunction<String, String, DataHolder>> static final Stringstatic final charstatic final Stringstatic final int[]private static final DataHolderstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final DataKey<Collection<Extension>> static final Stringstatic final charstatic final @NotNull CharPredicatestatic final Stringstatic final charstatic final Stringstatic final charstatic final DataHolderstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final DataKey<Collection<Class<? extends Extension>>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> MutableDataSetaddOption(DataHolder options, DataKey<T> key, T value) static voidaddSpecExample(boolean useTestExample, boolean includeExampleStart, boolean toVisibleSpecText, StringBuilder sb, String source, String html, String ast, String optionsSet, boolean includeExampleCoords, String section, int number) static voidaddSpecExample(boolean includeExampleStart, boolean toVisibleSpecText, StringBuilder sb, String source, String html, String ast, String optionsSet, boolean includeExampleCoords, String section, int number) static voidaddSpecExample(boolean includeExampleStart, StringBuilder sb, String source, String html, String ast, String optionsSet, boolean includeExampleCoords, String section, int number) static StringaddSpecExample(boolean includeExampleStart, String source, String html, String ast, String optionsSet) static voidaddSpecExample(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 voidaddSpecExample(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 StringadjustedFileUrl(@NotNull URL url) static voidappendBanner(@NotNull StringBuilder out, @NotNull String banner) static voidappendBanner(@NotNull StringBuilder out, @NotNull String banner, boolean addBlankLine) static voidappendBannerIfNeeded(@NotNull StringBuilder out, @NotNull String banner) static @NotNull Stringstatic @NotNull StringbannerText(@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 DataHoldercombineDefaultOptions(@Nullable DataHolder[] defaultOptions) static DataHoldercustomIntOption(@NotNull String option, @Nullable String params, @NotNull Function<Integer, DataHolder> resolver) static DataHoldercustomStringOption(@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 CharSequencestatic Stringstatic @NotNull StringgetAbsoluteSpecResourcePath(@NotNull String testClassPath, @NotNull String resourceRootPath, @NotNull String resourcePath) static @NotNull StringgetFormattedSection(String section, int exampleNumber) static StringgetFormattedTimingInfo(int iterations, long start, long parse, long render) static StringgetFormattedTimingInfo(String section, int exampleNumber, int iterations, long start, long parse, long render) static DataHoldergetOptions(@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 StringgetResolvedSpecResourcePath(@NotNull String testClassName, @NotNull String resourcePath) static @NotNull StringgetRootDirectoryForModule(@NotNull Class<?> resourceClass, @NotNull String moduleDirectoryName) static @NotNull StringgetSpecResourceFileUrl(@NotNull Class<?> resourceClass, @NotNull String resourcePath) getTestData(@NotNull ResourceLocation location) static @NotNull StringgetTestResourceRootDirectoryForModule(@NotNull Class<?> resourceClass, @NotNull String moduleRootPackage) static @NotNull StringgetUrlWithLineNumber(@NotNull String fileUrl, int lineNumber) static SequenceBuilderinsertCaretMarkup(BasedSequence sequence, int[] offsets) static @Nullable Map<String, ? extends DataHolder> optionsMaps(@Nullable Map<String, ? extends DataHolder> other, @Nullable Map<String, ? extends DataHolder> overrides) static DataHolderprocessOption(@NotNull Map<String, ? extends DataHolder> optionsMap, @NotNull String option) static StringDeprecated.static BasedSequencestripIndent(BasedSequence input, CharSequence sourceIndent) static voidthrowIgnoredOption(@NotNull SpecExample example, @NotNull String optionSets, @NotNull String option) static voidthrowIllegalStateException(@NotNull SpecExample example, @NotNull String option) static CharSequencestatic Stringstatic StringtrimTrailingEOL(String parseSource) static StringunShowTabs(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
-
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
-
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)