use of org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue in project kie-wb-common by kiegroup.
the class ExpressionEditorGridRowTest method testRowHigherThanDefaultWithNullCell.
@Test
@SuppressWarnings("unchecked")
public void testRowHigherThanDefaultWithNullCell() {
when(view.getHeight()).thenReturn(DEFAULT_HEIGHT + 1);
final GridRow row = spy(ExpressionEditorGridRow.class);
final Map<Integer, GridCell<?>> cells = new Maps.Builder<Integer, GridCell<?>>().put(0, new BaseGridCell<>(new ExpressionCellValue(Optional.of(view)))).put(1, null).build();
when(row.getCells()).thenReturn(cells);
assertThat(row.getHeight()).isGreaterThan(DEFAULT_HEIGHT);
}
use of org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue in project kie-wb-common by kiegroup.
the class ExpressionEditorGridRowTest method testRowHigherThanDefaultWithNullCellValue.
@Test
@SuppressWarnings("unchecked")
public void testRowHigherThanDefaultWithNullCellValue() {
when(view.getHeight()).thenReturn(DEFAULT_HEIGHT + 1);
final GridRow row = spy(ExpressionEditorGridRow.class);
final Map<Integer, GridCell<?>> cells = new Maps.Builder<Integer, GridCell<?>>().put(0, new BaseGridCell<>(new ExpressionCellValue(Optional.of(view)))).put(1, new BaseGridCell<>(null)).build();
when(row.getCells()).thenReturn(cells);
assertThat(row.getHeight()).isGreaterThan(DEFAULT_HEIGHT);
}
use of org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue 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.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue 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.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue in project kie-wb-common by kiegroup.
the class SetKindCommandTest method setupCommand.
private void setupCommand() {
final GridCellValueTuple gcv = new GridCellValueTuple<>(0, 0, gridWidget, new ExpressionCellValue(Optional.of(newEditor)));
this.command = new SetKindCommand(gcv, function, newKind, Optional.of(newExpression), executeCanvasOperation, undoCanvasOperation, () -> Optional.of(newEditor));
}
Aggregations