Search in sources :

Example 31 with BaseGridRow

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow in project kie-wb-common by kiegroup.

the class AddListRowCommandTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    this.list = new List();
    this.hasExpression = HasExpression.wrap(list, new LiteralExpression());
    this.uiModel = new BaseGridData();
    this.uiModelRow = new BaseGridRow();
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.uiModel.appendColumn(uiExpressionEditorColumn);
    when(gridWidget.getModel()).thenReturn(uiModel);
    when(handler.getRuleManager()).thenReturn(ruleManager);
    when(uiRowNumberColumn.getIndex()).thenReturn(0);
    when(uiExpressionEditorColumn.getIndex()).thenReturn(1);
    this.uiModel.setCellValue(0, EXPRESSION_COLUMN_INDEX, new ExpressionCellValue(Optional.of(literalExpressionEditor)));
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add(literalExpressionEditorDefinition);
    when(literalExpressionEditor.getParentInformation()).thenReturn(parent);
    when(literalExpressionEditorDefinition.getModelClass()).thenReturn(Optional.of(new LiteralExpression()));
    when(literalExpressionEditorDefinition.getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt())).thenReturn(Optional.of(literalExpressionEditor));
    this.uiModelMapper = spy(new ListUIModelMapper(gridWidget, () -> uiModel, () -> Optional.of(list), () -> false, () -> expressionEditorDefinitions, listSelector, 0));
}
Also used : ExpressionEditorDefinitions(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) Optional(java.util.Optional) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) ListUIModelMapper(org.kie.workbench.common.dmn.client.editors.expressions.types.list.ListUIModelMapper) List(org.kie.workbench.common.dmn.api.definition.model.List) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Before(org.junit.Before)

Example 32 with BaseGridRow

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow in project kie-wb-common by kiegroup.

the class AddListRowCommandTest method testCanvasCommandExecuteMultipleEntries.

@Test
public void testCanvasCommandExecuteMultipleEntries() {
    makeCommand();
    // first row
    command.newGraphCommand(handler).execute(gce);
    final Command<AbstractCanvasHandler, CanvasViolation> firstEntryCanvasCommand = command.newCanvasCommand(handler);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, firstEntryCanvasCommand.execute(handler));
    verify(command).updateRowNumbers();
    verify(command).updateParentInformation();
    // second row
    final HasExpression secondRowEntry = HasExpression.wrap(list, new LiteralExpression());
    final GridRow uiSecondModelRow = new BaseGridRow();
    command = spy(new AddListRowCommand(list, secondRowEntry, uiModel, uiSecondModelRow, list.getExpression().size(), uiModelMapper, canvasOperation));
    command.newGraphCommand(handler).execute(gce);
    final Command<AbstractCanvasHandler, CanvasViolation> secondEntryCanvasCommand = command.newCanvasCommand(handler);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, secondEntryCanvasCommand.execute(handler));
    verify(command).updateRowNumbers();
    verify(command).updateParentInformation();
    assertEquals(2, uiModel.getRowCount());
    assertEquals(uiModelRow, uiModel.getRows().get(0));
    assertEquals(uiSecondModelRow, uiModel.getRows().get(1));
    assertEquals(2, uiModel.getColumnCount());
    assertEquals(uiRowNumberColumn, uiModel.getColumns().get(ROW_COLUMN_INDEX));
    assertEquals(uiExpressionEditorColumn, uiModel.getColumns().get(EXPRESSION_COLUMN_INDEX));
    assertEquals(2, uiModel.getRows().get(0).getCells().size());
    assertEquals(1, uiModel.getCell(0, ROW_COLUMN_INDEX).getValue().getValue());
    assertTrue(uiModel.getCell(0, EXPRESSION_COLUMN_INDEX).getValue() instanceof ExpressionCellValue);
    assertEquals(2, uiModel.getRows().get(1).getCells().size());
    assertEquals(2, uiModel.getCell(1, ROW_COLUMN_INDEX).getValue().getValue());
    assertTrue(uiModel.getCell(1, EXPRESSION_COLUMN_INDEX).getValue() instanceof ExpressionCellValue);
    verify(canvasOperation, times(2)).execute();
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow) Test(org.junit.Test)

Example 33 with BaseGridRow

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow in project kie-wb-common by kiegroup.

the class DeleteListRowCommandTest method setup.

@Before
public void setup() {
    this.list = new List();
    this.uiModel = new BaseGridData();
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.uiModel.appendColumn(uiExpressionEditorColumn);
    this.uiModel.appendRow(new BaseGridRow());
    this.list.getExpression().add(HasExpression.wrap(list, new LiteralExpression()));
    doReturn(ruleManager).when(handler).getRuleManager();
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiExpressionEditorColumn).getIndex();
}
Also used : BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) List(org.kie.workbench.common.dmn.api.definition.model.List) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Before(org.junit.Before)

Example 34 with BaseGridRow

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow in project kie-wb-common by kiegroup.

the class BaseMoveCommandsTest method addUiModelRow.

protected void addUiModelRow(final int rowIndex) {
    final GridRow uiRow = new BaseGridRow();
    uiModel.appendRow(uiRow);
    uiModel.setCellValue(rowIndex, 0, new BaseGridCellValue<>(rowIndex + 1));
}
Also used : BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow)

Example 35 with BaseGridRow

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow in project kie-wb-common by kiegroup.

the class MoveRowsCommandTest method addUiModelRow.

protected void addUiModelRow(final int rowIndex) {
    final GridRow uiRow = new BaseGridRow();
    uiModel.appendRow(uiRow);
    uiModel.setCellValue(rowIndex, 0, new BaseGridCellValue<>(rowIndex + 1));
    uiModel.setCellValue(rowIndex, 1, new BaseGridCellValue<>("editor" + rowIndex));
}
Also used : BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow)

Aggregations

BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)104 Test (org.junit.Test)57 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)25 Before (org.junit.Before)24 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)19 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)18 GridRow (org.uberfire.ext.wires.core.grids.client.model.GridRow)18 List (org.kie.workbench.common.dmn.api.definition.model.List)14 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)14 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)11 Optional (java.util.Optional)10 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)10 InformationItem (org.kie.workbench.common.dmn.api.definition.model.InformationItem)10 DecisionRule (org.kie.workbench.common.dmn.api.definition.model.DecisionRule)9 ExpressionCellValue (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)9 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)9 GridColumn (org.uberfire.ext.wires.core.grids.client.model.GridColumn)9 RowNumberColumn (org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn)9 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)8 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)8