Search in sources :

Example 1 with TableViewTopComponent

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

the class UpdateColumnsTaskNGTest method setUpMethod.

@BeforeMethod
public void setUpMethod() throws Exception {
    tableViewTopComponent = mock(TableViewTopComponent.class);
    tableView = mock(TableView.class);
    tablePane = mock(TablePane.class);
    table = mock(Table.class);
    activeTableReference = mock(ActiveTableReference.class);
    selectionModel = mock(TableViewSelectionModel.class);
    selectedItemProperty = mock(ReadOnlyObjectProperty.class);
    selectedItems = mock(ObservableList.class);
    tableSelectionListener = mock(ChangeListener.class);
    selectedOnlySelectionListener = mock(ListChangeListener.class);
    columnType1 = "source.";
    attribute1 = mock(Attribute.class);
    column1 = mock(TableColumn.class);
    columnType2 = "destination.";
    attribute2 = mock(Attribute.class);
    column2 = mock(TableColumn.class);
    columnType3 = "source.";
    attribute3 = mock(Attribute.class);
    column3 = mock(TableColumn.class);
    columnType4 = "transaction.";
    attribute4 = mock(Attribute.class);
    column4 = mock(TableColumn.class);
    columnType5 = "transaction.";
    attribute5 = mock(Attribute.class);
    column5 = mock(TableColumn.class);
    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(tableViewTopComponent.getTablePane()).thenReturn(tablePane);
    when(tablePane.getTable()).thenReturn(table);
    when(tablePane.getActiveTableReference()).thenReturn(activeTableReference);
    when(tablePane.getParentComponent()).thenReturn(tableViewTopComponent);
    when(activeTableReference.getColumnIndex()).thenReturn(columnIndex);
    when(table.getTableView()).thenReturn(tableView);
    when(table.getSelectedOnlySelectionListener()).thenReturn(selectedOnlySelectionListener);
    when(table.getTableSelectionListener()).thenReturn(tableSelectionListener);
    when(table.getParentComponent()).thenReturn(tablePane);
    when(tableView.getSelectionModel()).thenReturn(selectionModel);
    when(selectionModel.selectedItemProperty()).thenReturn(selectedItemProperty);
    when(selectionModel.getSelectedItems()).thenReturn(selectedItems);
    updateColumnsTask = spy(new UpdateColumnsTask(table));
}
Also used : Table(au.gov.asd.tac.constellation.views.tableview.components.Table) Attribute(au.gov.asd.tac.constellation.graph.Attribute) TableViewSelectionModel(javafx.scene.control.TableView.TableViewSelectionModel) TableColumn(javafx.scene.control.TableColumn) ListChangeListener(javafx.collections.ListChangeListener) TableViewTopComponent(au.gov.asd.tac.constellation.views.tableview.TableViewTopComponent) ReadOnlyObjectProperty(javafx.beans.property.ReadOnlyObjectProperty) ObservableList(javafx.collections.ObservableList) TableColumn(javafx.scene.control.TableColumn) Column(au.gov.asd.tac.constellation.views.tableview.api.Column) ListChangeListener(javafx.collections.ListChangeListener) ChangeListener(javafx.beans.value.ChangeListener) ActiveTableReference(au.gov.asd.tac.constellation.views.tableview.api.ActiveTableReference) TableView(javafx.scene.control.TableView) TablePane(au.gov.asd.tac.constellation.views.tableview.panes.TablePane) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with TableViewTopComponent

use of au.gov.asd.tac.constellation.views.tableview.TableViewTopComponent 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)

Aggregations

TableViewTopComponent (au.gov.asd.tac.constellation.views.tableview.TableViewTopComponent)2 ActiveTableReference (au.gov.asd.tac.constellation.views.tableview.api.ActiveTableReference)2 Column (au.gov.asd.tac.constellation.views.tableview.api.Column)2 TablePane (au.gov.asd.tac.constellation.views.tableview.panes.TablePane)2 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)2 TableColumn (javafx.scene.control.TableColumn)2 BeforeMethod (org.testng.annotations.BeforeMethod)2 Attribute (au.gov.asd.tac.constellation.graph.Attribute)1 Graph (au.gov.asd.tac.constellation.graph.Graph)1 GraphAttribute (au.gov.asd.tac.constellation.graph.GraphAttribute)1 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)1 Table (au.gov.asd.tac.constellation.views.tableview.components.Table)1 TableViewState (au.gov.asd.tac.constellation.views.tableview.state.TableViewState)1 ReadOnlyObjectProperty (javafx.beans.property.ReadOnlyObjectProperty)1 ChangeListener (javafx.beans.value.ChangeListener)1 ListChangeListener (javafx.collections.ListChangeListener)1 ObservableList (javafx.collections.ObservableList)1 TableView (javafx.scene.control.TableView)1 TableViewSelectionModel (javafx.scene.control.TableView.TableViewSelectionModel)1