use of au.gov.asd.tac.constellation.views.tableview.utilities.TableViewUtilities in project constellation by constellation-app.
the class RightClickContextMenuNGTest method verifyCopyAction.
/**
* Verify that the passed event handler copies the correct table cells in
* CSV form to the OS clipboard.
*
* @param eventHandler the handler to test
* @param expectedClipboardText the expected CSV copied to the clipboard
*/
private void verifyCopyAction(final EventHandler<ActionEvent> eventHandler, final String expectedClipboardText) {
try (MockedStatic<TableViewUtilities> tableViewUtilsMockedStatic = Mockito.mockStatic(TableViewUtilities.class)) {
final ActionEvent actionEvent = mock(ActionEvent.class);
eventHandler.handle(actionEvent);
tableViewUtilsMockedStatic.verify(() -> TableViewUtilities.copyToClipboard(expectedClipboardText));
verify(actionEvent).consume();
}
}
use of au.gov.asd.tac.constellation.views.tableview.utilities.TableViewUtilities in project constellation by constellation-app.
the class TableSelectionListenerNGTest method changedCurrentStateSelectedOnlyModeFalse.
@Test
public void changedCurrentStateSelectedOnlyModeFalse() {
try (MockedStatic<TableViewUtilities> tableViewUtilitiesMockedStatic = Mockito.mockStatic(TableViewUtilities.class)) {
final TableViewState currentState = new TableViewState();
currentState.setSelectedOnly(false);
currentState.setElementType(GraphElementType.META);
final Graph graph = mock(Graph.class);
when(tableViewTopComponent.getCurrentState()).thenReturn(currentState);
when(tableViewTopComponent.getCurrentGraph()).thenReturn(graph);
tableSelectionListener.changed(null, null, null);
tableViewUtilitiesMockedStatic.verify(() -> TableViewUtilities.copySelectionToGraph(same(tableView), same(rowToElementIdIndex), eq(GraphElementType.META), same(graph)));
}
}
use of au.gov.asd.tac.constellation.views.tableview.utilities.TableViewUtilities in project constellation by constellation-app.
the class TableSelectionListenerNGTest method changedCurrentStateSelectedOnlyModeTrue.
@Test
public void changedCurrentStateSelectedOnlyModeTrue() {
try (MockedStatic<TableViewUtilities> tableViewUtilitiesMockedStatic = Mockito.mockStatic(TableViewUtilities.class)) {
final TableViewState currentState = new TableViewState();
currentState.setSelectedOnly(true);
when(tableViewTopComponent.getCurrentState()).thenReturn(currentState);
tableSelectionListener.changed(null, null, null);
tableViewUtilitiesMockedStatic.verifyNoInteractions();
}
}
use of au.gov.asd.tac.constellation.views.tableview.utilities.TableViewUtilities in project constellation by constellation-app.
the class CopyMenuNGTest method verifyCopyAction.
/**
* Verify that the passed event handler copies to the clipboard either the
* whole table or just the selected rows.
*
* @param eventHandler the handler to test
* @param expectedCopyOnlySelectedRows true if only the selected rows are
* expected to be copied, false otherwise
*/
private void verifyCopyAction(final EventHandler<ActionEvent> eventHandler, final boolean expectedCopyOnlySelectedRows) {
try (MockedStatic<TableViewUtilities> tableViewUtilsMockedStatic = Mockito.mockStatic(TableViewUtilities.class)) {
final ActionEvent actionEvent = mock(ActionEvent.class);
final TableView<ObservableList<String>> tableView = mock(TableView.class);
when(table.getTableView()).thenReturn(tableView);
final String tableData = "Row1Column1,Row1Column2\nRow2Column2,Row2Column2";
tableViewUtilsMockedStatic.when(() -> TableViewUtilities.getTableData(tableView, pagination, false, expectedCopyOnlySelectedRows)).thenReturn(tableData);
eventHandler.handle(actionEvent);
tableViewUtilsMockedStatic.verify(() -> TableViewUtilities.copyToClipboard(tableData));
verify(actionEvent).consume();
}
}
Aggregations