use of au.gov.asd.tac.constellation.views.tableview.api.Column in project constellation by constellation-app.
the class ColumnVisibilityContextMenuNGTest method createColumnVisibilityMenuItemNotSelected.
@Test
public void createColumnVisibilityMenuItemNotSelected() {
final String columnText = "Some Column Text";
final boolean isSelected = false;
when(column1.getText()).thenReturn(columnText);
when(column1.visibleProperty()).thenReturn(new SimpleBooleanProperty(isSelected));
final CustomMenuItem columnVisibilityMenuItem = columnVisibilityContextMenu.createColumnVisibilityMenu(new Column(columnType1, attribute1, column1));
verifyColumnVisibilityCheckBox(columnVisibilityMenuItem, isSelected, columnText, List.of(Tuple.create(columnType1, attribute1)), UpdateMethod.REMOVE);
}
use of au.gov.asd.tac.constellation.views.tableview.api.Column in project constellation by constellation-app.
the class TableCellFactoryNGTest method updateItemTestMouseClickWrongButton.
@Test
public void updateItemTestMouseClickWrongButton() {
final CopyOnWriteArrayList<Column> columnIndex = new CopyOnWriteArrayList<>();
when(table.getColumnIndex()).thenReturn(columnIndex);
tableCellFactory.updateItem("Test Value", false);
final MouseEvent mouseEvent = mock(MouseEvent.class);
when(mouseEvent.getButton()).thenReturn(MouseButton.PRIMARY);
tableCellFactory.getOnMouseClicked().handle(mouseEvent);
verify(tableCellFactory, times(0)).getRightClickContextMenu();
}
use of au.gov.asd.tac.constellation.views.tableview.api.Column in project constellation by constellation-app.
the class TableCellFactoryNGTest method updateItemTestMouseClick.
@Test
public void updateItemTestMouseClick() {
final ObservableList<String> styleClass = spy(FXCollections.observableArrayList());
doReturn(styleClass).when(tableCellFactory).getStyleClass();
final CopyOnWriteArrayList<Column> columnIndex = new CopyOnWriteArrayList<>();
when(table.getColumnIndex()).thenReturn(columnIndex);
tableCellFactory.updateItem("Test Value", false);
final TableView<ObservableList<String>> tableView = mock(TableView.class);
final RightClickContextMenu rightClickContextMenu = mock(RightClickContextMenu.class);
final ContextMenu contextMenu = mock(ContextMenu.class);
final MouseEvent mouseEvent = mock(MouseEvent.class);
doReturn(rightClickContextMenu).when(tableCellFactory).getRightClickContextMenu();
when(rightClickContextMenu.getContextMenu()).thenReturn(contextMenu);
when(mouseEvent.getScreenX()).thenReturn(20.0d);
when(mouseEvent.getScreenY()).thenReturn(40.0d);
when(mouseEvent.getButton()).thenReturn(MouseButton.SECONDARY);
when(table.getTableView()).thenReturn(tableView);
tableCellFactory.getOnMouseClicked().handle(mouseEvent);
verify(contextMenu).show(tableView, 20.0d, 40.0d);
assertEquals(FXCollections.observableArrayList(), styleClass);
}
use of au.gov.asd.tac.constellation.views.tableview.api.Column in project constellation by constellation-app.
the class TableCellFactoryNGTest method verifyStyle.
/**
* Verifies that the cell text is set correctly and the correct style for
* the column is added to the style class list.
*
* @param item the string passed in to be set in the table cell
* @param columnPrefix the column prefix for this cells column
* @param expectedText the expected string that will be set to the cell
* @param expectedStyles the expected styles that should be present in the
* style class list
*/
private void verifyStyle(final String item, final String columnPrefix, final String expectedText, final List<String> expectedStyles) {
clearInvocations(tableCellFactory, table);
final ObservableList<String> styleClass = spy(FXCollections.observableArrayList());
doReturn(styleClass).when(tableCellFactory).getStyleClass();
final CopyOnWriteArrayList<Column> columnIndex = new CopyOnWriteArrayList<>();
columnIndex.add(new Column("source.", null, mock(TableColumn.class)));
columnIndex.add(new Column(columnPrefix, null, cellColumn));
columnIndex.add(new Column("transaction.", null, mock(TableColumn.class)));
when(table.getColumnIndex()).thenReturn(columnIndex);
tableCellFactory.updateItem(item, false);
verify(tableCellFactory).setText(expectedText);
verify(styleClass).remove("null-value");
verify(styleClass).remove("element-source");
verify(styleClass).remove("element-destination");
verify(styleClass).remove("element-transaction");
expectedStyles.forEach(expectedStyle -> verify(styleClass).add(expectedStyle));
assertEquals(FXCollections.observableList(expectedStyles), styleClass);
}
use of au.gov.asd.tac.constellation.views.tableview.api.Column in project constellation by constellation-app.
the class TableNGTest method getRowDataForVertex.
@Test
public void getRowDataForVertex() {
final ReadableGraph readableGraph = mock(ReadableGraph.class);
final Map<Integer, ObservableList<String>> elementIdToRowIndex = new HashMap<>();
final Map<ObservableList<String>, Integer> rowToElementIdIndex = new HashMap<>();
doReturn(elementIdToRowIndex).when(activeTableReference).getElementIdToRowIndex();
doReturn(rowToElementIdIndex).when(activeTableReference).getRowToElementIdIndex();
final int vertexId = 42;
// Set up the attributes for each column
when(readableGraph.getAttribute(GraphElementType.VERTEX, "COLUMN_A")).thenReturn(101);
when(readableGraph.getAttributeName(101)).thenReturn("COLUMN_A");
when(readableGraph.getAttributeElementType(101)).thenReturn(GraphElementType.VERTEX);
when(readableGraph.getAttributeType(101)).thenReturn("string");
final Object objectValue1 = new Object();
when(readableGraph.getObjectValue(101, vertexId)).thenReturn(objectValue1);
final Attribute attribute1 = new GraphAttribute(readableGraph, 101);
final CopyOnWriteArrayList<Column> columnIndex = new CopyOnWriteArrayList<>();
columnIndex.add(new Column(null, attribute1, null));
when(table.getColumnIndex()).thenReturn(columnIndex);
try (final MockedStatic<AbstractAttributeInteraction> attrInteractionMockedStatic = Mockito.mockStatic(AbstractAttributeInteraction.class)) {
final AbstractAttributeInteraction interaction = mock(AbstractAttributeInteraction.class);
attrInteractionMockedStatic.when(() -> AbstractAttributeInteraction.getInteraction("string")).thenReturn(interaction);
when(interaction.getDisplayText(objectValue1)).thenReturn("column1Value");
assertEquals(FXCollections.observableArrayList("column1Value"), table.getRowDataForVertex(readableGraph, vertexId));
assertEquals(Map.of(vertexId, FXCollections.observableArrayList("column1Value")), elementIdToRowIndex);
assertEquals(Map.of(FXCollections.observableArrayList("column1Value"), vertexId), rowToElementIdIndex);
}
}
Aggregations