Search in sources :

Example 11 with ExpressionEditorDefinitions

use of org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions in project kie-wb-common by kiegroup.

the class ContextEditorDefinitionTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    this.definition = new ContextEditorDefinition(gridPanel, gridLayer, definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, cellEditorControls, listSelector, translationService, expressionEditorDefinitionsSupplier);
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add((ExpressionEditorDefinition) definition);
    doReturn(expressionEditorDefinitions).when(expressionEditorDefinitionsSupplier).get();
    doAnswer((i) -> i.getArguments()[0].toString()).when(translationService).format(anyString());
}
Also used : ExpressionEditorDefinitions(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions) Before(org.junit.Before)

Example 12 with ExpressionEditorDefinitions

use of org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions in project kie-wb-common by kiegroup.

the class FunctionEditorDefinitionTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    this.definition = new FunctionEditorDefinition(gridPanel, gridLayer, definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, cellEditorControls, listSelector, translationService, expressionEditorDefinitionsSupplier, supplementaryEditorDefinitionsSupplier, parametersEditor);
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add((ExpressionEditorDefinition) definition);
    doReturn(expressionEditorDefinitions).when(expressionEditorDefinitionsSupplier).get();
    doReturn(expressionEditorDefinitions).when(supplementaryEditorDefinitionsSupplier).get();
    doAnswer((i) -> i.getArguments()[0].toString()).when(translationService).format(anyString());
}
Also used : ExpressionEditorDefinitions(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions) Before(org.junit.Before)

Example 13 with ExpressionEditorDefinitions

use of org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions in project kie-wb-common by kiegroup.

the class FunctionGridTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    tupleWithoutValue = new GridCellTuple(0, 0, gridWidget);
    tupleWithValue = new GridCellValueTuple<>(0, 0, gridWidget, new BaseGridCellValue<>("value"));
    definition = new FunctionEditorDefinition(gridPanel, gridLayer, definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, cellEditorControls, listSelector, translationService, expressionEditorDefinitionsSupplier, supplementaryEditorDefinitionsSupplier, parametersEditor);
    expression = definition.getModelClass();
    expression.get().getFormalParameter().add(parameter);
    parameter.getName().setValue(PARAMETER_NAME);
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add((ExpressionEditorDefinition) definition);
    expressionEditorDefinitions.add(literalExpressionEditorDefinition);
    expressionEditorDefinitions.add(supplementaryLiteralExpressionEditorDefinition);
    final Decision decision = new Decision();
    decision.setName(new Name("name"));
    hasName = Optional.of(decision);
    doReturn(expressionEditorDefinitions).when(expressionEditorDefinitionsSupplier).get();
    doReturn(expressionEditorDefinitions).when(supplementaryEditorDefinitionsSupplier).get();
    doReturn(ExpressionType.LITERAL_EXPRESSION).when(literalExpressionEditorDefinition).getType();
    doReturn(Optional.of(literalExpression)).when(literalExpressionEditorDefinition).getModelClass();
    doReturn(Optional.of(literalExpressionEditor)).when(literalExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
    doReturn(Optional.of(supplementaryLiteralExpression)).when(supplementaryLiteralExpressionEditorDefinition).getModelClass();
    doReturn(Optional.of(supplementaryLiteralExpressionEditor)).when(supplementaryLiteralExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
    final GridData uiLiteralExpressionModel = new BaseGridData();
    doReturn(uiLiteralExpressionModel).when(literalExpressionEditor).getModel();
    doReturn(session).when(sessionManager).getCurrentSession();
    doReturn(canvasHandler).when(session).getCanvasHandler();
    when(gridWidget.getModel()).thenReturn(new BaseGridData(false));
    when(canvasHandler.getGraphIndex()).thenReturn(index);
    when(index.get(anyString())).thenReturn(element);
    when(element.getContent()).thenReturn(mock(Definition.class));
    when(definitionUtils.getNameIdentifier(any())).thenReturn("name");
    when(canvasCommandFactory.updatePropertyValue(any(Element.class), anyString(), any())).thenReturn(mock(UpdateElementPropertyCommand.class));
    doAnswer((i) -> i.getArguments()[0].toString()).when(translationService).format(anyString());
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Optional(java.util.Optional) Element(org.kie.workbench.common.stunner.core.graph.Element) ExpressionEditorDefinition(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition) FunctionDefinition(org.kie.workbench.common.dmn.api.definition.v1_1.FunctionDefinition) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) Decision(org.kie.workbench.common.dmn.api.definition.v1_1.Decision) UpdateElementPropertyCommand(org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPropertyCommand) HasName(org.kie.workbench.common.dmn.api.definition.HasName) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) ExpressionEditorDefinitions(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue) Before(org.junit.Before)

Example 14 with ExpressionEditorDefinitions

use of org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions 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 ExpressionEditorDefinitions

use of org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions in project kie-wb-common by kiegroup.

the class BaseFunctionSupplementaryGridTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    definition = getEditorDefinition();
    expression = definition.getModelClass();
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add((ExpressionEditorDefinition) definition);
    expressionEditorDefinitions.add(literalExpressionEditorDefinition);
    doReturn(expressionEditorDefinitions).when(expressionEditorDefinitionsSupplier).get();
    doReturn(Optional.of(literalExpression)).when(literalExpressionEditorDefinition).getModelClass();
    doReturn(Optional.of(literalExpressionEditor)).when(literalExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
}
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) Optional(java.util.Optional) Before(org.junit.Before)

Aggregations

ExpressionEditorDefinitions (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions)19 Before (org.junit.Before)18 Optional (java.util.Optional)12 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)12 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)12 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)10 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)5 DMNGridRow (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow)5 LiteralExpression (org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)4 InformationItem (org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem)3 ExpressionEditorDefinition (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition)3 UpdateElementPropertyCommand (org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPropertyCommand)3 Element (org.kie.workbench.common.stunner.core.graph.Element)3 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)3 BaseGridCellValue (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue)3 HasName (org.kie.workbench.common.dmn.api.definition.HasName)2 Context (org.kie.workbench.common.dmn.api.definition.v1_1.Context)2 ContextEntry (org.kie.workbench.common.dmn.api.definition.v1_1.ContextEntry)2 Decision (org.kie.workbench.common.dmn.api.definition.v1_1.Decision)2 FunctionDefinition (org.kie.workbench.common.dmn.api.definition.v1_1.FunctionDefinition)2