use of au.gov.asd.tac.constellation.views.tableview.api.UserTablePreferences in project constellation by constellation-app.
the class PreferenceMenuNGTest method verifyLoadPreferencesAction.
/**
* Verifies that when the load preferences button is clicked, the load
* preferences method is called and the tables pagination is updated with
* any necessary changes. If the current active graph is null, then no
* preferences will be loaded.
*
* @param loadPreferencesMenu the load userTablePreferences menu
* @param isActiveGraphNull true if the active graph is null, false
* otherwise
* @throws InterruptedException if there is a an issue waiting for the
* JavaFX thread work to complete
*/
private void verifyLoadPreferencesAction(final MenuItem loadPreferencesMenu, final boolean isActiveGraphNull) throws InterruptedException {
clearInvocations(preferencesMenu, activeTableReference, tablePane);
try (final MockedStatic<GraphManager> graphManagerMockedStatic = Mockito.mockStatic(GraphManager.class)) {
final GraphManager graphManager = mock(GraphManager.class);
graphManagerMockedStatic.when(GraphManager::getDefault).thenReturn(graphManager);
final ActionEvent actionEvent = mock(ActionEvent.class);
if (isActiveGraphNull) {
when(graphManager.getActiveGraph()).thenReturn(null);
loadPreferencesMenu.getOnAction().handle(actionEvent);
verify(preferencesMenu, times(0)).loadPreferences();
} else {
final UserTablePreferences userTablePreferences = new UserTablePreferences();
userTablePreferences.setMaxRowsPerPage(42);
final Graph graph = mock(Graph.class);
final Pagination pagination = mock(Pagination.class);
when(graphManager.getActiveGraph()).thenReturn(graph);
when(activeTableReference.getUserTablePreferences()).thenReturn(userTablePreferences);
when(activeTableReference.getPagination()).thenReturn(pagination);
doNothing().when(preferencesMenu).loadPreferences();
loadPreferencesMenu.getOnAction().handle(actionEvent);
final CountDownLatch latch = new CountDownLatch(1);
Platform.runLater(() -> latch.countDown());
latch.await();
verify(activeTableReference).updatePagination(42, tablePane);
verify(preferencesMenu).loadPreferences();
}
verify(actionEvent).consume();
}
}
use of au.gov.asd.tac.constellation.views.tableview.api.UserTablePreferences in project constellation by constellation-app.
the class TableNGTest method updateSortOrderPrefSortEmpty.
@Test
public void updateSortOrderPrefSortEmpty() {
final UserTablePreferences userTablePreferences = new UserTablePreferences();
userTablePreferences.setSortByColumn(ImmutablePair.of("", TableColumn.SortType.DESCENDING));
when(activeTableReference.getUserTablePreferences()).thenReturn(userTablePreferences);
final TableView<ObservableList<String>> tableView = mock(TableView.class);
when(table.getTableView()).thenReturn(tableView);
table.updateSortOrder();
verifyNoInteractions(tableView);
}
use of au.gov.asd.tac.constellation.views.tableview.api.UserTablePreferences in project constellation by constellation-app.
the class TableNGTest method updateSortOrder.
@Test
public void updateSortOrder() {
final UserTablePreferences userTablePreferences = new UserTablePreferences();
userTablePreferences.setSortByColumn(ImmutablePair.of("COLUMN_B", TableColumn.SortType.DESCENDING));
when(activeTableReference.getUserTablePreferences()).thenReturn(userTablePreferences);
final TableView<ObservableList<String>> tableView = mock(TableView.class);
when(table.getTableView()).thenReturn(tableView);
final TableColumn<ObservableList<String>, String> column1 = mock(TableColumn.class);
when(column1.getText()).thenReturn("COLUMN_A");
final TableColumn<ObservableList<String>, String> column2 = mock(TableColumn.class);
when(column2.getText()).thenReturn("COLUMN_B");
when(tableView.getColumns()).thenReturn(FXCollections.observableList(List.of(column1, column2)));
final ObservableList<TableColumn<ObservableList<String>, ?>> sortOrder = FXCollections.observableArrayList();
when(tableView.getSortOrder()).thenReturn(sortOrder);
table.updateSortOrder();
verify(column2).setSortType(TableColumn.SortType.DESCENDING);
assertEquals(FXCollections.observableArrayList(column2), sortOrder);
}
use of au.gov.asd.tac.constellation.views.tableview.api.UserTablePreferences in project constellation by constellation-app.
the class TableNGTest method updateSortOrderPrefSortNull.
@Test
public void updateSortOrderPrefSortNull() {
final UserTablePreferences userTablePreferences = new UserTablePreferences();
userTablePreferences.setSortByColumn(null);
when(activeTableReference.getUserTablePreferences()).thenReturn(userTablePreferences);
final TableView<ObservableList<String>> tableView = mock(TableView.class);
when(table.getTableView()).thenReturn(tableView);
table.updateSortOrder();
verifyNoInteractions(tableView);
}
use of au.gov.asd.tac.constellation.views.tableview.api.UserTablePreferences in project constellation by constellation-app.
the class TableViewPreferencesIoProviderNGTest method getPreferencesNullPrefs.
@Test
public void getPreferencesNullPrefs() throws IOException {
jsonIOStaticMock.when(() -> JsonIO.loadJsonPreferences(eq(Optional.of("TableViewPreferences")), eq(Optional.of("vertex-")), any(TypeReference.class))).thenReturn(null);
final UserTablePreferences tablepreferences = TableViewPreferencesIoProvider.getPreferences(GraphElementType.VERTEX);
final UserTablePreferences expected = new UserTablePreferences();
expected.setColumnOrder(Collections.emptyList());
expected.setSortByColumn(ImmutablePair.of("", TableColumn.SortType.ASCENDING));
expected.setMaxRowsPerPage(500);
assertEquals(expected, tablepreferences);
}
Aggregations