use of au.gov.asd.tac.constellation.views.tableview.state.TableViewState in project constellation by constellation-app.
the class TableNGTest method updateSelectionInSelectedOnlyMode.
@Test
public void updateSelectionInSelectedOnlyMode() {
try (final MockedStatic<Platform> platformMockedStatic = Mockito.mockStatic(Platform.class)) {
final TableViewState tableViewState = new TableViewState();
tableViewState.setSelectedOnly(true);
table.updateSelection(graph, tableViewState);
platformMockedStatic.verify(() -> Platform.runLater(any(Runnable.class)), times(0));
}
}
use of au.gov.asd.tac.constellation.views.tableview.state.TableViewState in project constellation by constellation-app.
the class TableNGTest method updateColumnsThreadInterrupted.
@Test
public void updateColumnsThreadInterrupted() {
final ReadableGraph readableGraph = mock(ReadableGraph.class);
when(graph.getReadableGraph()).thenReturn(readableGraph);
when(activeTableReference.getColumnIndex()).thenReturn(new ArrayList<>());
// Set up the table state
final TableViewState tableViewState = new TableViewState();
tableViewState.setElementType(GraphElementType.TRANSACTION);
tableViewState.setColumnAttributes(new ArrayList<>());
try (final MockedStatic<Platform> platformMockedStatic = Mockito.mockStatic(Platform.class)) {
platformMockedStatic.when(Platform::isFxApplicationThread).thenReturn(false);
Thread.currentThread().interrupt();
table.updateColumns(graph, tableViewState);
assertTrue(Thread.currentThread().isInterrupted());
platformMockedStatic.verify(() -> Platform.runLater(any(Runnable.class)), times(0));
}
// Clears the interrupted state
Thread.interrupted();
}
use of au.gov.asd.tac.constellation.views.tableview.state.TableViewState in project constellation by constellation-app.
the class TableToolbarNGTest method getElementTypeInitialIcon.
@Test
public void getElementTypeInitialIcon() {
final TableViewState state = new TableViewState();
when(tableTopComponent.getCurrentState()).thenReturn(state);
state.setElementType(GraphElementType.META);
assertTrue(isImageEqual(UserInterfaceIconProvider.TRANSACTIONS.buildImage(16), tableToolbar.getElementTypeInitialIcon().getImage()));
state.setElementType(GraphElementType.TRANSACTION);
assertTrue(isImageEqual(UserInterfaceIconProvider.TRANSACTIONS.buildImage(16), tableToolbar.getElementTypeInitialIcon().getImage()));
state.setElementType(GraphElementType.VERTEX);
assertTrue(isImageEqual(UserInterfaceIconProvider.NODES.buildImage(16), tableToolbar.getElementTypeInitialIcon().getImage()));
when(tableTopComponent.getCurrentState()).thenReturn(null);
assertTrue(isImageEqual(UserInterfaceIconProvider.TRANSACTIONS.buildImage(16), tableToolbar.getElementTypeInitialIcon().getImage()));
}
use of au.gov.asd.tac.constellation.views.tableview.state.TableViewState in project constellation by constellation-app.
the class TableToolbarNGTest method getSelectedOnlyInitialIcon.
@Test
public void getSelectedOnlyInitialIcon() {
final TableViewState state = new TableViewState();
when(tableTopComponent.getCurrentState()).thenReturn(state);
state.setSelectedOnly(true);
assertTrue(isImageEqual(UserInterfaceIconProvider.VISIBLE.buildImage(16, ConstellationColor.CHERRY.getJavaColor()), tableToolbar.getSelectedOnlyInitialIcon().getImage()));
state.setSelectedOnly(false);
assertTrue(isImageEqual(UserInterfaceIconProvider.VISIBLE.buildImage(16), tableToolbar.getSelectedOnlyInitialIcon().getImage()));
when(tableTopComponent.getCurrentState()).thenReturn(null);
assertTrue(isImageEqual(UserInterfaceIconProvider.VISIBLE.buildImage(16), tableToolbar.getSelectedOnlyInitialIcon().getImage()));
}
use of au.gov.asd.tac.constellation.views.tableview.state.TableViewState in project constellation by constellation-app.
the class TableToolbarNGTest method elementTypeChangeActionChecks.
/**
* When the element type button is pressed the tables state is switched
* between VERTEX and TRANSACTION. This verifies that as the button is
* pressed that transition happens and the update state plugin is executed
* triggering the required changes. The buttons icon should also change to
* the element type now set in the state.
*
* @param elementTypeInitialState the initial element type in the state
* before the button is pressed
* @param elementTypeEndState the expected element type in the state after
* the button is pressed
* @param expectedNewIcon the expected image to be now on the element type
* change button
*/
private void elementTypeChangeActionChecks(final GraphElementType elementTypeInitialState, final GraphElementType elementTypeEndState, final Image expectedNewIcon) {
try (MockedStatic<PluginExecution> pluginExecutionMockedStatic = Mockito.mockStatic(PluginExecution.class)) {
final PluginExecution pluginExecution = mock(PluginExecution.class);
final ActionEvent actionEvent = mock(ActionEvent.class);
final TableViewState tableViewState = new TableViewState();
tableViewState.setElementType(elementTypeInitialState);
when(tableTopComponent.getCurrentState()).thenReturn(tableViewState);
final ArgumentCaptor<UpdateStatePlugin> captor = ArgumentCaptor.forClass(UpdateStatePlugin.class);
pluginExecutionMockedStatic.when(() -> PluginExecution.withPlugin(captor.capture())).thenReturn(pluginExecution);
tableToolbar.getElementTypeButton().getOnAction().handle(actionEvent);
final UpdateStatePlugin updatePlugin = captor.getValue();
final ImageView buttonIcon = (ImageView) tableToolbar.getElementTypeButton().getGraphic();
assertTrue(isImageEqual(expectedNewIcon, buttonIcon.getImage()));
assertEquals(elementTypeEndState, updatePlugin.getTableViewState().getElementType());
verify(pluginExecution).executeLater(graph);
verify(actionEvent).consume();
}
}
Aggregations