public class JTableFixture extends AbstractJPopupMenuInvokerFixture<JTableFixture,JTable,JTableDriver>
Supports functional testing of JTable
s.
The conversion between the values given in tests and the values being displayed by a JTable
renderer is
performed by a JTableCellReader
. This fixture uses a BasicJTableCellReader
by default.
BACKGROUND_PROPERTY, FONT_PROPERTY, FOREGROUND_PROPERTY
Constructor and Description |
---|
JTableFixture(Robot robot,
JTable target)
Creates a new
JTableFixture . |
JTableFixture(Robot robot,
String tableName)
Creates a new
JTableFixture . |
Modifier and Type | Method and Description |
---|---|
ColorFixture |
backgroundAt(TableCell cell)
Returns a fixture that verifies the background color of the given table cell.
|
JTableCellFixture |
cell(Pattern valuePattern)
Returns a
JTableCellFixture wrapping the table cell whose value matches the given regular expression
pattern. |
JTableCellFixture |
cell(String value)
Returns a
JTableCellFixture wrapping the table cell whose value matches the given one. |
JTableCellFixture |
cell(TableCell cell)
Returns a
JTableCellFixture wrapping the table cell specified by the given row and column. |
JTableCellFixture |
cell(TableCellFinder cellFinder)
Returns a
JTableCellFixture wrapping the table cell found by the given TableCellFinder . |
JTableFixture |
click(TableCell cell,
MouseButton button)
Simulates a user clicking a cell in this fixture's
JTable once, using the specified mouse button. |
JTableFixture |
click(TableCell cell,
MouseClickInfo mouseClickInfo)
Simulates a user clicking a cell in this fixture's
JTable , using the specified mouse button the given
number of times. |
int |
columnIndexFor(Object columnName)
Returns the index of the column in this fixture's
JTable whose name matches the given one. |
String[][] |
contents() |
protected JTableDriver |
createDriver(Robot robot) |
JTableFixture |
drag(TableCell cell)
Simulates a user dragging an item from this fixture's
JTable . |
JTableFixture |
drop(TableCell cell)
Simulates a user dropping an item to this fixture's
JTable . |
JTableFixture |
enterValue(TableCell cell,
String value)
Enters the given value in the given cell of this fixture's
JTable , using this fixture's
JTableCellWriter . |
FontFixture |
fontAt(TableCell cell)
Returns a fixture that verifies the font of the given table cell.
|
ColorFixture |
foregroundAt(TableCell cell)
Returns a fixture that verifies the foreground color of the given table cell.
|
Point |
pointAt(TableCell cell)
Converts the given cell into a coordinate pair.
|
void |
replaceCellReader(JTableCellReader cellReader) |
void |
replaceCellWriter(JTableCellWriter cellWriter) |
JTableFixture |
requireCellValue(TableCell cell,
Pattern pattern)
Asserts that the value of the given cell matches the given regular expression pattern.
|
JTableFixture |
requireCellValue(TableCell cell,
String value)
Asserts that the value of the given cell matches the given value.
|
JTableFixture |
requireColumnCount(int expected)
Asserts that this fixture's
JTable has the given number of columns. |
JTableFixture |
requireColumnNamed(String columnName)
Asserts that this fixture's
JTable contains a column whose name matches the given one. |
JTableFixture |
requireContents(String[][] contents)
Asserts that the
String representation of the cell values in this fixture's JTable is equal to the
given String array. |
JTableFixture |
requireEditable(TableCell cell)
Asserts that the given cell in this fixture's
JTable is editable. |
JTableFixture |
requireNoSelection()
Verifies that this fixture's
JTable does not have any selection. |
JTableFixture |
requireNotEditable(TableCell cell)
Asserts that the given cell in this fixture's
JTable is not editable. |
JTableFixture |
requireRowCount(int expected)
Asserts that this fixture's
JTable has the given number of rows. |
JTableFixture |
requireSelectedRows(int... rows)
Asserts that the set of selected rows in this fixture's
JTable contains to the given row indices. |
int |
rowCount()
Returns the number of rows that can be shown in this fixture's
JTable , given unlimited space. |
JTableFixture |
selectCell(TableCell cell)
Simulates a user selecting the given cell (row and column) of this fixture's
JTable . |
JTableFixture |
selectCells(TableCell... cells)
Simulates a user selecting the given cells of this fixture's
JTable . |
String |
selectionValue()
Returns the
String representation of the selected cell in this fixture's JTable , using this
fixture's JTableCellReader . |
JTableFixture |
selectRows(int... rows)
Simulates a user selecting the given rows in this fixture's
JTable . |
JPopupMenuFixture |
showPopupMenuAt(TableCell cell)
Shows a pop-up menu at the given cell.
|
JTableHeaderFixture |
tableHeader() |
JTableFixture |
unselectCell(TableCell cell)
Simulates a user unselecting the given cell (row and column) of this fixture's
JTable . |
JTableFixture |
unselectCells(TableCell... cells)
Simulates a user unselecting the given cells of this fixture's
JTable . |
JTableFixture |
unselectRows(int... rows)
Simulates a user unselecting the given rows in this fixture's
JTable . |
String |
valueAt(TableCell cell)
Returns the
String representation of the value of a cell in this fixture's JTable , using this
fixture's JTableCellReader . |
showPopupMenu, showPopupMenuAt
clientProperty, requireToolTip, requireToolTip
background, click, click, click, doubleClick, driver, drop, equals, focus, font, foreground, hashCode, isEnabled, myself, pressAndReleaseKey, pressAndReleaseKeys, pressKey, pressKeyWhileRunning, releaseKey, replaceDriverWith, requireDisabled, requireEnabled, requireEnabled, requireFocused, requireNotVisible, requireShowing, requireVisible, rightClick, robot, target, targetCastedTo
public JTableFixture(@Nonnull Robot robot, @Nonnull JTable target)
JTableFixture
.robot
- performs simulation of user events on the given JTable
.target
- the JTable
to be managed by this fixture.NullPointerException
- if robot
is null
.NullPointerException
- if target
is null
.public JTableFixture(@Nonnull Robot robot, @Nullable String tableName)
JTableFixture
.robot
- performs simulation of user events on a JTable
.tableName
- the name of the JTable
to find using the given Robot
.NullPointerException
- if robot
is null
.ComponentLookupException
- if a matching JTable
could not be found. Or if
more than one matching JTable
is found.@Nonnull protected JTableDriver createDriver(@Nonnull Robot robot)
createDriver
in class AbstractComponentFixture<JTableFixture,JTable,JTableDriver>
public FontFixture fontAt(@Nonnull TableCell cell)
cell
- the given table cell.NullPointerException
- if the cell is null
.IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.@Nonnull public ColorFixture backgroundAt(@Nonnull TableCell cell)
cell
- the given table cell.NullPointerException
- if the cell is null
.IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.@Nonnull public ColorFixture foregroundAt(@Nonnull TableCell cell)
cell
- the given table cell.NullPointerException
- if the cell is null
.IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.@Nonnull public JTableCellFixture cell(String value)
JTableCellFixture
wrapping the table cell whose value matches the given one.value
- the value of the cell to look for. It can be a regular expression.JTableCellFixture
wrapping the table cell whose value matches the given one.ActionFailedException
- if a cell with a matching value cannot be found.@Nonnull public JTableCellFixture cell(@Nonnull Pattern valuePattern)
JTableCellFixture
wrapping the table cell whose value matches the given regular expression
pattern.valuePattern
- the regular expression pattern to match.JTableCellFixture
wrapping the table cell whose value matches the given regular expression
pattern.NullPointerException
- if the given regular expression pattern is null
.ActionFailedException
- if a cell with a matching value cannot be found.@Nonnull public JTableCellFixture cell(@Nonnull TableCellFinder cellFinder)
JTableCellFixture
wrapping the table cell found by the given TableCellFinder
.cellFinder
- knows how to find a cell.JTableCellFixture
wrapping the table cell found by the given TableCellFinder
NullPointerException
- if the TableCellFinder
is null
.ActionFailedException
- if a matching cell could not be found.IndexOutOfBoundsException
- if the row or column indices in the found cell are out of bounds.@Nonnull public JTableCellFixture cell(@Nonnull TableCell cell)
JTableCellFixture
wrapping the table cell specified by the given row and column.cell
- the cell of interest.JTableCellFixture
wrapping the table cell specified by the given row and column.NullPointerException
- if the cell is null
.IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.@Nonnull public JTableHeaderFixture tableHeader()
JTableHeaderFixture
wrapping the JTableHeader
in this fixture's JTable
.AssertionError
- if the JTableHeader
in this fixture's JTable
is null
.@Nullable public String selectionValue()
String
representation of the selected cell in this fixture's JTable
, using this
fixture's JTableCellReader
. Returns null
if one can not be obtained or if
the JTable
does not have any selected cell.String
representation of the selected cell.replaceCellReader(JTableCellReader)
@Nonnull public Point pointAt(@Nonnull TableCell cell)
cell
- the given cell.NullPointerException
- if the cell is null
.IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.@Nonnull public String[][] contents()
String
representation of the cells in the cells in this fixture's JTable
, using this
fixture's JTableCellReader
.replaceCellReader(JTableCellReader)
public int rowCount()
JTable
, given unlimited space.JTable
.JTable.getRowCount()
@Nullable public String valueAt(@Nonnull TableCell cell)
String
representation of the value of a cell in this fixture's JTable
, using this
fixture's JTableCellReader
.cell
- the given cell.String
representation of the value of a cell in this fixture's JTable
.NullPointerException
- if the cell is null
.IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.replaceCellReader(JTableCellReader)
@Nonnull public JTableFixture selectCell(@Nonnull TableCell cell)
JTable
.cell
- the cell to select.NullPointerException
- if the cell is null
.IllegalStateException
- if this fixture's JTable
is disabled.IllegalStateException
- if this fixture's JTable
is not showing on the screen.IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.@Nonnull public JTableFixture selectCells(@Nonnull TableCell... cells)
JTable
.cells
- the cells to select.NullPointerException
- if cells
is null
or empty.IllegalArgumentException
- if cells
is null
or empty.IllegalStateException
- if this fixture's JTable
is disabled.IllegalStateException
- if this fixture's JTable
is not showing on the screen.NullPointerException
- if any element in cells
is null
.IndexOutOfBoundsException
- if any of the indices of any of the cells
are out of bounds.@Nonnull public JTableFixture selectRows(@Nonnull int... rows)
JTable
.rows
- the indices of the row to select.NullPointerException
- if the given array of indices is null
.IllegalArgumentException
- if the given array of indices is empty.IllegalStateException
- if this fixture's JTable
is disabled.IllegalStateException
- if this fixture's JTable
is not showing on the screen.IndexOutOfBoundsException
- if any of the given indices is out of bounds.@Nonnull public JTableFixture unselectCell(@Nonnull TableCell cell)
JTable
.cell
- the cell to unselect.NullPointerException
- if the cell is null
.IllegalStateException
- if this fixture's JTable
is disabled.IllegalStateException
- if this fixture's JTable
is not showing on the screen.IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.@Nonnull public JTableFixture unselectCells(@Nonnull TableCell... cells)
JTable
.cells
- the cells to unselect.NullPointerException
- if cells
is null
or empty.IllegalArgumentException
- if cells
is null
or empty.IllegalStateException
- if this fixture's JTable
is disabled.IllegalStateException
- if this fixture's JTable
is not showing on the screen.NullPointerException
- if any element in cells
is null
.IndexOutOfBoundsException
- if any of the indices of any of the cells
are out of bounds.@Nonnull public JTableFixture unselectRows(@Nonnull int... rows)
JTable
.rows
- the indices of the row to unselect.NullPointerException
- if the given array of indices is null
.IllegalArgumentException
- if the given array of indices is empty.IllegalStateException
- if this fixture's JTable
is disabled.IllegalStateException
- if this fixture's JTable
is not showing on the screen.IndexOutOfBoundsException
- if any of the given indices is out of bounds.@Nonnull public JTableFixture drag(@Nonnull TableCell cell)
JTable
.cell
- the cell to drag.NullPointerException
- if the cell is null
.IllegalStateException
- if this fixture's JTable
is disabled.IllegalStateException
- if this fixture's JTable
is not showing on the screen.IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.@Nonnull public JTableFixture drop(@Nonnull TableCell cell)
JTable
.cell
- the cell to drop the dragging item into.NullPointerException
- if the cell is null
.IllegalStateException
- if this fixture's JTable
is disabled.IllegalStateException
- if this fixture's JTable
is not showing on the screen.IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.@Nonnull public JTableFixture click(@Nonnull TableCell cell, @Nonnull MouseButton button)
JTable
once, using the specified mouse button.cell
- the cell to click.button
- the mouse button to use.NullPointerException
- if the cell is null
.IllegalStateException
- if this fixture's JTable
is disabled.IllegalStateException
- if this fixture's JTable
is not showing on the screen.IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.@Nonnull public JTableFixture click(@Nonnull TableCell cell, @Nonnull MouseClickInfo mouseClickInfo)
JTable
, using the specified mouse button the given
number of times.cell
- the cell to click.mouseClickInfo
- specifies the mouse button to use and how many times to click.NullPointerException
- if the given MouseClickInfo
is null
.NullPointerException
- if the cell is null
.IllegalStateException
- if this fixture's JTable
is disabled.IllegalStateException
- if this fixture's JTable
is not showing on the screen.IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.@Nonnull public JTableFixture enterValue(@Nonnull TableCell cell, @Nonnull String value)
JTable
, using this fixture's
JTableCellWriter
. If you need more flexibility for editing cell, please see
JTableCellFixture.editor()
.cell
- the given cell.value
- the given value.NullPointerException
- if the cell is null
.IllegalStateException
- if this fixture's JTable
is disabled.IllegalStateException
- if this fixture's JTable
is not showing on the screen.IllegalStateException
- if this fixture's JTable
is not editable.IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.ActionFailedException
- if this fixture's JTableCellValueReader
is unable
to enter the given value.replaceCellWriter(JTableCellWriter)
,
JTableCellFixture.editor()
public void replaceCellReader(@Nonnull JTableCellReader cellReader)
@Nonnull public JTableFixture requireRowCount(int expected)
JTable
has the given number of rows.expected
- the expected number of rows.AssertionError
- if this fixture's JTable
does not have the given number of rows.@Nonnull public JTableFixture requireSelectedRows(@Nonnull int... rows)
JTable
contains to the given row indices. The given
row indices can be a subset of all the selected rows in a JTable
.rows
- the indices of the rows expected to be selected.AssertionError
- if the set of selected rows in this fixture's JTable
(if any) do not contain the
given indices.@Nonnull public JTableFixture requireColumnCount(int expected)
JTable
has the given number of columns.expected
- the expected number of columns.AssertionError
- if this fixture's JTable
does not have the given number of columns.@Nonnull public JTableFixture requireEditable(@Nonnull TableCell cell)
JTable
is editable.cell
- the given cell.NullPointerException
- if the cell is null
.IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.AssertionError
- if the given cell is not editable.@Nonnull public JTableFixture requireNotEditable(@Nonnull TableCell cell)
JTable
is not editable.cell
- the given cell.NullPointerException
- if the cell is null
.IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.AssertionError
- if the given cell is editable.@Nonnull public JTableFixture requireNoSelection()
JTable
does not have any selection.AssertionError
- if this fixture's JTable
has a selection.@Nonnull public JTableFixture requireCellValue(@Nonnull TableCell cell, @Nullable String value)
cell
- the given table cell.value
- the expected value. It can be a regular expression.NullPointerException
- if the cell is null
.IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.AssertionError
- if the value of the given cell does not match the given value.@Nonnull public JTableFixture requireCellValue(@Nonnull TableCell cell, @Nonnull Pattern pattern)
cell
- the given table cell.pattern
- the regular expression pattern to match.NullPointerException
- if the cell is null
.NullPointerException
- if the given regular expression pattern is null
.IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.AssertionError
- if the value of the given cell does not match the given regular expression pattern.@Nonnull public JTableFixture requireContents(@Nonnull String[][] contents)
String
representation of the cell values in this fixture's JTable
is equal to the
given String
array. This method uses this fixture's JTableCellReader
to read the values of the
table cells as String
s.contents
- the expected String
representation of the cell values in this fixture's JTable
.replaceCellReader(JTableCellReader)
public void replaceCellWriter(JTableCellWriter cellWriter)
public int columnIndexFor(@Nonnull Object columnName)
JTable
whose name matches the given one.columnName
- the name of the column to look for.ActionFailedException
- if a column with a matching name could not be found.public JTableFixture requireColumnNamed(String columnName)
JTable
contains a column whose name matches the given one.columnName
- the name of the column to look for.ActionFailedException
- if a column with a matching name could not be found.@Nonnull public JPopupMenuFixture showPopupMenuAt(@Nonnull TableCell cell)
cell
- the table cell where to show the pop-up menu.NullPointerException
- if the cell is null
.IllegalStateException
- if this fixture's JTable
is disabled.IllegalStateException
- if this fixture's JTable
is not showing on the screen.ComponentLookupException
- if a pop-up menu cannot be found.Copyright © 2014–2017 AssertJ. All rights reserved.