Skip to content

Commit

Permalink
TableViewer.DataSetsRow: add test cases for not equals
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Peter authored and Benjamin Peter committed Jan 27, 2021
1 parent 65a566b commit 280fe56
Showing 1 changed file with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package de.gsi.chart.plugins;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import static de.gsi.chart.plugins.TableViewer.BUTTON_BAR_STYLE_CLASS;
Expand Down Expand Up @@ -102,12 +104,23 @@ public void testThatDataSetsRowHashCodeEqualsWorks() throws TimeoutException {

@SuppressWarnings("unchecked")
TableView<DataSetsRow> tableView = (TableView<DataSetsRow>) tableViewer.getTable();

// Equals/hashCode with self is true
tableView.getSelectionModel().select(0);
DataSetsRow anyRowItem = tableView.getSelectionModel().getSelectedItem();
assertEquals(anyRowItem.hashCode(), anyRowItem.hashCode());
assertTrue(anyRowItem.equals(anyRowItem));
DataSetsRow firstRowItem = tableView.getSelectionModel().getSelectedItem();
assertEquals(firstRowItem.hashCode(), firstRowItem.hashCode());
assertTrue(firstRowItem.equals(firstRowItem));

// Equals/hashCode with other row is false
tableView.getSelectionModel().clearAndSelect(1);
DataSetsRow secondRowItem = tableView.getSelectionModel().getSelectedItem();
assertNotEquals(firstRowItem.hashCode(), secondRowItem.hashCode());
assertFalse(firstRowItem.equals(secondRowItem));

// Equals with other type is false
assertFalse(firstRowItem.equals(new Object()));
}

private Button locateTableViewButton(final FlowPane toolbar) {
return fxRobot.from(toolbar) //
.lookup("." + BUTTON_BAR_STYLE_CLASS + " > ." + BUTTON_SWITCH_TABLE_VIEW_STYLE_CLASS) //
Expand Down

0 comments on commit 280fe56

Please sign in to comment.