Search in sources :

Example 6 with ExpressionEditorDefinitions

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

the class ExpressionContainerUIModelMapperTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    uiModel = new BaseGridData();
    uiModel.appendRow(new DMNGridRow());
    uiModel.appendColumn(uiExpressionColumn);
    doReturn(0).when(uiExpressionColumn).getIndex();
    doReturn(MINIMUM_COLUMN_WIDTH).when(uiExpressionColumn).getMinimumWidth();
    parent = new GridCellTuple(0, 0, expressionContainerGrid);
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add(literalExpressionEditorDefinition);
    expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
    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());
    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());
    mapper = new ExpressionContainerUIModelMapper(parent, () -> uiModel, () -> Optional.ofNullable(expression), () -> NODE_UUID, () -> hasExpression, () -> Optional.of(hasName), expressionEditorDefinitionsSupplier, listSelector);
}
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) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Before(org.junit.Before)

Example 7 with ExpressionEditorDefinitions

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

the class UndefinedExpressionColumnTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    this.column = spy(new UndefinedExpressionColumn(headerMetaData, gridWidget, cellEditorControls, expressionEditorDefinitionsSupplier));
    doReturn(parent).when(gridWidget).getParentInformation();
    doReturn(parentGridWidget).when(parent).getGridWidget();
    doReturn(parentGridData).when(parentGridWidget).getModel();
    doReturn(Collections.singletonList(parentGridColumn)).when(parentGridData).getColumns();
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add(literalExpressionEditorDefinition);
    doReturn(ExpressionType.LITERAL_EXPRESSION).when(literalExpressionEditorDefinition).getType();
    doReturn(LiteralExpression.class.getSimpleName()).when(literalExpressionEditorDefinition).getName();
    doReturn(Optional.of(literalExpression)).when(literalExpressionEditorDefinition).getModelClass();
    doReturn(expressionEditorDefinitions).when(expressionEditorDefinitionsSupplier).get();
    when(context.getRowIndex()).thenReturn(ROW_INDEX);
    when(context.getColumnIndex()).thenReturn(COLUMN_INDEX);
    when(context.getRelativeLocation()).thenReturn(Optional.of(relativeLocation));
    when(context.getAbsoluteCellX()).thenReturn(ABSOLUTE_CELL_X);
    when(context.getAbsoluteCellY()).thenReturn(ABSOLUTE_CELL_Y);
}
Also used : ExpressionEditorDefinitions(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) Before(org.junit.Before)

Example 8 with ExpressionEditorDefinitions

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

the class UndefinedExpressionGridTest method testGetItemsEmpty.

@Test
public void testGetItemsEmpty() {
    setupGrid(0);
    reset(expressionEditorDefinitionsSupplier);
    doReturn(new ExpressionEditorDefinitions()).when(expressionEditorDefinitionsSupplier).get();
    final List<HasListSelectorControl.ListSelectorItem> items = grid.getItems(0, 0);
    assertThat(items.size()).isEqualTo(0);
}
Also used : ExpressionEditorDefinitions(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions) Test(org.junit.Test)

Example 9 with ExpressionEditorDefinitions

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

the class UndefinedExpressionGridTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    definition = new UndefinedExpressionEditorDefinition(gridPanel, gridLayer, definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, cellEditorControls, listSelector, translationService, expressionEditorDefinitionsSupplier);
    expression = definition.getModelClass();
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add(definition);
    expressionEditorDefinitions.add(literalExpressionEditorDefinition);
    doReturn(expressionEditorDefinitions).when(expressionEditorDefinitionsSupplier).get();
    doReturn(ExpressionType.LITERAL_EXPRESSION).when(literalExpressionEditorDefinition).getType();
    doReturn(LiteralExpression.class.getSimpleName()).when(literalExpressionEditorDefinition).getName();
    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(0).when(parent).getRowIndex();
    doReturn(0).when(parent).getColumnIndex();
    doReturn(parentGridWidget).when(parent).getGridWidget();
    doReturn(mock(GridData.class)).when(parentGridWidget).getModel();
    doReturn(session).when(sessionManager).getCurrentSession();
    doReturn(handler).when(session).getCanvasHandler();
    when(parentGridWidget.getModel()).thenReturn(parentGridUiModel);
    when(parent.getGridWidget()).thenReturn(parentGridWidget);
    when(parent.getRowIndex()).thenReturn(0);
    when(parent.getColumnIndex()).thenReturn(1);
}
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) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) Before(org.junit.Before)

Example 10 with ExpressionEditorDefinitions

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

the class BaseContextUIModelMapperTest 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();
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add(literalExpressionEditorDefinition);
    expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
    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());
    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());
    this.context = new Context();
    this.context.getContextEntry().add(new ContextEntry() {

        {
            setVariable(new InformationItem() {

                {
                    setName(new Name("ii1"));
                }
            });
        }
    });
    this.context.getContextEntry().add(new ContextEntry() {

        {
            setExpression(new LiteralExpression());
        }
    });
    this.mapper = getMapper();
    this.cellValueSupplier = Optional::empty;
}
Also used : Context(org.kie.workbench.common.dmn.api.definition.v1_1.Context) 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) 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) ContextEntry(org.kie.workbench.common.dmn.api.definition.v1_1.ContextEntry) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) 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