Search in sources :

Example 26 with InformationItem

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

the class RelationUIModelMapperTest method setup.

@Before
public void setup() {
    this.uiModel = new BaseGridData();
    this.uiModel.appendRow(new DMNGridRow());
    this.uiModel.appendRow(new DMNGridRow());
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.uiModel.appendColumn(uiRelationColumn1);
    this.uiModel.appendColumn(uiRelationColumn2);
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiRelationColumn1).getIndex();
    doReturn(2).when(uiRelationColumn2).getIndex();
    this.relation = new Relation();
    this.relation.getColumn().add(new InformationItem());
    this.relation.getColumn().add(new InformationItem());
    this.relation.getRow().add(new List() {

        {
            getExpression().add(new LiteralExpression() {

                {
                    setText("le(1,0)");
                }
            });
            getExpression().add(new LiteralExpression() {

                {
                    setText("le(2,0)");
                }
            });
        }
    });
    this.relation.getRow().add(new List() {

        {
            getExpression().add(new LiteralExpression() {

                {
                    setText("le(1,1)");
                }
            });
            getExpression().add(new LiteralExpression() {

                {
                    setText("le(2,1)");
                }
            });
        }
    });
    this.mapper = new RelationUIModelMapper(() -> uiModel, () -> Optional.of(relation), listSelector);
    this.cellValueSupplier = Optional::empty;
}
Also used : Relation(org.kie.workbench.common.dmn.api.definition.v1_1.Relation) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) Optional(java.util.Optional) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) List(org.kie.workbench.common.dmn.api.definition.v1_1.List) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Before(org.junit.Before)

Example 27 with InformationItem

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

the class InvocationUIModelMapperTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    this.uiModel = new BaseGridData();
    this.uiModel.appendRow(new DMNGridRow());
    this.uiModel.appendRow(new DMNGridRow());
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.uiModel.appendColumn(uiNameColumn);
    this.uiModel.appendColumn(uiExpressionEditorColumn);
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiNameColumn).getIndex();
    doReturn(2).when(uiExpressionEditorColumn).getIndex();
    doReturn(uiModel).when(gridWidget).getModel();
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add(literalExpressionEditorDefinition);
    doReturn(expressionEditorDefinitions).when(expressionEditorDefinitionsSupplier).get();
    doReturn(Optional.of(literalExpression)).when(literalExpressionEditorDefinition).getModelClass();
    doReturn(Optional.of(literalExpression)).when(literalExpressionEditor).getExpression();
    doReturn(Optional.of(literalExpressionEditor)).when(literalExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
    final LiteralExpression invocationExpression = new LiteralExpression();
    invocationExpression.setText("invocation-expression");
    final LiteralExpression bindingExpression = new LiteralExpression();
    bindingExpression.setText("binding-expression");
    final Binding binding = new Binding();
    final InformationItem parameter = new InformationItem();
    parameter.setName(new Name("p0"));
    binding.setParameter(parameter);
    binding.setExpression(bindingExpression);
    this.invocation = new Invocation();
    this.invocation.setExpression(invocationExpression);
    this.invocation.getBinding().add(binding);
    this.mapper = new InvocationUIModelMapper(gridWidget, () -> uiModel, () -> Optional.of(invocation), expressionEditorDefinitionsSupplier, listSelector, 0);
    this.cellValueSupplier = Optional::empty;
}
Also used : Binding(org.kie.workbench.common.dmn.api.definition.v1_1.Binding) 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) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) Optional(java.util.Optional) Invocation(org.kie.workbench.common.dmn.api.definition.v1_1.Invocation) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Before(org.junit.Before)

Example 28 with InformationItem

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

the class AddParameterCommandTest method testGraphCommandUndoWithParameters.

@Test
public void testGraphCommandUndoWithParameters() {
    final InformationItem otherParameter = new InformationItem();
    function.getFormalParameter().add(otherParameter);
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    // Add parameter and then undo
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce));
    assertFormalParameters(1, otherParameter);
}
Also used : GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) Test(org.junit.Test)

Example 29 with InformationItem

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

the class AddParameterCommandTest method testGraphCommandExecuteWithParameters.

@Test
public void testGraphCommandExecuteWithParameters() {
    final InformationItem otherParameter = new InformationItem();
    function.getFormalParameter().add(otherParameter);
    final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
    assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
    assertFormalParameters(2, otherParameter, parameter);
}
Also used : GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) Test(org.junit.Test)

Example 30 with InformationItem

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

the class RemoveParameterCommandTest method setup.

@Before
public void setup() {
    this.function = new FunctionDefinition();
    this.parameter = new InformationItem();
    this.function.getFormalParameter().add(parameter);
    this.command = new RemoveParameterCommand(function, parameter, canvasOperation);
    doReturn(ruleManager).when(handler).getRuleManager();
}
Also used : FunctionDefinition(org.kie.workbench.common.dmn.api.definition.v1_1.FunctionDefinition) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) Before(org.junit.Before)

Aggregations

InformationItem (org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem)66 Test (org.junit.Test)33 LiteralExpression (org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)20 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)20 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)19 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)18 DMNGridRow (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow)12 Before (org.junit.Before)11 ContextEntry (org.kie.workbench.common.dmn.api.definition.v1_1.ContextEntry)11 List (org.kie.workbench.common.dmn.api.definition.v1_1.List)10 Binding (org.kie.workbench.common.dmn.api.definition.v1_1.Binding)8 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)7 Optional (java.util.Optional)6 InformationItem (org.kie.dmn.model.v1_1.InformationItem)6 HasName (org.kie.workbench.common.dmn.api.definition.HasName)6 Relation (org.kie.workbench.common.dmn.api.definition.v1_1.Relation)6 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)6 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)6 Context (org.kie.workbench.common.dmn.api.definition.v1_1.Context)5 Expression (org.kie.workbench.common.dmn.api.definition.v1_1.Expression)5