Search in sources :

Example 31 with GridCellTuple

use of org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple in project kie-wb-common by kiegroup.

the class FunctionUIModelMapperTest method assertFromDMNModelEditor.

@SuppressWarnings("unchecked")
private void assertFromDMNModelEditor(final BaseExpressionGrid editor, final ExpressionEditorDefinition definition) {
    assertTrue(uiModel.getCell(0, 0).getValue() instanceof ExpressionCellValue);
    final ExpressionCellValue dcv = (ExpressionCellValue) uiModel.getCell(0, 0).getValue();
    assertEquals(editor, dcv.getValue().get());
    verify(definition).getEditor(parentCaptor.capture(), eq(Optional.empty()), eq(function), eq(Optional.ofNullable(function.getExpression())), eq(Optional.empty()), eq(1));
    final GridCellTuple parent = parentCaptor.getValue();
    assertEquals(0, parent.getRowIndex());
    assertEquals(0, parent.getColumnIndex());
    assertEquals(gridWidget, parent.getGridWidget());
}
Also used : GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)

Example 32 with GridCellTuple

use of org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple 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 33 with GridCellTuple

use of org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple in project kie-wb-common by kiegroup.

the class InvocationUIModelMapperTest method testFromDMNModelBindingExpression.

@Test
@SuppressWarnings("unchecked")
public void testFromDMNModelBindingExpression() {
    mapper.fromDMNModel(0, 2);
    assertNotNull(uiModel.getCell(0, 2));
    assertTrue(uiModel.getCell(0, 2).getValue() instanceof ExpressionCellValue);
    final ExpressionCellValue dcv = (ExpressionCellValue) uiModel.getCell(0, 2).getValue();
    assertEquals(literalExpressionEditor, dcv.getValue().get());
    verify(literalExpressionEditorDefinition).getEditor(parentCaptor.capture(), eq(Optional.empty()), eq(invocation.getBinding().get(0)), eq(Optional.of(invocation.getBinding().get(0).getExpression())), eq(Optional.of(invocation.getBinding().get(0).getParameter())), eq(1));
    final GridCellTuple parent = parentCaptor.getValue();
    assertEquals(0, parent.getRowIndex());
    assertEquals(2, parent.getColumnIndex());
    assertEquals(gridWidget, parent.getGridWidget());
}
Also used : GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) Test(org.junit.Test)

Example 34 with GridCellTuple

use of org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple in project kie-wb-common by kiegroup.

the class LiteralExpressionGridTest method setup.

@Before
public void setup() {
    tupleWithoutValue = new GridCellTuple(0, 0, gridWidget);
    tupleWithValue = new GridCellValueTuple<>(0, 0, gridWidget, new BaseGridCellValue<>("value"));
    definition = new LiteralExpressionEditorDefinition(gridPanel, gridLayer, definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, cellEditorControls, listSelector, translationService);
    final Decision decision = new Decision();
    decision.setName(new Name("name"));
    hasName = Optional.of(decision);
    expression = definition.getModelClass();
    expression.ifPresent(e -> e.setText(EXPRESSION_TEXT));
    doReturn(session).when(sessionManager).getCurrentSession();
    doReturn(canvasHandler).when(session).getCanvasHandler();
    doReturn(mock(Bounds.class)).when(gridLayer).getVisibleBounds();
    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));
    when(parentGridWidget.getModel()).thenReturn(parentGridUiModel);
    when(parent.getGridWidget()).thenReturn(parentGridWidget);
    when(parent.getRowIndex()).thenReturn(0);
    when(parent.getColumnIndex()).thenReturn(1);
}
Also used : GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) Bounds(org.uberfire.ext.wires.core.grids.client.model.Bounds) Element(org.kie.workbench.common.stunner.core.graph.Element) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Decision(org.kie.workbench.common.dmn.api.definition.v1_1.Decision) UpdateElementPropertyCommand(org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPropertyCommand) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue) HasName(org.kie.workbench.common.dmn.api.definition.HasName) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Before(org.junit.Before)

Example 35 with GridCellTuple

use of org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple in project kie-wb-common by kiegroup.

the class LiteralExpressionUIModelMapperTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    uiModel = new BaseGridData();
    uiModel.appendRow(new DMNGridRow());
    uiModel.appendColumn(uiLiteralExpressionColumn);
    doReturn(0).when(uiLiteralExpressionColumn).getIndex();
    when(parentGridWidget.getModel()).thenReturn(parentGridUiModel);
    when(parentGridUiModel.getCell(eq(PARENT_ROW_INDEX), eq(PARENT_COLUMN_INDEX))).thenReturn(parentGridUiCell);
    when(parentGridUiCell.getSelectionStrategy()).thenReturn(parentGridUiCellCellSelectionStrategy);
    literalExpression = new LiteralExpression();
    mapper = new LiteralExpressionUIModelMapper(() -> uiModel, () -> Optional.of(literalExpression), listSelector, new GridCellTuple(PARENT_ROW_INDEX, PARENT_COLUMN_INDEX, parentGridWidget));
}
Also used : GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Before(org.junit.Before)

Aggregations

GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)39 Test (org.junit.Test)19 Before (org.junit.Before)11 GridCellValueTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellValueTuple)10 BaseGridCellValue (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue)10 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)9 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)9 ExpressionCellValue (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)8 BaseExpressionGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid)8 TextBoxSingletonDOMElementFactory (org.kie.workbench.common.dmn.client.widgets.grid.columns.factory.TextBoxSingletonDOMElementFactory)8 Optional (java.util.Optional)6 HasName (org.kie.workbench.common.dmn.api.definition.HasName)6 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)6 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)6 ExpressionEditorDefinition (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition)5 DMNGridRow (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow)5 Decision (org.kie.workbench.common.dmn.api.definition.v1_1.Decision)4 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)4 ExpressionEditorDefinitions (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions)4 GridWidget (org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget)4