Search in sources :

Example 96 with InformationItem

use of org.kie.workbench.common.dmn.api.definition.model.InformationItem in project kie-wb-common by kiegroup.

the class AddRelationColumnCommandTest method testCanvasCommandExecuteWithRowsAddColumnMiddle.

@Test
public void testCanvasCommandExecuteWithRowsAddColumnMiddle() {
    makeCommand(2);
    final InformationItem existingInformationItemFirst = new InformationItem();
    relation.getColumn().add(existingInformationItemFirst);
    final InformationItem existingInformationItemLast = new InformationItem();
    relation.getColumn().add(existingInformationItemLast);
    uiModel.appendColumn(mock(RelationColumn.class));
    uiModel.appendColumn(mock(RelationColumn.class));
    uiModel.appendRow(new BaseGridRow());
    // Add Graph column first as RelationUIModelMapper relies on the model being first updated
    command.newGraphCommand(handler).execute(gce);
    final Command<AbstractCanvasHandler, CanvasViolation> cc = command.newCanvasCommand(handler);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, cc.execute(handler));
    assertEquals(4, uiModel.getColumnCount());
    assertEquals(uiModelColumn, uiModel.getColumns().get(2));
}
Also used : RelationColumn(org.kie.workbench.common.dmn.client.editors.expressions.types.relation.RelationColumn) CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) Test(org.junit.Test)

Example 97 with InformationItem

use of org.kie.workbench.common.dmn.api.definition.model.InformationItem 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 98 with InformationItem

use of org.kie.workbench.common.dmn.api.definition.model.InformationItem in project kie-wb-common by kiegroup.

the class DeleteRelationRowCommandTest method testCanvasCommandUndoWithColumns.

@Test
public void testCanvasCommandUndoWithColumns() {
    relation.getColumn().add(new InformationItem());
    final LiteralExpression literalExpression = new LiteralExpression();
    literalExpression.getText().setValue(VALUE);
    relation.getRow().get(0).getExpression().add(HasExpression.wrap(rowList, literalExpression));
    uiModel.appendColumn(uiModelColumn);
    uiModelMapper.fromDMNModel(0, 0);
    uiModelMapper.fromDMNModel(0, 1);
    // Delete row and then undo
    final Command<AbstractCanvasHandler, CanvasViolation> cc = command.newCanvasCommand(handler);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, cc.execute(handler));
    reset(command, canvasOperation);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, cc.undo(handler));
    assertEquals(2, uiModel.getColumnCount());
    assertEquals(uiRowNumberColumn, uiModel.getColumns().get(0));
    assertEquals(uiModelColumn, uiModel.getColumns().get(1));
    assertEquals(1, uiModel.getRowCount());
    assertEquals(1, uiModel.getCell(0, 0).getValue().getValue());
    assertEquals(VALUE, uiModel.getCell(0, 1).getValue().getValue());
    verify(command).updateRowNumbers();
    verify(command).updateParentInformation();
    verify(canvasOperation).execute();
}
Also used : CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) Test(org.junit.Test)

Example 99 with InformationItem

use of org.kie.workbench.common.dmn.api.definition.model.InformationItem in project kie-wb-common by kiegroup.

the class BindingPropertyConverter method wbFromDMN.

public static Binding wbFromDMN(final JSITBinding dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
    if (Objects.isNull(dmn)) {
        return null;
    }
    final InformationItem parameter = InformationItemPropertyConverter.wbFromDMN(dmn.getParameter());
    Expression expression = null;
    final JSITExpression jsiWrapped = dmn.getExpression();
    if (Objects.nonNull(jsiWrapped)) {
        final JSITExpression jsiExpression = Js.uncheckedCast(JsUtils.getUnwrappedElement(jsiWrapped));
        expression = ExpressionPropertyConverter.wbFromDMN(jsiExpression, Js.uncheckedCast(dmn), hasComponentWidthsConsumer);
    }
    final Binding result = new Binding();
    if (Objects.nonNull(parameter)) {
        parameter.setParent(result);
    }
    result.setParameter(parameter);
    if (Objects.nonNull(expression)) {
        expression.setParent(result);
    }
    result.setExpression(expression);
    return result;
}
Also used : Binding(org.kie.workbench.common.dmn.api.definition.model.Binding) JSITBinding(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITBinding) JSITExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) JSITInformationItem(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInformationItem) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) JSITExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITExpression)

Example 100 with InformationItem

use of org.kie.workbench.common.dmn.api.definition.model.InformationItem in project kie-wb-common by kiegroup.

the class DecisionTableGridTest method testSelectHeaderMultipleOutputClauseColumnNestedContextEntry.

@Test
@SuppressWarnings("unchecked")
public void testSelectHeaderMultipleOutputClauseColumnNestedContextEntry() {
    // Mock nesting of DecisionTable in a ContextEntry
    final Context context = new Context();
    final ContextEntry contextEntry = new ContextEntry();
    final InformationItem variable = new InformationItem();
    contextEntry.setVariable(variable);
    context.getContextEntry().add(contextEntry);
    contextEntry.setExpression(expression.get());
    this.hasExpression.setExpression(context);
    this.grid = spy((DecisionTableGrid) definition.getEditor(parent, Optional.empty(), contextEntry, makeHasNameForDecision(), false, 1).get());
    addOutputClause(2);
    reset(domainObjectSelectionEvent);
    grid.selectHeaderCell(0, DEFAULT_OUTPUT_CLAUSE_COLUMN_INDEX, false, false);
    assertDomainObjectSelection(variable);
    reset(domainObjectSelectionEvent);
    grid.selectHeaderCell(1, DEFAULT_OUTPUT_CLAUSE_COLUMN_INDEX, false, false);
    assertDomainObjectSelection(expression.get().getOutput().get(0));
}
Also used : GridBodyCellEditContext(org.uberfire.ext.wires.core.grids.client.widget.context.GridBodyCellEditContext) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) Context(org.kie.workbench.common.dmn.api.definition.model.Context) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) ContextEntry(org.kie.workbench.common.dmn.api.definition.model.ContextEntry) Test(org.junit.Test)

Aggregations

InformationItem (org.kie.workbench.common.dmn.api.definition.model.InformationItem)110 Test (org.junit.Test)61 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)24 ContextEntry (org.kie.workbench.common.dmn.api.definition.model.ContextEntry)22 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)22 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)20 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)19 Binding (org.kie.workbench.common.dmn.api.definition.model.Binding)13 Context (org.kie.workbench.common.dmn.api.definition.model.Context)11 Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)11 Before (org.junit.Before)10 List (org.kie.workbench.common.dmn.api.definition.model.List)10 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)10 BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)10 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)9 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)9 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)9 HasName (org.kie.workbench.common.dmn.api.definition.HasName)7 Relation (org.kie.workbench.common.dmn.api.definition.model.Relation)7 JSITInformationItem (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInformationItem)7