Search in sources :

Example 6 with TablePane

use of au.gov.asd.tac.constellation.views.tableview.panes.TablePane 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 7 with TablePane

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

the class UpdateTableDataTaskNGTest method updateDataTask.

@Test
public void updateDataTask() {
    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 TriggerDataUpdateTask updateTableDataTask = new TriggerDataUpdateTask(tablePane, graph, tableViewState);
    updateTableDataTask.run();
    verify(table).updateData(graph, tableViewState, progressBar);
}
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 8 with TablePane

use of au.gov.asd.tac.constellation.views.tableview.panes.TablePane 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 9 with TablePane

use of au.gov.asd.tac.constellation.views.tableview.panes.TablePane 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 10 with TablePane

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

the class ActiveTableReferenceNGTest method updatePagination.

@Test
public void updatePagination() throws InterruptedException {
    final List<ObservableList<String>> newRowList = IntStream.range(0, 45).mapToObj(i -> FXCollections.observableList(List.of(Integer.toString(i)))).collect(Collectors.toList());
    final TablePane tablePane = mock(TablePane.class);
    final Pagination pagination = activeTableReference.updatePagination(22, newRowList, tablePane);
    assertEquals(3, pagination.getPageCount());
    assertSame(pageFactory, pagination.getPageFactory());
    verify(pageFactory).update(same(newRowList), eq(22));
    // This verification is dependent on code completing in the UI thread so
    // the following ensures that the verification does not occur until
    // the required code is run.
    final CountDownLatch latch = new CountDownLatch(1);
    Platform.runLater(() -> latch.countDown());
    latch.await();
    verify(tablePane).setCenter(same(pagination));
}
Also used : IntStream(java.util.stream.IntStream) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Mockito.doCallRealMethod(org.mockito.Mockito.doCallRealMethod) Tuple(au.gov.asd.tac.constellation.utilities.datastructure.Tuple) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) TimeoutException(java.util.concurrent.TimeoutException) FXCollections(javafx.collections.FXCollections) HashMap(java.util.HashMap) Test(org.testng.annotations.Test) FxToolkit(org.testfx.api.FxToolkit) Mockito.spy(org.mockito.Mockito.spy) AfterMethod(org.testng.annotations.AfterMethod) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) TableColumn(javafx.scene.control.TableColumn) Graph(au.gov.asd.tac.constellation.graph.Graph) Answer(org.mockito.stubbing.Answer) InvocationOnMock(org.mockito.invocation.InvocationOnMock) TableViewState(au.gov.asd.tac.constellation.views.tableview.state.TableViewState) Plugin(au.gov.asd.tac.constellation.plugins.Plugin) Map(java.util.Map) Attribute(au.gov.asd.tac.constellation.graph.Attribute) AssertJUnit.assertNotSame(org.testng.AssertJUnit.assertNotSame) PluginExecution(au.gov.asd.tac.constellation.plugins.PluginExecution) Mockito.doReturn(org.mockito.Mockito.doReturn) SortedList(javafx.collections.transformation.SortedList) AfterClass(org.testng.annotations.AfterClass) TablePane(au.gov.asd.tac.constellation.views.tableview.panes.TablePane) BeforeClass(org.testng.annotations.BeforeClass) BeforeMethod(org.testng.annotations.BeforeMethod) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) TableViewPageFactory(au.gov.asd.tac.constellation.views.tableview.factory.TableViewPageFactory) Mockito.verify(org.mockito.Mockito.verify) Platform(javafx.application.Platform) CountDownLatch(java.util.concurrent.CountDownLatch) Mockito(org.mockito.Mockito) List(java.util.List) MockedStatic(org.mockito.MockedStatic) AssertJUnit.assertSame(org.testng.AssertJUnit.assertSame) AssertJUnit.assertNotNull(org.testng.AssertJUnit.assertNotNull) ObservableList(javafx.collections.ObservableList) UpdateStatePlugin(au.gov.asd.tac.constellation.views.tableview.plugins.UpdateStatePlugin) AssertJUnit.assertEquals(org.testng.AssertJUnit.assertEquals) Pagination(javafx.scene.control.Pagination) ArgumentMatchers.same(org.mockito.ArgumentMatchers.same) Mockito.mock(org.mockito.Mockito.mock) Pagination(javafx.scene.control.Pagination) ObservableList(javafx.collections.ObservableList) CountDownLatch(java.util.concurrent.CountDownLatch) TablePane(au.gov.asd.tac.constellation.views.tableview.panes.TablePane) Test(org.testng.annotations.Test)

Aggregations

TablePane (au.gov.asd.tac.constellation.views.tableview.panes.TablePane)10 Test (org.testng.annotations.Test)8 Graph (au.gov.asd.tac.constellation.graph.Graph)6 TableViewState (au.gov.asd.tac.constellation.views.tableview.state.TableViewState)5 Pagination (javafx.scene.control.Pagination)5 Table (au.gov.asd.tac.constellation.views.tableview.components.Table)4 ObservableList (javafx.collections.ObservableList)4 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)3 ActiveTableReference (au.gov.asd.tac.constellation.views.tableview.api.ActiveTableReference)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 TableColumn (javafx.scene.control.TableColumn)3 BeforeMethod (org.testng.annotations.BeforeMethod)3 Attribute (au.gov.asd.tac.constellation.graph.Attribute)2 PluginExecution (au.gov.asd.tac.constellation.plugins.PluginExecution)2 TableViewTopComponent (au.gov.asd.tac.constellation.views.tableview.TableViewTopComponent)2 Column (au.gov.asd.tac.constellation.views.tableview.api.Column)2 ProgressBar (au.gov.asd.tac.constellation.views.tableview.components.ProgressBar)2 UpdateStatePlugin (au.gov.asd.tac.constellation.views.tableview.plugins.UpdateStatePlugin)2 ArrayList (java.util.ArrayList)2 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)2