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));
}
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);
}
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);
}
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));
}
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));
}
Aggregations