Search in sources :

Example 11 with FunctionDefinition

use of org.kie.workbench.common.dmn.api.definition.v1_1.FunctionDefinition 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 12 with FunctionDefinition

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

Example 13 with FunctionDefinition

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

the class SetKindCommandTest method setup.

@Before
public void setup() {
    this.function = new FunctionDefinition();
    this.function.getAdditionalAttributes().put(FunctionDefinition.KIND_QNAME, originalKind.code());
    this.function.setExpression(originalExpression);
    this.uiModel = new BaseGridData();
    this.uiModel.appendColumn(mockColumn);
    this.uiModel.appendRow(new BaseGridRow());
    this.uiModel.setCellValue(0, 0, new ExpressionCellValue(Optional.of(originalEditor)));
    doReturn(uiModel).when(gridWidget).getModel();
    doReturn(ruleManager).when(handler).getRuleManager();
}
Also used : BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) FunctionDefinition(org.kie.workbench.common.dmn.api.definition.v1_1.FunctionDefinition) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Before(org.junit.Before)

Example 14 with FunctionDefinition

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

the class FunctionUIModelMapperTest 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(uiExpressionEditorColumn);
    doReturn(0).when(uiExpressionEditorColumn).getIndex();
    doReturn(uiModel).when(gridWidget).getModel();
    // Core Editor definitions
    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());
    // Supplementary Editor definitions
    final ExpressionEditorDefinitions supplementaryEditorDefinitions = new ExpressionEditorDefinitions();
    supplementaryEditorDefinitions.add(supplementaryEditorDefinition);
    doReturn(supplementaryEditorDefinitions).when(supplementaryEditorDefinitionsSupplier).get();
    doReturn(Optional.of(context)).when(supplementaryEditorDefinition).getModelClass();
    doReturn(Optional.of(context)).when(supplementaryEditor).getExpression();
    doReturn(Optional.of(supplementaryEditor)).when(supplementaryEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
    this.function = new FunctionDefinition();
    this.mapper = new FunctionUIModelMapper(gridWidget, () -> uiModel, () -> Optional.of(function), expressionEditorDefinitionsSupplier, supplementaryEditorDefinitionsSupplier, 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) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) Optional(java.util.Optional) FunctionDefinition(org.kie.workbench.common.dmn.api.definition.v1_1.FunctionDefinition) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Before(org.junit.Before)

Example 15 with FunctionDefinition

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

the class FunctionEditorDefinition method getModelClass.

@Override
public Optional<FunctionDefinition> getModelClass() {
    final FunctionDefinition function = new FunctionDefinition();
    KindUtilities.setKind(function, FunctionDefinition.Kind.FEEL);
    function.setExpression(new LiteralExpression());
    return Optional.of(function);
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) FunctionDefinition(org.kie.workbench.common.dmn.api.definition.v1_1.FunctionDefinition)

Aggregations

FunctionDefinition (org.kie.workbench.common.dmn.api.definition.v1_1.FunctionDefinition)13 Before (org.junit.Before)7 InformationItem (org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem)5 FunctionDefinition (org.kie.dmn.model.v1_1.FunctionDefinition)4 Optional (java.util.Optional)3 Test (org.junit.Test)3 Expression (org.kie.workbench.common.dmn.api.definition.v1_1.Expression)3 BaseExpressionGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid)3 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 List (java.util.List)2 DMNContext (org.kie.dmn.api.core.DMNContext)2 DMNMessage (org.kie.dmn.api.core.DMNMessage)2 EvaluatorResult (org.kie.dmn.core.api.EvaluatorResult)2 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.v1_1.BusinessKnowledgeModel)2 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)2 ExpressionCellValue (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)2 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)2 ViewImpl (org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl)2 IOException (java.io.IOException)1