Search in sources :

Example 11 with TableViewState

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));
    }
}
Also used : Platform(javafx.application.Platform) TableViewState(au.gov.asd.tac.constellation.views.tableview.state.TableViewState) Test(org.testng.annotations.Test)

Example 12 with TableViewState

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();
}
Also used : ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) Platform(javafx.application.Platform) TableViewState(au.gov.asd.tac.constellation.views.tableview.state.TableViewState) Test(org.testng.annotations.Test)

Example 13 with TableViewState

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()));
}
Also used : TableViewState(au.gov.asd.tac.constellation.views.tableview.state.TableViewState) Test(org.testng.annotations.Test)

Example 14 with TableViewState

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()));
}
Also used : TableViewState(au.gov.asd.tac.constellation.views.tableview.state.TableViewState) Test(org.testng.annotations.Test)

Example 15 with TableViewState

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();
    }
}
Also used : PluginExecution(au.gov.asd.tac.constellation.plugins.PluginExecution) ActionEvent(javafx.event.ActionEvent) TableViewState(au.gov.asd.tac.constellation.views.tableview.state.TableViewState) UpdateStatePlugin(au.gov.asd.tac.constellation.views.tableview.plugins.UpdateStatePlugin) ImageView(javafx.scene.image.ImageView)

Aggregations

TableViewState (au.gov.asd.tac.constellation.views.tableview.state.TableViewState)65 Test (org.testng.annotations.Test)50 Graph (au.gov.asd.tac.constellation.graph.Graph)24 Platform (javafx.application.Platform)19 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)14 ObservableList (javafx.collections.ObservableList)14 Attribute (au.gov.asd.tac.constellation.graph.Attribute)13 UpdateStatePlugin (au.gov.asd.tac.constellation.views.tableview.plugins.UpdateStatePlugin)12 PluginExecution (au.gov.asd.tac.constellation.plugins.PluginExecution)10 TableColumn (javafx.scene.control.TableColumn)10 GraphAttribute (au.gov.asd.tac.constellation.graph.GraphAttribute)8 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)8 TablePane (au.gov.asd.tac.constellation.views.tableview.panes.TablePane)7 ListChangeListener (javafx.collections.ListChangeListener)7 Tuple (au.gov.asd.tac.constellation.utilities.datastructure.Tuple)6 TableViewUtilities (au.gov.asd.tac.constellation.views.tableview.utilities.TableViewUtilities)6 GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)5 Column (au.gov.asd.tac.constellation.views.tableview.api.Column)5 Table (au.gov.asd.tac.constellation.views.tableview.components.Table)5 ArrayList (java.util.ArrayList)5