Search in sources :

Example 51 with TableViewState

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

Example 52 with TableViewState

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

the class UpdateTableSelectionTaskNGTest method updateSelectionTask.

@Test
public void updateSelectionTask() {
    final TablePane tablePane = mock(TablePane.class);
    final Graph graph = mock(Graph.class);
    final TableViewState tableViewState = new TableViewState();
    final Table table = mock(Table.class);
    final ProgressBar progressBar = mock(ProgressBar.class);
    when(tablePane.getTable()).thenReturn(table);
    when(tablePane.getProgressBar()).thenReturn(progressBar);
    final TriggerSelectionUpdateTask updateTableSelectionTask = new TriggerSelectionUpdateTask(tablePane, graph, tableViewState);
    updateTableSelectionTask.run();
    verify(table).updateSelection(graph, tableViewState);
}
Also used : Graph(au.gov.asd.tac.constellation.graph.Graph) Table(au.gov.asd.tac.constellation.views.tableview.components.Table) TableViewState(au.gov.asd.tac.constellation.views.tableview.state.TableViewState) ProgressBar(au.gov.asd.tac.constellation.views.tableview.components.ProgressBar) TablePane(au.gov.asd.tac.constellation.views.tableview.panes.TablePane) Test(org.testng.annotations.Test)

Example 53 with TableViewState

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

the class ColumnIndexSortNGTest method compare.

@Test
public void compare() {
    final TableViewState state = new TableViewState();
    final Attribute attribute1 = mock(Attribute.class);
    final Attribute attribute2 = mock(Attribute.class);
    final Attribute attribute3 = mock(Attribute.class);
    final Attribute attribute4 = mock(Attribute.class);
    final Attribute attribute5 = mock(Attribute.class);
    final Attribute attribute6 = mock(Attribute.class);
    final Attribute attribute7 = mock(Attribute.class);
    final Tuple<String, Attribute> column1 = Tuple.create(GraphRecordStoreUtilities.SOURCE, attribute1);
    final Tuple<String, Attribute> column2 = Tuple.create(GraphRecordStoreUtilities.SOURCE, attribute2);
    final Tuple<String, Attribute> column3 = Tuple.create(GraphRecordStoreUtilities.SOURCE, attribute3);
    final Tuple<String, Attribute> column4 = Tuple.create(GraphRecordStoreUtilities.TRANSACTION, attribute4);
    final Tuple<String, Attribute> column5 = Tuple.create(GraphRecordStoreUtilities.DESTINATION, attribute5);
    final Tuple<String, Attribute> column6 = Tuple.create("random", attribute6);
    final Tuple<String, Attribute> column7 = Tuple.create("random", attribute7);
    state.setColumnAttributes(List.of(column1, column2));
    final ColumnIndexSort sort = new ColumnIndexSort(state);
    // Both columns are in the state. Order based on index position in the state column attrs
    assertTrue(sort.compare(createColumn(column1), createColumn(column2)) < 0);
    assertTrue(sort.compare(createColumn(column2), createColumn(column1)) > 0);
    // Only one column is in the state
    assertTrue(sort.compare(createColumn(column1), createColumn(column3)) < 0);
    assertTrue(sort.compare(createColumn(column3), createColumn(column1)) > 0);
    // Neither in the state - source is before everything, transaction before destination
    assertTrue(sort.compare(createColumn(column3), createColumn(column4)) < 0);
    assertTrue(sort.compare(createColumn(column3), createColumn(column5)) < 0);
    assertTrue(sort.compare(createColumn(column4), createColumn(column5)) < 0);
    assertTrue(sort.compare(createColumn(column5), createColumn(column3)) > 0);
    assertTrue(sort.compare(createColumn(column5), createColumn(column4)) > 0);
    assertTrue(sort.compare(createColumn(column4), createColumn(column3)) > 0);
    // Neither are in state and neither type is known. Default to the column name
    when(attribute6.getName()).thenReturn("a");
    when(attribute7.getName()).thenReturn("b");
    assertTrue(sort.compare(createColumn(column6), createColumn(column7)) < 0);
    assertTrue(sort.compare(createColumn(column7), createColumn(column6)) > 0);
}
Also used : Attribute(au.gov.asd.tac.constellation.graph.Attribute) TableViewState(au.gov.asd.tac.constellation.views.tableview.state.TableViewState) Test(org.testng.annotations.Test)

Example 54 with TableViewState

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

the class ColumnVisibilityContextMenuNGTest method setUpMethod.

