Module org.testfx

Class AbstractTableViewAssert<SELF extends AbstractTableViewAssert<SELF,​T>,​T>

  • All Implemented Interfaces:
    org.assertj.core.api.Assert<SELF,​javafx.css.Styleable>, org.assertj.core.api.Descriptable<SELF>, org.assertj.core.api.ExtensionPoints<SELF,​javafx.css.Styleable>
    Direct Known Subclasses:
    TableViewAssert

    public class AbstractTableViewAssert<SELF extends AbstractTableViewAssert<SELF,​T>,​T>
    extends AbstractNodeAssert<SELF>
    Base class for all TableView assertions.
    • Field Summary

      • Fields inherited from class org.assertj.core.api.AbstractAssert

        actual, info, myself, throwUnsupportedExceptionOnEquals
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractTableViewAssert​(javafx.scene.control.TableView<T> actual, Class<?> selfType)  
    • Constructor Detail

      • AbstractTableViewAssert

        protected AbstractTableViewAssert​(javafx.scene.control.TableView<T> actual,
                                          Class<?> selfType)
    • Method Detail

      • hasTableCell

        public SELF hasTableCell​(Object expectedValue)
        Verifies that the actual TableView contains the given table cell expectedValue.

        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);
         
        Parameters:
        expectedValue - the given table cell value to ensure the TableView contains
        Returns:
        this assertion object
      • doesNotHaveTableCell

        public SELF doesNotHaveTableCell​(Object expectedValue)
        Verifies that the actual TableView does not contain the given table cell expectedValue.
        Parameters:
        expectedValue - the given table cell value to ensure the TableView does not contain
        Returns:
        this assertion object
      • hasExactlyNumRows

        public SELF hasExactlyNumRows​(int rows)
        Verifies that the actual TableView has exactly the given amount of rows.
        Parameters:
        rows - the given amount of rows to compare the actual amount of rows to
        Returns:
        this assertion object
      • doesNotHaveExactlyNumRows

        public SELF doesNotHaveExactlyNumRows​(int rows)
        Verifies that the actual TableView does not have exactly the given amount of rows.
        Parameters:
        rows - the given amount of rows to compare the actual amount of rows to
        Returns:
        this assertion object
      • containsRowAtIndex

        public SELF containsRowAtIndex​(int rowIndex,
                                       Object... cells)
        Verifies that the actual TableView contains the given table cells at the given rowIndex.

        For example, given a TableView that has three columns:

        
         TableColumn<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);
         
        Then to verify that such a TableView, contains, at index 3, a row for a RegularPolygon that has the name "Pentagon", the number of sides 5, and a unit area of 1.720477401 one would use:
        
         assertThat(polygonsTable).containsRowAtIndex(3, "Pentagon", 5, 1.720477401);
         
        Where the types of each argument, after the row index, correspond to the types of the TableColumns which in our example is (String, Integer, Double).
        Parameters:
        rowIndex - the given row index that the actual TableView should contain the given cells on
        cells - the cells that should be contained at the given row index
        Returns:
        this assertion object
      • doesNotContainRowAtIndex

        public SELF doesNotContainRowAtIndex​(int rowIndex,
                                             Object... cells)
        Verifies that the actual TableView does not contain the given table cells at the given rowIndex.
        Parameters:
        rowIndex - the given row index that the actual TableView should not contain the given cells on
        cells - the cells that should not be contained at the given row index
        Returns:
        this assertion object
      • containsRow

        public SELF containsRow​(Object... cells)
        Verifies that the actual TableView contains the given table cells at any row index.

        For example, given a TableView that has three columns:

        
         TableColumn<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);
         
        Then to verify that such a TableView, contains at least one row with a Person that has the name "Dan Anderson", the body mass index 28.83, and a valid gym membership (true) one would use:
        
         assertThat(fitnessTable).containsRow("Dan Anderson", 28.83, true);
         
        Where the types of each argument correspond to the types of the TableColumns which in our example is (String, Double, Boolean).
        Parameters:
        cells - the cells that should be contained at any (at least one) row index
        Returns:
        this assertion object
      • doesNotContainRow

        public SELF doesNotContainRow​(Object... cells)
        Verifies that the actual TableView does not contain the given table cells at any row index.
        Parameters:
        cells - the cells that should not be contained at any (at least one) row index
        Returns:
        this assertion object