Search in sources :

Example 16 with ExpressionEditorDefinitions

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

the class InvocationEditorDefinitionTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    this.definition = new InvocationEditorDefinition(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 17 with ExpressionEditorDefinitions

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

the class InvocationGridTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    tupleWithoutValue = new GridCellTuple(0, 1, gridWidget);
    tupleWithValue = new GridCellValueTuple<>(0, 1, gridWidget, new BaseGridCellValue<>("value"));
    definition = new InvocationEditorDefinition(gridPanel, gridLayer, definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, cellEditorControls, listSelector, translationService, expressionEditorDefinitionsSupplier);
    expression = definition.getModelClass();
    expression.ifPresent(invocation -> ((LiteralExpression) invocation.getExpression()).setText("invocation-expression"));
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add((ExpressionEditorDefinition) definition);
    expressionEditorDefinitions.add(literalExpressionEditorDefinition);
    expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
    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());
    doReturn(parent).when(undefinedExpressionEditor).getParentInformation();
    doReturn(Optional.empty()).when(undefinedExpressionEditorDefinition).getModelClass();
    doReturn(Optional.of(undefinedExpressionEditor)).when(undefinedExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
    doReturn(session).when(sessionManager).getCurrentSession();
    doReturn(canvasHandler).when(session).getCanvasHandler();
    doReturn(graphContext).when(canvasHandler).getGraphExecutionContext();
    final Decision decision = new Decision();
    decision.setName(new Name("name"));
    hasName = Optional.of(decision);
    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) UndefinedExpressionEditorDefinition(org.kie.workbench.common.dmn.client.editors.expressions.types.undefined.UndefinedExpressionEditorDefinition) 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) 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 18 with ExpressionEditorDefinitions

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

the class ExpressionContainerGridTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    this.grid = new ExpressionContainerGrid(gridPanel, gridLayer, cellEditorControls, translationService, listSelector, sessionManager, sessionCommandManager, expressionEditorDefinitionsSupplier, onHasNameChanged);
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
    expressionEditorDefinitions.add(literalExpressionEditorDefinition);
    doReturn(expressionEditorDefinitions).when(expressionEditorDefinitionsSupplier).get();
    doReturn(parent).when(literalExpressionEditor).getParentInformation();
    doReturn(new BaseGridData()).when(literalExpressionEditor).getModel();
    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(parent).when(undefinedExpressionEditor).getParentInformation();
    doReturn(new BaseGridData()).when(undefinedExpressionEditor).getModel();
    doReturn(Optional.empty()).when(undefinedExpressionEditorDefinition).getModelClass();
    doReturn(Optional.of(undefinedExpressionEditor)).when(undefinedExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
    doReturn(session).when(sessionManager).getCurrentSession();
    doReturn(canvasHandler).when(session).getCanvasHandler();
    doReturn(graphExecutionContext).when(canvasHandler).getGraphExecutionContext();
    doReturn(mock(Bounds.class)).when(gridLayer).getVisibleBounds();
    doAnswer((i) -> i.getArguments()[0].toString()).when(translationService).format(anyString());
}
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) Bounds(org.uberfire.ext.wires.core.grids.client.model.Bounds) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Before(org.junit.Before)

Example 19 with ExpressionEditorDefinitions

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

the class ExpressionEditorViewImplTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    doReturn(viewport).when(gridPanel).getViewport();
    doReturn(viewportMediators).when(viewport).getMediators();
    doReturn(gridPanelElement).when(gridPanel).getElement();
    doReturn(Optional.of(editor)).when(editorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
    doReturn(new BaseGridData()).when(editor).getModel();
    this.view = spy(new ExpressionEditorViewImpl(returnToDRG, gridPanel, gridLayer, mousePanMediator, cellEditorControls, translationService, listSelector, sessionManager, sessionCommandManager, expressionEditorDefinitionsSupplier));
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
    doReturn(expressionEditorDefinitions).when(expressionEditorDefinitionsSupplier).get();
    doReturn(Optional.empty()).when(undefinedExpressionEditorDefinition).getModelClass();
    doReturn(new BaseGridData()).when(undefinedExpressionEditor).getModel();
    doReturn(Optional.of(undefinedExpressionEditor)).when(undefinedExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
    doAnswer((i) -> i.getArguments()[1]).when(translationService).format(anyString(), anyObject());
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) ExpressionEditorDefinitions(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) Optional(java.util.Optional) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) 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