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