/** * Creates a new {@link JTableCellFixture}. * * @param table handles the {@code JTable} containing the cell in this fixture. * @param cell row and column indices of the table cell to be managed by this fixture. * @throws NullPointerException if {@code table} is {@code null}. * @throws NullPointerException if {@code cell} is {@code null}. */ protected JTableCellFixture(@Nonnull JTableFixture table, @Nonnull TableCell cell) { this(table, cell, table.target(), table.driver()); }
/** * Converts the given cell into a coordinate pair. * * @param cell the given cell. * @return the coordinates of the given cell. * @throws NullPointerException if the cell is {@code null}. * @throws IndexOutOfBoundsException if any of the indices (row and column) is out of bounds. */ @Nonnull public Point pointAt(@Nonnull TableCell cell) { return driver().pointAt(target(), cell); }
/** * Asserts that the given cell in this fixture's {@code JTable} is editable. * * @param cell the given cell. * @return this fixture. * @throws NullPointerException if the cell is {@code null}. * @throws IndexOutOfBoundsException if any of the indices (row and column) is out of bounds. * @throws AssertionError if the given cell is not editable. */ @Nonnull public JTableFixture requireEditable(@Nonnull TableCell cell) { driver().requireEditable(target(), cell); return this; }
/** * Asserts that the given cell in this fixture's {@code JTable} is not editable. * * @param cell the given cell. * @return this fixture. * @throws NullPointerException if the cell is {@code null}. * @throws IndexOutOfBoundsException if any of the indices (row and column) is out of bounds. * @throws AssertionError if the given cell is editable. */ @Nonnull public JTableFixture requireNotEditable(@Nonnull TableCell cell) { driver().requireNotEditable(target(), cell); return this; }
/** * Returns the {@code String} representation of the value of a cell in this fixture's {@code JTable}, using this * fixture's {@link JTableCellReader}. * * @param cell the given cell. * @return the {@code String} representation of the value of a cell in this fixture's {@code JTable}. * @throws NullPointerException if the cell is {@code null}. * @throws IndexOutOfBoundsException if any of the indices (row and column) is out of bounds. * @see #replaceCellReader(JTableCellReader) */ @Nullable public String valueAt(@Nonnull TableCell cell) { return driver().value(target(), cell); }
/** * Asserts that the set of selected rows in this fixture's {@code JTable} contains to the given row indices. The given * row indices can be a subset of all the selected rows in a {@code JTable}. * * @param rows the indices of the rows expected to be selected. * @return this fixture. * @throws AssertionError if the set of selected rows in this fixture's {@code JTable} (if any) do not contain the * given indices. */ @Nonnull public JTableFixture requireSelectedRows(@Nonnull int... rows) { driver().requireSelectedRows(target(), rows); return this; }
/** * Asserts that the {@code String} representation of the cell values in this fixture's {@code JTable} is equal to the * given {@code String} array. This method uses this fixture's {@link JTableCellReader} to read the values of the * table cells as {@code String}s. * * @param contents the expected {@code String} representation of the cell values in this fixture's {@code JTable}. * @return this fixture. * @see #replaceCellReader(JTableCellReader) */ @Nonnull public JTableFixture requireContents(@Nonnull String[][] contents) { driver().requireContents(target(), contents); return this; }
/** * Returns the index of the column in this fixture's {@code JTable} whose name matches the given one. * * @param columnName the name of the column to look for. * @return the index of the column whose name matches the given one. * @throws org.assertj.swing.exception.ActionFailedException if a column with a matching name could not be found. */ public int columnIndexFor(@Nonnull Object columnName) { return driver().columnIndex(target(), columnName); }
/** * @return the {@code String} representation of the cells in the cells in this fixture's {@code JTable}, using this * fixture's {@link JTableCellReader}. * @see #replaceCellReader(JTableCellReader) */ @Nonnull public String[][] contents() { return driver().contents(target()); }
/** * Asserts that this fixture's {@code JTable} has the given number of rows. * * @param expected the expected number of rows. * @return this fixture. * @throws AssertionError if this fixture's {@code JTable} does not have the given number of rows. */ @Nonnull public JTableFixture requireRowCount(int expected) { driver().requireRowCount(target(), expected); return this; }
/** * Asserts that this fixture's {@code JTable} has the given number of columns. * * @param expected the expected number of columns. * @return this fixture. * @throws AssertionError if this fixture's {@code JTable} does not have the given number of columns. */ @Nonnull public JTableFixture requireColumnCount(int expected) { driver().requireColumnCount(target(), expected); return this; }
/** * Verifies that this fixture's {@code JTable} does not have any selection. * * @return this fixture. * @throws AssertionError if this fixture's {@code JTable} has a selection. */ @Nonnull public JTableFixture requireNoSelection() { driver().requireNoSelection(target()); return this; }
/** * Returns the {@code String} representation of the selected cell in this fixture's {@code JTable}, using this * fixture's {@link org.assertj.swing.cell.JTableCellReader}. Returns {@code null} if one can not be obtained or if * the {@code JTable} does not have any selected cell. * * @return the {@code String} representation of the selected cell. * @see #replaceCellReader(JTableCellReader) */ @Nullable public String selectionValue() { return driver().selectionValue(target()); }
/** * Returns a {@link JTableCellFixture} wrapping the table cell specified by the given row and column. * * @param cell the cell of interest. * @return a {@code JTableCellFixture} wrapping the table cell specified by the given row and column. * @throws NullPointerException if the cell is {@code null}. * @throws IndexOutOfBoundsException if any of the indices (row and column) is out of bounds. */ @Nonnull public JTableCellFixture cell(@Nonnull TableCell cell) { driver().checkCellIndicesInBounds(target(), cell); return new JTableCellFixture(this, cell); }
/** * Returns the number of rows that can be shown in this fixture's {@code JTable}, given unlimited space. * * @return the number of rows shown in this fixture's {@code JTable}. * @see JTable#getRowCount() */ public int rowCount() { return driver().rowCountOf(target()); }
/** * Returns a {@link JTableCellFixture} wrapping the table cell whose value matches the given one. * * @param value the value of the cell to look for. It can be a regular expression. * @return a {@code JTableCellFixture} wrapping the table cell whose value matches the given one. * @throws org.assertj.swing.exception.ActionFailedException if a cell with a matching value cannot be found. */ @Nonnull public JTableCellFixture cell(String value) { TableCell cell = driver().cell(target(), value); return new JTableCellFixture(this, cell); }
/** * Returns a fixture that verifies the background color of the given table cell. * * @param cell the given table cell. * @return a fixture that verifies the background color of the given table cell. * @throws NullPointerException if the cell is {@code null}. * @throws IndexOutOfBoundsException if any of the indices (row and column) is out of bounds. */ @Nonnull public ColorFixture backgroundAt(@Nonnull TableCell cell) { Color background = driver().background(target(), cell); return new ColorFixture(checkNotNull(background), cellProperty(cell, BACKGROUND_PROPERTY)); }
/** * Returns a fixture that verifies the foreground color of the given table cell. * * @param cell the given table cell. * @return a fixture that verifies the foreground color of the given table cell. * @throws NullPointerException if the cell is {@code null}. * @throws IndexOutOfBoundsException if any of the indices (row and column) is out of bounds. */ @Nonnull public ColorFixture foregroundAt(@Nonnull TableCell cell) { Color foreground = driver().foreground(target(), cell); return new ColorFixture(checkNotNull(foreground), cellProperty(cell, FOREGROUND_PROPERTY)); }
/** * @return a {@code JTableHeaderFixture} wrapping the {@code JTableHeader} in this fixture's {@code JTable}. * @throws AssertionError if the {@code JTableHeader} in this fixture's {@code JTable} is {@code null}. */ @Nonnull public JTableHeaderFixture tableHeader() { JTableHeader tableHeader = driver().tableHeaderOf(target()); return new JTableHeaderFixture(robot(), checkNotNull(tableHeader)); }
/** * Returns a fixture that verifies the font of the given table cell. * * @param cell the given table cell. * @return a fixture that verifies the font of the given table cell. * @throws NullPointerException if the cell is {@code null}. * @throws IndexOutOfBoundsException if any of the indices (row and column) is out of bounds. */ public FontFixture fontAt(@Nonnull TableCell cell) { Font font = driver().font(target(), cell); return new FontFixture(checkNotNull(font), cellProperty(cell, FONT_PROPERTY)); }