Class TestUtils

java.lang.Object
com.vladsch.flexmark.test.util.TestUtils

public class TestUtils extends Object
  • Field Details

  • 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 missing
      options - 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

      @NotNull public static @NotNull Pair<String,Integer> addSpecSection(@NotNull @NotNull String headingLine, @NotNull @NotNull String headingText, String[] sectionHeadings)
    • 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 processed
      optionSets - comma separate list of option set names
      optionsProvider - function to take a string option name and provide settings based on it
      Returns:
      combined set from applying these options together
    • addOption

      public static <T> MutableDataSet addOption(DataHolder options, DataKey<T> key, T value)
    • 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

      @NotNull public static @NotNull String ast(@NotNull @NotNull Node node)
    • stripIndent

      public static BasedSequence stripIndent(BasedSequence input, CharSequence sourceIndent)
    • addSpecExample

      public static String addSpecExample(boolean includeExampleStart, String source, String html, String ast, String optionsSet)
    • addSpecExample

      public static void addSpecExample(boolean includeExampleStart, StringBuilder sb, String source, String html, String ast, String optionsSet, boolean includeExampleCoords, String section, int number)
    • addSpecExample

      public static void addSpecExample(boolean includeExampleStart, boolean toVisibleSpecText, StringBuilder sb, String source, String html, String ast, String optionsSet, boolean includeExampleCoords, String section, int number)
    • addSpecExample

      public 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)
    • 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 public static String showTabs(String s)
      Deprecated.
      Parameters:
      s - text to convert to visible chars
      Returns:
      spec test special chars converted to visible
    • toVisibleSpecText

      public static String toVisibleSpecText(String s)
      Parameters:
      s - text to convert to visible chars
      Returns:
      spec test special chars converted to visible
    • toVisibleSpecText

      public static CharSequence toVisibleSpecText(CharSequence s)
      Parameters:
      s - text to convert to visible chars
      Returns:
      spec test special chars converted to visible
    • unShowTabs

      @Deprecated public static String unShowTabs(String s)
      Parameters:
      s - text to convert to from visible chars to normal
      Returns:
      spec test special visible chars converted to normal
    • fromVisibleSpecText

      public static String fromVisibleSpecText(String s)
      Parameters:
      s - text to convert to from visible chars to normal
      Returns:
      spec test special visible chars converted to normal
    • fromVisibleSpecText

      public static CharSequence fromVisibleSpecText(CharSequence s)
      Parameters:
      s - text to convert to from visible chars to normal
      Returns:
      spec test special visible chars converted to normal
    • trimTrailingEOL

      public static String trimTrailingEOL(String parseSource)
    • getFormattedTimingInfo

      public static String getFormattedTimingInfo(int iterations, long start, long parse, long render)
    • getFormattedTimingInfo

      public static String getFormattedTimingInfo(String section, int exampleNumber, int iterations, long start, long parse, long render)
    • getFormattedSection

      @NotNull public static @NotNull String getFormattedSection(String section, int exampleNumber)
    • getResolvedSpecResourcePath

      @NotNull public static @NotNull String getResolvedSpecResourcePath(@NotNull @NotNull String testClassName, @NotNull @NotNull String resourcePath)
    • getAbsoluteSpecResourcePath

      @NotNull public static @NotNull String getAbsoluteSpecResourcePath(@NotNull @NotNull String testClassPath, @NotNull @NotNull String resourceRootPath, @NotNull @NotNull String resourcePath)
    • getSpecResourceFileUrl

      @NotNull public static @NotNull String getSpecResourceFileUrl(@NotNull @NotNull Class<?> resourceClass, @NotNull @NotNull String resourcePath)
    • getTestData

      public static ArrayList<Object[]> getTestData(@NotNull @NotNull ResourceLocation location)
    • getUrlWithLineNumber

      @NotNull public static @NotNull String getUrlWithLineNumber(@NotNull @NotNull String fileUrl, int lineNumber)
    • adjustedFileUrl

      public static String adjustedFileUrl(@NotNull @NotNull URL url)
    • 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

      @NotNull public static @NotNull String getTestResourceRootDirectoryForModule(@NotNull @NotNull Class<?> resourceClass, @NotNull @NotNull String moduleRootPackage)
    • getRootDirectoryForModule

      @NotNull public static @NotNull String getRootDirectoryForModule(@NotNull @NotNull Class<?> resourceClass, @NotNull @NotNull String moduleDirectoryName)
    • 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

      public static SequenceBuilder insertCaretMarkup(BasedSequence sequence, int[] offsets)
    • extractMarkup

      public static Pair<BasedSequence,int[]> extractMarkup(BasedSequence input)
    • bannerText

      @NotNull public static @NotNull String bannerText(@NotNull @NotNull String message)
    • 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)