Search in sources :

Example 26 with LiteralExpression

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

the class DeleteOutputClauseCommandTest method testGraphCommandExecuteRemoveMiddle.

@Test
public void testGraphCommandExecuteRemoveMiddle() {
    final OutputClause firstOutput = mock(OutputClause.class);
    final OutputClause lastOutput = mock(OutputClause.class);
    dtable.getOutput().add(0, firstOutput);
    dtable.getOutput().add(lastOutput);
    final LiteralExpression outputOneValue = mock(LiteralExpression.class);
    final LiteralExpression outputTwoValue = mock(LiteralExpression.class);
    final LiteralExpression outputThreeValue = mock(LiteralExpression.class);
    final DecisionRule rule = new DecisionRule();
    rule.getOutputEntry().add(outputOneValue);
    rule.getOutputEntry().add(outputTwoValue);
    rule.getOutputEntry().add(outputThreeValue);
    dtable.getRule().add(rule);
    makeCommand(DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT + dtable.getInput().size() + 1);
    final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
    assertEquals(GraphCommandResultBuilder.SUCCESS, graphCommand.execute(graphCommandExecutionContext));
    assertEquals(2, dtable.getOutput().size());
    assertEquals(firstOutput, dtable.getOutput().get(0));
    assertEquals(lastOutput, dtable.getOutput().get(1));
    assertEquals(2, dtable.getRule().get(0).getOutputEntry().size());
    assertEquals(outputOneValue, dtable.getRule().get(0).getOutputEntry().get(0));
    assertEquals(outputThreeValue, dtable.getRule().get(0).getOutputEntry().get(1));
}
Also used : OutputClause(org.kie.workbench.common.dmn.api.definition.model.OutputClause) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) DecisionRule(org.kie.workbench.common.dmn.api.definition.model.DecisionRule) Test(org.junit.Test)

Example 27 with LiteralExpression

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

the class MoveColumnsCommandTest method setUp.

@Before
public void setUp() {
    this.dtable = new DecisionTable();
    this.uiModel = new DMNGridData();
    dtable.getInput().add(inputClauseOne);
    dtable.getInput().add(inputClauseTwo);
    dtable.getInput().add(inputClauseThree);
    dtable.getOutput().add(outputClauseOne);
    dtable.getOutput().add(outputClauseTwo);
    dtable.getOutput().add(outputClauseThree);
    dtable.getAnnotations().add(annotationClauseOne);
    dtable.getAnnotations().add(annotationClauseTwo);
    dtable.getAnnotations().add(annotationClauseThree);
    dtable.getRule().add(new DecisionRule() {

        {
            getInputEntry().add(new UnaryTests());
            getInputEntry().add(new UnaryTests());
            getInputEntry().add(new UnaryTests());
            getOutputEntry().add(new LiteralExpression());
            getOutputEntry().add(new LiteralExpression());
            getOutputEntry().add(new LiteralExpression());
            getAnnotationEntry().add(new RuleAnnotationClauseText());
            getAnnotationEntry().add(new RuleAnnotationClauseText());
            getAnnotationEntry().add(new RuleAnnotationClauseText());
        }
    });
    uiModel.appendColumn(uiRowNumberColumn);
    uiModel.appendColumn(uiInputClauseColumnOne);
    uiModel.appendColumn(uiInputClauseColumnTwo);
    uiModel.appendColumn(uiInputClauseColumnThree);
    uiModel.appendColumn(uiOutputClauseColumnOne);
    uiModel.appendColumn(uiOutputClauseColumnTwo);
    uiModel.appendColumn(uiOutputClauseColumnThree);
    uiModel.appendColumn(uiRuleAnnotationClauseColumnOne);
    uiModel.appendColumn(uiRuleAnnotationClauseColumnTwo);
    uiModel.appendColumn(uiRuleAnnotationClauseColumnThree);
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiInputClauseColumnOne).getIndex();
    doReturn(2).when(uiInputClauseColumnTwo).getIndex();
    doReturn(3).when(uiInputClauseColumnThree).getIndex();
    doReturn(4).when(uiOutputClauseColumnOne).getIndex();
    doReturn(5).when(uiOutputClauseColumnTwo).getIndex();
    doReturn(6).when(uiOutputClauseColumnThree).getIndex();
    doReturn(7).when(uiRuleAnnotationClauseColumnOne).getIndex();
    doReturn(8).when(uiRuleAnnotationClauseColumnTwo).getIndex();
    doReturn(9).when(uiRuleAnnotationClauseColumnThree).getIndex();
}
Also used : DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) RuleAnnotationClauseText(org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClauseText) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) UnaryTests(org.kie.workbench.common.dmn.api.definition.model.UnaryTests) DecisionRule(org.kie.workbench.common.dmn.api.definition.model.DecisionRule) Before(org.junit.Before)

Example 28 with LiteralExpression

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

the class HasExpressionTest method testWrapNonNull.

@Test
public void testWrapNonNull() {
    final LiteralExpression le = new LiteralExpression();
    final HasExpression hasExpression = HasExpression.wrap(parent, le);
    assertNotNull(hasExpression.getExpression());
    assertEquals(le, hasExpression.getExpression());
    assertEquals(parent, hasExpression.asDMNModelInstrumentedBase());
    final Context context = new Context();
    hasExpression.setExpression(context);
    assertNotNull(hasExpression.getExpression());
    assertEquals(context, hasExpression.getExpression());
    assertEquals(parent, hasExpression.asDMNModelInstrumentedBase());
}
Also used : Context(org.kie.workbench.common.dmn.api.definition.model.Context) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) Test(org.junit.Test)

Example 29 with LiteralExpression

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

the class ListEditorDefinition method enrich.

@Override
public void enrich(final Optional<String> nodeUUID, final HasExpression hasExpression, final Optional<List> expression) {
    expression.ifPresent(list -> {
        final LiteralExpression literalExpression = new LiteralExpression();
        list.getExpression().add(HasExpression.wrap(list, literalExpression));
        literalExpression.setParent(list);
    });
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)

Example 30 with LiteralExpression

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

the class ListGrid method addRow.

void addRow(final int index) {
    getExpression().get().ifPresent(list -> {
        final GridRow listRow = new ExpressionEditorGridRow();
        final HasExpression hasExpression = HasExpression.wrap(list, new LiteralExpression());
        sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new AddListRowCommand(list, hasExpression, model, listRow, index, uiModelMapper, () -> resize(BaseExpressionGrid.RESIZE_EXISTING)));
    });
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) AddListRowCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.list.AddListRowCommand) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) ExpressionEditorGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.ExpressionEditorGridRow) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow) ExpressionEditorGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.ExpressionEditorGridRow)

Aggregations

LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)113 Test (org.junit.Test)64 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)25 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)25 InformationItem (org.kie.workbench.common.dmn.api.definition.model.InformationItem)23 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)21 List (org.kie.workbench.common.dmn.api.definition.model.List)20 UnaryTests (org.kie.workbench.common.dmn.api.definition.model.UnaryTests)16 DecisionRule (org.kie.workbench.common.dmn.api.definition.model.DecisionRule)15 BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)14 Before (org.junit.Before)13 RuleAnnotationClauseText (org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClauseText)12 Optional (java.util.Optional)11 TLiteralExpression (org.kie.dmn.model.v1_2.TLiteralExpression)11 HasComponentWidths (org.kie.workbench.common.dmn.api.definition.HasComponentWidths)11 FunctionDefinition (org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition)11 Context (org.kie.workbench.common.dmn.api.definition.model.Context)10 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)10 ContextEntry (org.kie.workbench.common.dmn.api.definition.model.ContextEntry)9 Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)9