Package org.testfx.matcher.control
Class TableViewMatchers
- java.lang.Object
-
- org.testfx.matcher.control.TableViewMatchers
-
public class TableViewMatchers extends java.lang.ObjectTestFX matchers forTableViewcontrols.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringSELECTOR_TABLE_CELL
-
Constructor Summary
Constructors Modifier Constructor Description privateTableViewMatchers()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static org.hamcrest.Matcher<javafx.scene.control.TableView>containsRow(java.lang.Object... cells)Creates a matcher that matches allTableViews that have at least one row that contains the given values for each column of aTableView.private static <T> booleancontainsRow(javafx.scene.control.TableView<T> tableView, java.lang.Object... cells)static org.hamcrest.Matcher<javafx.scene.control.TableView>containsRowAtIndex(int rowIndex, java.lang.Object... cells)Creates a matcher that matches allTableViews that have a row at the givenindexthat contains the given values for each column of aTableView.private static <T> booleancontainsRowAtIndex(javafx.scene.control.TableView<T> tableView, int rowIndex, java.lang.Object... cells)private static java.util.List<javafx.beans.value.ObservableValue<?>>getRowValues(javafx.scene.control.TableView<?> tableView, int rowIndex)private static booleanhasCellValue(javafx.scene.control.Cell cell, java.lang.Object value)static org.hamcrest.Matcher<javafx.scene.control.TableView>hasItems(int rows)Deprecated.UsehasNumRows(int amount)instead.private static booleanhasItemValue(java.lang.Object item, java.lang.Object value)static org.hamcrest.Matcher<javafx.scene.control.TableView>hasNumRows(int rows)Creates a matcher that matches allTableViews that have exactlyamountrows.static org.hamcrest.Matcher<javafx.scene.control.TableView>hasTableCell(java.lang.Object value)Creates a matcher that matches allTableViews that has aTableCellwhose value orvalue.toString()equals the given value.private static booleanhasTableCell(javafx.scene.control.TableView tableView, java.lang.Object value)private static java.lang.StringtoText(javafx.scene.control.TableView<?> tableView)Returns a textual representation of all rows of the giventableView.private static java.lang.StringtoText(javafx.scene.control.TableView<?> tableView, int rowIndex)Returns a textual representation of one row (specified byrowIndex) of the giventableView.
-
-
-
Field Detail
-
SELECTOR_TABLE_CELL
private static final java.lang.String SELECTOR_TABLE_CELL
- See Also:
- Constant Field Values
-
-
Method Detail
-
hasTableCell
public static org.hamcrest.Matcher<javafx.scene.control.TableView> hasTableCell(java.lang.Object value)
Creates a matcher that matches allTableViews that has aTableCellwhose value orvalue.toString()equals the given value.Test code must ensure that the cell is visible by scrolling it into the viewport before using the matcher:
int row = ... int col = ... tableView.scrollTo(row); tableView.scrollToColumn(col); verifyThat(tableView, hasTableCell(contentOfCell);
-
hasItems
@Deprecated public static org.hamcrest.Matcher<javafx.scene.control.TableView> hasItems(int rows)
Deprecated.UsehasNumRows(int amount)instead.Creates a matcher that matches allTableViews that have exactlyamountitems.
-
hasNumRows
public static org.hamcrest.Matcher<javafx.scene.control.TableView> hasNumRows(int rows)
Creates a matcher that matches allTableViews that have exactlyamountrows.
-
containsRowAtIndex
public static org.hamcrest.Matcher<javafx.scene.control.TableView> containsRowAtIndex(int rowIndex, java.lang.Object... cells)Creates a matcher that matches allTableViews that have a row at the givenindexthat contains the given values for each column of aTableView.For example, given a
TableViewthat has three columns:
Then to verify that such aTableColumn<RegularPolygon, String> nameColumn = new TableColumn<>("Name"); TableColumn<RegularPolygon, Integer> numSidesColumn = new TableColumn<>("Number of Sides"); TableColumn<RegularPolygon, Double> unitAreaColumn = new TableColumn<>("Area when Side = 1"); polygonsTable.getColumns().setAll(nameColumn, numSidesColumn, unitAreaColumn);TableView, contains, at index 3, a row for aRegularPolygonthat has the name "Pentagon", the number of sides 5, and a unit area of 1.720477401 one would use:
Where the types of each argument, after the row index, correspond to the types of theverifyThat("#polygonsTable", TableViewMatchers.containsRowAtIndex(3, "Pentagon", 5, 1.720477401);TableColumns which in our example is(String, Integer, Double).- Parameters:
rowIndex- the row number (starting from 0) that must contains the given cell valuescells- The values or String representations of the values (e.g. the result of callingtoString()) contained in the row at a given index you want to verify aTableViewcontains - one such value for each column of thatTableView. Usenullif the value is expected to not be set or if no cell value factory has been set.
-
containsRow
public static org.hamcrest.Matcher<javafx.scene.control.TableView> containsRow(java.lang.Object... cells)
Creates a matcher that matches allTableViews that have at least one row that contains the given values for each column of aTableView.For example, given a
TableViewthat has three columns:
Then to verify that such aTableColumn<Person, String> nameColumn = new TableColumn<>("Name"); TableColumn<Person, Double> bmiColumn = new TableColumn<>("Body Mass Index"); TableColumn<Person, Boolean> membershipColumn = new TableColumn<>("Gym Membership Valid"); fitnessTable.getColumns().setAll(nameColumn, bmiColumn, membershipColumn);TableView, contains at least one row with aPersonthat has the name "Dan Anderson", the body mass index 28.83, and a valid gym membership (true) one would use:
Where the types of each argument correspond to the types of theverifyThat("#fitnessTable", TableViewMatchers.containsRow("Dan Anderson", 28.83, true);TableColumns which in our example is(String, Double, Boolean).- Parameters:
cells- The values or String representations of the values (e.g. the result of callingtoString()) contained in the row you want to verify aTableViewcontains - one such value for each column of thatTableView. Usenullif the value is expected to not be set or if no cell value factory has been set.
-
hasTableCell
private static boolean hasTableCell(javafx.scene.control.TableView tableView, java.lang.Object value)
-
containsRowAtIndex
private static <T> boolean containsRowAtIndex(javafx.scene.control.TableView<T> tableView, int rowIndex, java.lang.Object... cells)
-
getRowValues
private static java.util.List<javafx.beans.value.ObservableValue<?>> getRowValues(javafx.scene.control.TableView<?> tableView, int rowIndex)
-
toText
private static java.lang.String toText(javafx.scene.control.TableView<?> tableView)
Returns a textual representation of all rows of the giventableView.
-
toText
private static java.lang.String toText(javafx.scene.control.TableView<?> tableView, int rowIndex)Returns a textual representation of one row (specified byrowIndex) of the giventableView.
-
containsRow
private static <T> boolean containsRow(javafx.scene.control.TableView<T> tableView, java.lang.Object... cells)
-
hasCellValue
private static boolean hasCellValue(javafx.scene.control.Cell cell, java.lang.Object value)
-
hasItemValue
private static boolean hasItemValue(java.lang.Object item, java.lang.Object value)
-
-