@BeforeMethod
public void setUpMethod() throws Exception {
    tableViewTopComponent = mock(TableViewTopComponent.class);
    tablePane = mock(TablePane.class);
    table = mock(Table.class);
    activeTableReference = mock(ActiveTableReference.class);
    graph = mock(Graph.class);
    readableGraph = mock(ReadableGraph.class);
    tableViewState = new TableViewState();
    when(graph.getReadableGraph()).thenReturn(readableGraph);
    // These two will define which columns are shown when the "Key Columns" button is pressed
    when(readableGraph.getPrimaryKey(GraphElementType.VERTEX)).thenReturn(new int[] { 2, 3 });
    when(readableGraph.getPrimaryKey(GraphElementType.TRANSACTION)).thenReturn(new int[] { 5 });
    // Define the columns available in the table
    // I think typically the value for Attribut.getAttribute and
    // TableColumn.getText will be the same. But for the purpose of these
    // tests they are different so it can be differentiated in the assertions
    columnType1 = "source.";
    when(readableGraph.getAttributeName(1)).thenReturn("Location Name");
    attribute1 = new GraphAttribute(readableGraph, 1);
    column1 = mock(TableColumn.class);
    when(column1.getText()).thenReturn("Text from Column 1");
    columnType2 = "destination.";
    when(readableGraph.getAttributeName(2)).thenReturn("Number of Visitors");
    attribute2 = new GraphAttribute(readableGraph, 2);
    column2 = mock(TableColumn.class);
    when(column2.getText()).thenReturn("Text from Column 2");
    columnType3 = "source.";
    when(readableGraph.getAttributeName(3)).thenReturn("personal notes");
    attribute3 = new GraphAttribute(readableGraph, 3);
    column3 = mock(TableColumn.class);
    when(column3.getText()).thenReturn("Text from Column 3");
    columnType4 = "transaction.";
    when(readableGraph.getAttributeName(4)).thenReturn("Related To");
    attribute4 = new GraphAttribute(readableGraph, 4);
    column4 = mock(TableColumn.class);
    when(column4.getText()).thenReturn("Text from Column 4");
    columnType5 = "transaction.";
    when(readableGraph.getAttributeName(5)).thenReturn("personal notes");
    attribute5 = new GraphAttribute(readableGraph, 5);
    column5 = mock(TableColumn.class);
    when(column5.getText()).thenReturn("Text from Column 5");
    final CopyOnWriteArrayList<Column> columnIndex = new CopyOnWriteArrayList<>();
    columnIndex.add(new Column(columnType1, attribute1, column1));
    columnIndex.add(new Column(columnType2, attribute2, column2));
    columnIndex.add(new Column(columnType3, attribute3, column3));
    columnIndex.add(new Column(columnType4, attribute4, column4));
    columnIndex.add(new Column(columnType5, attribute5, column5));
    when(table.getColumnIndex()).thenReturn(columnIndex);
    when(table.getParentComponent()).thenReturn(tablePane);
    when(tablePane.getActiveTableReference()).thenReturn(activeTableReference);
    when(tablePane.getParentComponent()).thenReturn(tableViewTopComponent);
    when(tableViewTopComponent.getCurrentGraph()).thenReturn(graph);
    when(tableViewTopComponent.getCurrentState()).thenReturn(tableViewState);
    columnVisibilityContextMenu = spy(new ColumnVisibilityContextMenu(table));
}
Also used : ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) GraphAttribute(au.gov.asd.tac.constellation.graph.GraphAttribute) TableColumn(javafx.scene.control.TableColumn) TableViewTopComponent(au.gov.asd.tac.constellation.views.tableview.TableViewTopComponent) ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) Graph(au.gov.asd.tac.constellation.graph.Graph) Column(au.gov.asd.tac.constellation.views.tableview.api.Column) TableColumn(javafx.scene.control.TableColumn) TableViewState(au.gov.asd.tac.constellation.views.tableview.state.TableViewState) ActiveTableReference(au.gov.asd.tac.constellation.views.tableview.api.ActiveTableReference) TablePane(au.gov.asd.tac.constellation.views.tableview.panes.TablePane) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 55 with TableViewState

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

the class TableNGTest method updateDataOnSwingThread.

@Test(expectedExceptions = IllegalStateException.class)
public void updateDataOnSwingThread() {
    try (final MockedStatic<SwingUtilities> swingUtilsMockedStatic = Mockito.mockStatic(SwingUtilities.class)) {
        swingUtilsMockedStatic.when(SwingUtilities::isEventDispatchThread).thenReturn(true);
        table.updateData(graph, new TableViewState(), null);
    }
}
Also used : TableViewState(au.gov.asd.tac.constellation.views.tableview.state.TableViewState) SwingUtilities(javax.swing.SwingUtilities) 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