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