Class TstUtils

java.lang.Object
io.deephaven.engine.testutil.TstUtils

public class TstUtils extends Object
Utility functions to create and update test tables, compare results, and otherwise make unit testing more pleasant.
  • Field Details

  • Constructor Details

    • TstUtils

      public TstUtils()
  • Method Details

    • columnHolderForChunk

      public static ColumnHolder columnHolderForChunk(String name, Class<?> type, Chunk<Attributes.Values> chunkData)
      Create a column holder from the given chunk.
      Parameters:
      name - the name of the column
      type - the type of the column
      chunkData - the data in an chunk for this column
      Returns:
      the new ColumnHolder
    • groupedColumnHolderForChunk

      public static <T> ColumnHolder groupedColumnHolderForChunk(String name, Class<?> type, Chunk<Attributes.Values> chunkData)
      Create a grouped column holder from the given chunk.
      Parameters:
      name - the name of the column
      type - the type of the column
      chunkData - the data in an chunk for this column
      Returns:
      the new ColumnHolder with the grouping attribute set
    • i

      public static Index i(long... keys)
      A shorthand for getIndexByValues for use in unit tests.
      Parameters:
      keys - the keys of the new index
      Returns:
      a new index with the given keys
    • addToTable

      public static void addToTable(Table table, Index index, ColumnHolder... columnHolders)
    • removeRows

      public static void removeRows(Table table, Index index)
    • colGrouped

      public static <T> ColumnHolder colGrouped(String name, T... data)
    • getRandomStringCol

      public static ColumnHolder getRandomStringCol(String colName, int size, Random random)
    • getRandomStringArrayCol

      public static ColumnHolder getRandomStringArrayCol(String colName, int size, Random random, int maxSz)
    • getRandomStringSetCol

      public static ColumnHolder getRandomStringSetCol(String colName, int size, Random random, int maxSz)
    • getRandomIndex

      public static Index getRandomIndex(long minValue, int size, Random random)
    • getRandomIntCol

      public static ColumnHolder getRandomIntCol(String colName, int size, Random random)
    • getRandomDoubleCol

      public static ColumnHolder getRandomDoubleCol(String colName, int size, Random random)
    • getRandomFloatCol

      public static ColumnHolder getRandomFloatCol(String colName, int size, Random random)
    • getRandomShortCol

      public static ColumnHolder getRandomShortCol(String colName, int size, Random random)
    • getRandomLongCol

      public static ColumnHolder getRandomLongCol(String colName, int size, Random random)
    • getRandomBooleanCol

      public static ColumnHolder getRandomBooleanCol(String colName, int size, Random random)
    • getRandomCharCol

      public static ColumnHolder getRandomCharCol(String colName, int size, Random random)
    • getRandomByteCol

      public static ColumnHolder getRandomByteCol(String colName, int size, Random random)
    • getRandomByteArrayCol

      public static ColumnHolder getRandomByteArrayCol(String colName, int size, Random random, int maxSz)
    • getRandomFixedLengthByteArrayCol

      public static ColumnHolder getRandomFixedLengthByteArrayCol(String colName, int size, Random random, int arraySize)
    • getRandomBooleanArrayCol

      public static ColumnHolder getRandomBooleanArrayCol(String colName, int size, Random random, int maxSz)
    • getRandomIntArrayCol

      public static ColumnHolder getRandomIntArrayCol(String colName, int size, Random random, int maxSz)
    • getRandomLongArrayCol

      public static ColumnHolder getRandomLongArrayCol(String colName, int size, Random random, int maxSz)
    • getRandomShortArrayCol

      public static ColumnHolder getRandomShortArrayCol(String colName, int size, Random random, int maxSz)
    • getRandomDoubleArrayCol

      public static ColumnHolder getRandomDoubleArrayCol(String colName, int size, Random random, int maxSz)
    • getRandomFloatArrayCol

      public static ColumnHolder getRandomFloatArrayCol(String colName, int size, Random random, int maxSz)
    • getRandomCharArrayCol

      public static ColumnHolder getRandomCharArrayCol(String colName, int size, Random random, int maxSz)
    • getRandomBigDecimalCol

      public static ColumnHolder getRandomBigDecimalCol(String colName, int size, Random random)
    • getRandomBigDecimalCol

      public static ColumnHolder getRandomBigDecimalCol(String colName, int size, Random random, int precision, int scale)
    • getRandomDateTimeCol

      public static ColumnHolder getRandomDateTimeCol(String colName, int size, Random random)
    • validate

      public static void validate(EvalNuggetInterface[] en)
    • validate

      public static void validate(String ctxt, EvalNuggetInterface[] en)
    • selectSubIndexSet

      public static Index selectSubIndexSet(int size, Index sourceIndex, Random random)
    • newIndex

      public static Index newIndex(int targetSize, Index sourceIndex, Random random)
    • initColumnInfos

      public static TstUtils.ColumnInfo[] initColumnInfos(String[] names, TestDataGenerator... generators)
    • initColumnInfos

      public static TstUtils.ColumnInfo[] initColumnInfos(String[] names, TstUtils.ColumnInfo.ColAttributes[] attributes, TestDataGenerator... generators)
    • initColumnInfos

      public static TstUtils.ColumnInfo[] initColumnInfos(String[] names, List<List<TstUtils.ColumnInfo.ColAttributes>> attributes, TestDataGenerator... generators)
    • getTable

      public static QueryTable getTable(int size, Random random, TstUtils.ColumnInfo[] columnInfos)
    • getTable

      public static QueryTable getTable(boolean refreshing, int size, Random random, TstUtils.ColumnInfo[] columnInfos)
    • testTable

      public static QueryTable testTable(ColumnHolder... columnHolders)
    • testTable

      public static QueryTable testTable(Index index, ColumnHolder... columnHolders)
    • testRefreshingTable

      public static QueryTable testRefreshingTable(Index index, ColumnHolder... columnHolders)
    • testFlatRefreshingTable

      public static QueryTable testFlatRefreshingTable(Index index, ColumnHolder... columnHolders)
    • testRefreshingTable

      public static QueryTable testRefreshingTable(ColumnHolder... columnHolders)
    • getTestColumnSource

      public static ColumnSource<?> getTestColumnSource(Index index, ColumnHolder columnHolder)
    • prevTableColumnSources

      public static Table prevTableColumnSources(Table table)
    • prevTable

      public static Table prevTable(Table table)
    • assertException

      public static <T extends Throwable> void assertException(Class<T> clazz, Runnable r)
    • assertException

      public static <T extends Throwable> void assertException(Class<T> clazz, Runnable r, String expectedMessage)
    • assertIndexEquals

      public static void assertIndexEquals(@NotNull @NotNull ReadOnlyIndex expected, @NotNull @NotNull ReadOnlyIndex actual)
    • assertTableEquals

      public static void assertTableEquals(@NotNull @NotNull Table expected, @NotNull @NotNull Table actual, TableDiff.DiffItems... itemsToSkip)
    • assertTableEquals

      public static void assertTableEquals(String context, @NotNull @NotNull Table expected, @NotNull @NotNull Table actual, TableDiff.DiffItems... itemsToSkip)
    • assertTableEquals

      public static void assertTableEquals(String context, @NotNull @NotNull Table expected, @NotNull @NotNull Table actual, EnumSet<TableDiff.DiffItems> itemsToSkip)
    • findMinimalTestCase

      public static void findMinimalTestCase(Object test, int initialSeed, int maxSeed, int initialSteps, BiConsumer<Integer,org.apache.commons.lang3.mutable.MutableInt> runner)
      Reruns test cases trying new seeds while minimizing the number of steps to catch the failing test. The test should mutate the provided MutableInt so that when it fails it is equal to the current step iteration. This allows the test to minimize the total number of steps per seed as it discovers better candidate parameters.
      Parameters:
      test - A test instance to tearDown and setUp between each test.
      initialSeed - The seed to begin using.
      maxSeed - The highest seed to try.
      initialSteps - Number of steps to start with.
      runner - A method whose first param is the random seed to use, and second parameter is the number of steps.