Search in sources :

Example 46 with TableViewState

use of au.gov.asd.tac.constellation.views.tableview.state.TableViewState in project constellation by constellation-app.

the class TableNGTest method updateColumnsGraphNull.

@Test
public void updateColumnsGraphNull() {
    try (final MockedStatic<Platform> platformMockedStatic = Mockito.mockStatic(Platform.class)) {
        table.updateColumns(null, new TableViewState());
        platformMockedStatic.verifyNoInteractions();
    }
}
Also used : Platform(javafx.application.Platform) TableViewState(au.gov.asd.tac.constellation.views.tableview.state.TableViewState) Test(org.testng.annotations.Test)

Example 47 with TableViewState

use of au.gov.asd.tac.constellation.views.tableview.state.TableViewState in project constellation by constellation-app.

the class TableNGTest method updateDataGraphNull.

@Test
public void updateDataGraphNull() {
    try (final MockedStatic<Platform> platformMockedStatic = Mockito.mockStatic(Platform.class)) {
        table.updateData(null, new TableViewState(), null);
        platformMockedStatic.verifyNoInteractions();
    }
}
Also used : Platform(javafx.application.Platform) TableViewState(au.gov.asd.tac.constellation.views.tableview.state.TableViewState) Test(org.testng.annotations.Test)

Example 48 with TableViewState

use of au.gov.asd.tac.constellation.views.tableview.state.TableViewState in project constellation by constellation-app.

the class TableViewPageFactoryNGTest method updateSelectionNotOnFxThread.

@Test(expectedExceptions = IllegalStateException.class)
public void updateSelectionNotOnFxThread() {
    try (final MockedStatic<Platform> platformMockedStatic = Mockito.mockStatic(Platform.class)) {
        platformMockedStatic.when(Platform::isFxApplicationThread).thenReturn(false);
        tableViewPageFactory.restoreSelectionFromGraph(graph, new TableViewState(), null);
    }
}
Also used : Platform(javafx.application.Platform) TableViewState(au.gov.asd.tac.constellation.views.tableview.state.TableViewState) Test(org.testng.annotations.Test)

Example 49 with TableViewState

use of au.gov.asd.tac.constellation.views.tableview.state.TableViewState in project constellation by constellation-app.

the class SelectedOnlySelectionListenerNGTest method onChanged.

@Test
public void onChanged() {
    final TableViewState currentState = new TableViewState();
    currentState.setSelectedOnly(true);
    final TableViewSelectionModel<ObservableList<String>> selectionModel = mock(TableViewSelectionModel.class);
    when(tableViewTopComponent.getCurrentState()).thenReturn(currentState);
    // 4 rows. Rows 1 and 3 are currently selected. Row 2 was previously selected. Row 4 is not
    // selected and never was.
    final ObservableList<ObservableList<String>> items = FXCollections.observableList(List.of(FXCollections.observableList(List.of("row1Column1", "row1Column2")), FXCollections.observableList(List.of("row2Column1", "row2Column2")), FXCollections.observableList(List.of("row3Column1", "row3Column2")), FXCollections.observableList(List.of("row4Column1", "row4Column2"))));
    final ObservableList<ObservableList<String>> selectedItems = FXCollections.observableList(List.of(FXCollections.observableList(List.of("row1Column1", "row1Column2")), FXCollections.observableList(List.of("row3Column1", "row3Column2"))));
    selectedOnlySelectedRows.add(FXCollections.observableList(List.of("row2Column1", "row2Column2")));
    when(tableView.getItems()).thenReturn(items);
    when(tableView.getSelectionModel()).thenReturn(selectionModel);
    when(selectionModel.getSelectedItems()).thenReturn(selectedItems);
    selectedOnlySelectionListener.onChanged(null);
    final Set<ObservableList<String>> expectedSelectedRows = Set.of(FXCollections.observableList(List.of("row1Column1", "row1Column2")), FXCollections.observableList(List.of("row3Column1", "row3Column2")));
    assertEquals(expectedSelectedRows, selectedOnlySelectedRows);
}
Also used : ObservableList(javafx.collections.ObservableList) TableViewState(au.gov.asd.tac.constellation.views.tableview.state.TableViewState) Test(org.testng.annotations.Test)

Example 50 with TableViewState

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

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