use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow in project kie-wb-common by kiegroup.
the class BaseExpressionGridGeneralTest method testShowContextMenu.
@Test
@SuppressWarnings("unchecked")
public void testShowContextMenu() {
grid.getModel().appendColumn(new BaseGridColumn<Object>(mock(GridColumn.HeaderMetaData.class), mock(GridColumnRenderer.class), COLUMN_WIDTH));
final BaseGridRow gridRow = new BaseGridRow();
grid.getModel().appendRow(gridRow);
final DMNGridCell<?> dmnGridCellMock = mock(DMNGridCell.class);
final HasCellEditorControls.Editor cellControlsEditorMock = mock(HasCellEditorControls.Editor.class);
doReturn(Optional.of(cellControlsEditorMock)).when(dmnGridCellMock).getEditor();
grid.getModel().setCell(0, 0, () -> dmnGridCellMock);
assertThat(grid.showContextMenuForCell(0, 0)).isTrue();
verify(cellControlsEditorMock).bind(eq(grid), eq(0), eq(0));
verify(cellEditorControls).show(eq(cellControlsEditorMock), eq((int) COLUMN_WIDTH / 2), eq((int) (gridRow.getHeight() / 2 + HEADER_HEIGHT)));
}
use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow in project kie-wb-common by kiegroup.
the class BaseExpressionGridGeneralTest method testSelectExpressionEditorFirstCell.
@Test
public void testSelectExpressionEditorFirstCell() {
grid.getModel().appendRow(new BaseGridRow());
appendColumns(GridColumn.class);
final ExpressionCellValue cellValue = mock(ExpressionCellValue.class);
final BaseExpressionGrid cellGrid = mock(BaseExpressionGrid.class);
when(cellValue.getValue()).thenReturn(Optional.of(cellGrid));
grid.getModel().setCellValue(0, 0, cellValue);
grid.selectExpressionEditorFirstCell(0, 0);
verify(gridLayer).select(cellGrid);
verify(cellGrid).selectFirstCell();
}
use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow in project kie-wb-common by kiegroup.
the class AddInputClauseCommandTest method testCanvasCommandAddRuleAndThenUndo.
@Test
public void testCanvasCommandAddRuleAndThenUndo() throws Exception {
makeCommand(DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT);
final String ruleOneInputValue = "one";
final String ruleTwoInputValue = "two";
dtable.getRule().add(new DecisionRule());
dtable.getRule().add(new DecisionRule());
uiModel.appendRow(new BaseGridRow());
uiModel.appendRow(new BaseGridRow());
// Graph command populates InputEntries so overwrite with test values
final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
graphCommand.execute(graphCommandExecutionContext);
dtable.getRule().get(0).getInputEntry().get(0).getText().setValue(ruleOneInputValue);
dtable.getRule().get(1).getInputEntry().get(0).getText().setValue(ruleTwoInputValue);
final Command<AbstractCanvasHandler, CanvasViolation> canvasAddInputClauseCommand = command.newCanvasCommand(canvasHandler);
canvasAddInputClauseCommand.execute(canvasHandler);
// first rule
assertEquals(ruleOneInputValue, uiModel.getRow(0).getCells().get(1).getValue().getValue());
// second rule
assertEquals(ruleTwoInputValue, uiModel.getRow(1).getCells().get(1).getValue().getValue());
assertEquals(2, uiModel.getColumnCount());
assertEquals(CanvasCommandResultBuilder.SUCCESS, canvasAddInputClauseCommand.undo(canvasHandler));
assertEquals(1, uiModel.getColumnCount());
verify(executeCanvasOperation).execute();
verify(undoCanvasOperation).execute();
verify(command, times(2)).updateParentInformation();
}
use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow in project kie-wb-common by kiegroup.
the class ExpressionContainerUIModelMapperTest method setup.
@SuppressWarnings("unchecked")
public void setup(final boolean isOnlyVisualChangeAllowed) {
uiModel = new BaseGridData();
uiModel.appendRow(new BaseGridRow());
uiModel.appendColumn(uiExpressionColumn);
when(uiExpressionColumn.getIndex()).thenReturn(0);
when(uiExpressionColumn.getMinimumWidth()).thenReturn(MINIMUM_COLUMN_WIDTH);
parent = new GridCellTuple(0, 0, expressionContainerGrid);
final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
expressionEditorDefinitions.add(literalExpressionEditorDefinition);
expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
when(expressionEditorDefinitionsSupplier.get()).thenReturn(expressionEditorDefinitions);
when(literalExpressionEditorDefinition.getModelClass()).thenReturn(Optional.of(literalExpression));
when(literalExpressionEditor.isCacheable()).thenReturn(true);
when(literalExpressionEditor.getExpression()).thenReturn(() -> Optional.of(literalExpression));
when(literalExpressionEditorDefinition.getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt())).thenReturn(Optional.of(literalExpressionEditor));
when(undefinedExpressionEditorDefinition.getModelClass()).thenReturn(Optional.empty());
when(undefinedExpressionEditorDefinition.getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt())).thenReturn(Optional.of(undefinedExpressionEditor));
expressionGridCache = spy(new ExpressionGridCacheImpl());
mapper = new ExpressionContainerUIModelMapper(parent, () -> uiModel, () -> Optional.ofNullable(expression), () -> NODE_UUID, () -> hasExpression, () -> Optional.of(hasName), () -> isOnlyVisualChangeAllowed, expressionEditorDefinitionsSupplier, () -> expressionGridCache, listSelector);
}
use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow in project kie-wb-common by kiegroup.
the class BaseContextUIModelMapperTest method setup.
@SuppressWarnings("unchecked")
public void setup(final boolean isOnlyVisualChangeAllowedSupplier) {
this.uiModel = new BaseGridData();
this.uiModel.appendRow(new BaseGridRow());
this.uiModel.appendRow(new BaseGridRow());
this.uiModel.appendColumn(uiRowNumberColumn);
this.uiModel.appendColumn(uiNameColumn);
this.uiModel.appendColumn(uiExpressionEditorColumn);
when(uiRowNumberColumn.getIndex()).thenReturn(0);
when(uiNameColumn.getIndex()).thenReturn(1);
when(uiExpressionEditorColumn.getIndex()).thenReturn(2);
final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
expressionEditorDefinitions.add(literalExpressionEditorDefinition);
expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
when(expressionEditorDefinitionsSupplier.get()).thenReturn(expressionEditorDefinitions);
when(literalExpressionEditorDefinition.getModelClass()).thenReturn(Optional.of(literalExpression));
when(literalExpressionEditor.getExpression()).thenReturn(() -> Optional.of(literalExpression));
when(literalExpressionEditorDefinition.getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt())).thenReturn(Optional.of(literalExpressionEditor));
when(undefinedExpressionEditorDefinition.getModelClass()).thenReturn(Optional.empty());
when(undefinedExpressionEditorDefinition.getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt())).thenReturn(Optional.of(undefinedExpressionEditor));
this.context = new Context();
this.context.getContextEntry().add(new ContextEntry() {
{
setVariable(new InformationItem() {
{
setName(new Name("ii1"));
}
});
}
});
this.context.getContextEntry().add(new ContextEntry() {
{
setExpression(new LiteralExpression());
}
});
this.mapper = getMapper(isOnlyVisualChangeAllowedSupplier);
this.cellValueSupplier = Optional::empty;
}
Aggregations