Search in sources :

Example 26 with Expression

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

the class ContextEditorDefinitionTest method testEditor.

@Test
public void testEditor() {
    final Optional<Context> expression = definition.getModelClass();
    final Optional<BaseExpressionGrid> oEditor = definition.getEditor(parent, Optional.empty(), hasExpression, expression, hasName, 0);
    assertTrue(oEditor.isPresent());
    final GridWidget editor = oEditor.get();
    assertTrue(editor instanceof ContextGrid);
}
Also used : Context(org.kie.workbench.common.dmn.api.definition.v1_1.Context) GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) Test(org.junit.Test)

Example 27 with Expression

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

the class DecisionTableEditorDefinitionTest method testEditor.

@Test
public void testEditor() {
    final Optional<DecisionTable> expression = definition.getModelClass();
    final Optional<BaseExpressionGrid> oEditor = definition.getEditor(parent, Optional.empty(), hasExpression, expression, hasName, 0);
    assertThat(oEditor).isPresent();
    final GridWidget editor = oEditor.get();
    assertThat(editor).isInstanceOf(DecisionTableGrid.class);
}
Also used : DecisionTable(org.kie.workbench.common.dmn.api.definition.v1_1.DecisionTable) GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) Test(org.junit.Test)

Example 28 with Expression

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

the class FunctionEditorDefinitionTest method testEditor.

@Test
public void testEditor() {
    final Optional<FunctionDefinition> expression = definition.getModelClass();
    final Optional<BaseExpressionGrid> oEditor = definition.getEditor(parent, Optional.empty(), hasExpression, expression, hasName, 0);
    assertTrue(oEditor.isPresent());
    final GridWidget editor = oEditor.get();
    assertTrue(editor instanceof FunctionGrid);
}
Also used : GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) FunctionDefinition(org.kie.workbench.common.dmn.api.definition.v1_1.FunctionDefinition) Test(org.junit.Test)

Example 29 with Expression

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

the class InvocationEditorDefinitionTest method testEditor.

@Test
public void testEditor() {
    final Optional<Invocation> expression = definition.getModelClass();
    final Optional<BaseExpressionGrid> oEditor = definition.getEditor(parent, Optional.empty(), hasExpression, expression, hasName, 0);
    assertTrue(oEditor.isPresent());
    final GridWidget editor = oEditor.get();
    assertTrue(editor instanceof InvocationGrid);
}
Also used : Invocation(org.kie.workbench.common.dmn.api.definition.v1_1.Invocation) GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) Test(org.junit.Test)

Example 30 with Expression

use of org.kie.workbench.common.dmn.api.definition.v1_1.Expression 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)

Aggregations

Expression (org.kie.workbench.common.dmn.api.definition.v1_1.Expression)19 BaseExpressionGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid)15 Expression (org.apache.commons.jexl2.Expression)14 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)13 JexlContext (org.apache.commons.jexl2.JexlContext)12 Test (org.junit.Test)12 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)12 LiteralExpression (org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)11 HasName (org.kie.workbench.common.dmn.api.definition.HasName)10 JexlEngine (org.apache.commons.jexl2.JexlEngine)9 InformationItem (org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem)9 BaseGridCellValue (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue)9 GridWidget (org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget)9 MapContext (org.apache.commons.jexl2.MapContext)8 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)7 Expression (org.eclipse.xtext.resource.bug385636.Expression)7 Optional (java.util.Optional)6 Before (org.junit.Before)6 Decision (org.kie.workbench.common.dmn.api.definition.v1_1.Decision)6 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)6