Package io.deephaven.engine.testutil
Class TstUtils
java.lang.Object
io.deephaven.engine.testutil.TstUtils
Utility functions to create and update test tables, compare results, and otherwise make unit testing more pleasant.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic class -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddToTable(Table table, Index index, ColumnHolder... columnHolders) static <T extends Throwable>
voidassertException(Class<T> clazz, Runnable r) static <T extends Throwable>
voidassertException(Class<T> clazz, Runnable r, String expectedMessage) static voidassertIndexEquals(@NotNull ReadOnlyIndex expected, @NotNull ReadOnlyIndex actual) static voidassertTableEquals(@NotNull Table expected, @NotNull Table actual, TableDiff.DiffItems... itemsToSkip) static voidassertTableEquals(String context, @NotNull Table expected, @NotNull Table actual, TableDiff.DiffItems... itemsToSkip) static voidassertTableEquals(String context, @NotNull Table expected, @NotNull Table actual, EnumSet<TableDiff.DiffItems> itemsToSkip) static <T> ColumnHoldercolGrouped(String name, T... data) static ColumnHoldercolumnHolderForChunk(String name, Class<?> type, Chunk<Attributes.Values> chunkData) Create a column holder from the given chunk.static voidfindMinimalTestCase(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.static ColumnHoldergetRandomBigDecimalCol(String colName, int size, Random random) static ColumnHoldergetRandomBigDecimalCol(String colName, int size, Random random, int precision, int scale) static ColumnHoldergetRandomBooleanArrayCol(String colName, int size, Random random, int maxSz) static ColumnHoldergetRandomBooleanCol(String colName, int size, Random random) static ColumnHoldergetRandomByteArrayCol(String colName, int size, Random random, int maxSz) static ColumnHoldergetRandomByteCol(String colName, int size, Random random) static ColumnHoldergetRandomCharArrayCol(String colName, int size, Random random, int maxSz) static ColumnHoldergetRandomCharCol(String colName, int size, Random random) static ColumnHoldergetRandomDateTimeCol(String colName, int size, Random random) static ColumnHoldergetRandomDoubleArrayCol(String colName, int size, Random random, int maxSz) static ColumnHoldergetRandomDoubleCol(String colName, int size, Random random) static ColumnHoldergetRandomFixedLengthByteArrayCol(String colName, int size, Random random, int arraySize) static ColumnHoldergetRandomFloatArrayCol(String colName, int size, Random random, int maxSz) static ColumnHoldergetRandomFloatCol(String colName, int size, Random random) static IndexgetRandomIndex(long minValue, int size, Random random) static ColumnHoldergetRandomIntArrayCol(String colName, int size, Random random, int maxSz) static ColumnHoldergetRandomIntCol(String colName, int size, Random random) static ColumnHoldergetRandomLongArrayCol(String colName, int size, Random random, int maxSz) static ColumnHoldergetRandomLongCol(String colName, int size, Random random) static ColumnHoldergetRandomShortArrayCol(String colName, int size, Random random, int maxSz) static ColumnHoldergetRandomShortCol(String colName, int size, Random random) static ColumnHoldergetRandomStringArrayCol(String colName, int size, Random random, int maxSz) static ColumnHoldergetRandomStringCol(String colName, int size, Random random) static ColumnHoldergetRandomStringSetCol(String colName, int size, Random random, int maxSz) static QueryTablegetTable(boolean refreshing, int size, Random random, TstUtils.ColumnInfo[] columnInfos) static QueryTablegetTable(int size, Random random, TstUtils.ColumnInfo[] columnInfos) static ColumnSource<?>getTestColumnSource(Index index, ColumnHolder columnHolder) static <T> ColumnHoldergroupedColumnHolderForChunk(String name, Class<?> type, Chunk<Attributes.Values> chunkData) Create a grouped column holder from the given chunk.static Indexi(long... keys) A shorthand for getIndexByValues for use in unit tests.static TstUtils.ColumnInfo[]initColumnInfos(String[] names, TestDataGenerator... generators) static TstUtils.ColumnInfo[]initColumnInfos(String[] names, TstUtils.ColumnInfo.ColAttributes[] attributes, TestDataGenerator... generators) static TstUtils.ColumnInfo[]initColumnInfos(String[] names, List<List<TstUtils.ColumnInfo.ColAttributes>> attributes, TestDataGenerator... generators) static Indexstatic Tablestatic TableprevTableColumnSources(Table table) static voidremoveRows(Table table, Index index) static IndexselectSubIndexSet(int size, Index sourceIndex, Random random) static QueryTabletestFlatRefreshingTable(Index index, ColumnHolder... columnHolders) static QueryTabletestRefreshingTable(ColumnHolder... columnHolders) static QueryTabletestRefreshingTable(Index index, ColumnHolder... columnHolders) static QueryTabletestTable(ColumnHolder... columnHolders) static QueryTabletestTable(Index index, ColumnHolder... columnHolders) static voidvalidate(EvalNuggetInterface[] en) static voidvalidate(String ctxt, EvalNuggetInterface[] en)
-
Field Details
-
TEST_DELTA_ZERO
public static final float TEST_DELTA_ZERO- See Also:
-
-
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 columntype- the type of the columnchunkData- 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 columntype- the type of the columnchunkData- the data in an chunk for this column- Returns:
- the new ColumnHolder with the grouping attribute set
-
i
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
-
removeRows
-
colGrouped
-
getRandomStringCol
-
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
-
getRandomIntCol
-
getRandomDoubleCol
-
getRandomFloatCol
-
getRandomShortCol
-
getRandomLongCol
-
getRandomBooleanCol
-
getRandomCharCol
-
getRandomByteCol
-
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
-
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
-
getRandomBigDecimalCol
public static ColumnHolder getRandomBigDecimalCol(String colName, int size, Random random, int precision, int scale) -
getRandomDateTimeCol
-
validate
-
validate
-
selectSubIndexSet
-
newIndex
-
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
-
getTable
public static QueryTable getTable(boolean refreshing, int size, Random random, TstUtils.ColumnInfo[] columnInfos) -
testTable
-
testTable
-
testRefreshingTable
-
testFlatRefreshingTable
-
testRefreshingTable
-
getTestColumnSource
-
prevTableColumnSources
-
prevTable
-
assertException
-
assertException
-
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.
-