use of org.kie.workbench.common.dmn.api.definition.model.List in project kie-wb-common by kiegroup.
the class DeleteRelationRowCommandTest method testGraphCommandExecuteRemoveMiddleWithColumns.
@Test
public void testGraphCommandExecuteRemoveMiddleWithColumns() {
uiModel.appendRow(new BaseGridRow());
uiModel.appendRow(new BaseGridRow());
final List firstRow = new List();
final List lastRow = new List();
relation.getRow().add(0, firstRow);
relation.getRow().add(lastRow);
relation.getColumn().add(new InformationItem());
relation.getRow().get(0).getExpression().add(HasExpression.wrap(rowList, new LiteralExpression()));
makeCommand(1);
final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
assertEquals(2, relation.getRow().size());
assertEquals(firstRow, relation.getRow().get(0));
assertEquals(lastRow, relation.getRow().get(1));
assertEquals(1, relation.getColumn().size());
}
use of org.kie.workbench.common.dmn.api.definition.model.List in project kie-wb-common by kiegroup.
the class RelationGridTest method testDeleteRow.
@Test
public void testDeleteRow() {
relation.getRow().add(new List());
setupGrid(0);
grid.deleteRow(0);
verify(sessionCommandManager).execute(eq(canvasHandler), deleteRowCommand.capture());
deleteRowCommand.getValue().execute(canvasHandler);
verifyCommandExecuteOperation(BaseExpressionGrid.RESIZE_EXISTING);
}
use of org.kie.workbench.common.dmn.api.definition.model.List in project kie-wb-common by kiegroup.
the class RelationGridTest method testInitialiseUiModel.
@Test
public void testInitialiseUiModel() {
relation.getColumn().add(new InformationItem() {
{
getName().setValue("first column header");
}
});
final String firstRowValue = "first column value 1";
final String secondRowValue = "first column value 2";
final List rowList1 = new List();
rowList1.getExpression().add(HasExpression.wrap(rowList1, new LiteralExpression() {
{
getText().setValue(firstRowValue);
}
}));
final List rowList2 = new List();
rowList2.getExpression().add(HasExpression.wrap(rowList2, new LiteralExpression() {
{
getText().setValue(secondRowValue);
}
}));
relation.getRow().add(rowList1);
relation.getRow().add(rowList2);
expression = Optional.of(relation);
setupGrid(0);
assertEquals(2, grid.getModel().getRowCount());
assertEquals(firstRowValue, grid.getModel().getRow(0).getCells().get(1).getValue().getValue());
assertEquals(secondRowValue, grid.getModel().getRow(1).getCells().get(1).getValue().getValue());
}
use of org.kie.workbench.common.dmn.api.definition.model.List in project kie-wb-common by kiegroup.
the class ListUIModelMapperTest method setup.
@SuppressWarnings("unchecked")
public void setup(final Expression expression, final boolean isOnlyVisualChangeAllowedSupplier) {
this.uiModel = new BaseGridData();
this.uiModel.appendRow(new BaseGridRow());
this.uiModel.appendRow(new BaseGridRow());
this.uiModel.appendColumn(uiRowNumberColumn);
this.uiModel.appendColumn(uiExpressionEditorColumn);
when(uiRowNumberColumn.getIndex()).thenReturn(0);
when(uiExpressionEditorColumn.getIndex()).thenReturn(1);
final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
expressionEditorDefinitions.add(literalExpressionEditorDefinition);
expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
when(expressionEditorDefinitionsSupplier.get()).thenReturn(expressionEditorDefinitions);
when(literalExpressionEditor.getExpression()).thenReturn(() -> Optional.of(literalExpression));
when(literalExpressionEditorDefinition.getModelClass()).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(undefinedExpressionEditor.getExpression()).thenReturn(Optional::empty);
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.list = new List();
this.list.getExpression().add(HasExpression.wrap(list, expression));
this.mapper = new ListUIModelMapper(gridWidget, () -> uiModel, () -> Optional.of(list), () -> isOnlyVisualChangeAllowedSupplier, expressionEditorDefinitionsSupplier, listSelector, 0);
this.cellValueSupplier = Optional::empty;
}
Aggregations