Search in sources :

Example 36 with List

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());
}
Also used : BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) List(org.kie.workbench.common.dmn.api.definition.model.List) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) Test(org.junit.Test)

Example 37 with List

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);
}
Also used : List(org.kie.workbench.common.dmn.api.definition.model.List) Test(org.junit.Test)

Example 38 with List

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());
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) List(org.kie.workbench.common.dmn.api.definition.model.List) Test(org.junit.Test)

Example 39 with List

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;
}
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) List(org.kie.workbench.common.dmn.api.definition.model.List) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)

Aggregations

List (org.kie.workbench.common.dmn.api.definition.model.List)39 Test (org.junit.Test)22 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)21 BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)13 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)10 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)10 InformationItem (org.kie.workbench.common.dmn.api.definition.model.InformationItem)9 Relation (org.kie.workbench.common.dmn.api.definition.model.Relation)9 ArrayList (java.util.ArrayList)7 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)7 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)7 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)7 Before (org.junit.Before)6 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)5 HasComponentWidths (org.kie.workbench.common.dmn.api.definition.HasComponentWidths)4 Context (org.kie.workbench.common.dmn.api.definition.model.Context)4 DecisionTable (org.kie.workbench.common.dmn.api.definition.model.DecisionTable)4 FunctionDefinition (org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition)4 Invocation (org.kie.workbench.common.dmn.api.definition.model.Invocation)4 IsLiteralExpression (org.kie.workbench.common.dmn.api.definition.model.IsLiteralExpression)4