Search in sources :

Example 1 with ExpressionGridCacheImpl

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

the class ExpressionEditorTest method setUp.

@Before
@SuppressWarnings("unchecked")
public void setUp() throws Exception {
    this.decision = new Decision();
    this.expressionGridCache = new ExpressionGridCacheImpl();
    this.definitions = new Definitions();
    this.definitions.setName(new Name(DRG_NAME));
    testedEditor = spy(new ExpressionEditor(view, decisionNavigator, dmnGraphUtils, dmnDiagramsSession, drdNameChanger));
    testedEditor.bind(dmnSession);
    when(session.getCanvasControl(eq(ExpressionGridCache.class))).thenReturn(expressionGridCache);
    when(dmnGraphUtils.getModelDefinitions()).thenReturn(definitions);
    when(dmnDiagramsSession.getCurrentDMNDiagramElement()).thenReturn(Optional.of(dmnDiagramElement));
}
Also used : Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) ExpressionGridCacheImpl(org.kie.workbench.common.dmn.client.widgets.grid.ExpressionGridCacheImpl) ExpressionGridCache(org.kie.workbench.common.dmn.client.widgets.grid.ExpressionGridCache) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) HasName(org.kie.workbench.common.dmn.api.definition.HasName) Before(org.junit.Before)

Example 2 with ExpressionGridCacheImpl

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

the class ExpressionContainerUIModelMapperTest method setup.

@SuppressWarnings("unchecked")
public void setup(final boolean isOnlyVisualChangeAllowed) {
    uiModel = new BaseGridData();
    uiModel.appendRow(new BaseGridRow());
    uiModel.appendColumn(uiExpressionColumn);
    when(uiExpressionColumn.getIndex()).thenReturn(0);
    when(uiExpressionColumn.getMinimumWidth()).thenReturn(MINIMUM_COLUMN_WIDTH);
    parent = new GridCellTuple(0, 0, expressionContainerGrid);
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add(literalExpressionEditorDefinition);
    expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
    when(expressionEditorDefinitionsSupplier.get()).thenReturn(expressionEditorDefinitions);
    when(literalExpressionEditorDefinition.getModelClass()).thenReturn(Optional.of(literalExpression));
    when(literalExpressionEditor.isCacheable()).thenReturn(true);
    when(literalExpressionEditor.getExpression()).thenReturn(() -> Optional.of(literalExpression));
    when(literalExpressionEditorDefinition.getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt())).thenReturn(Optional.of(literalExpressionEditor));
    when(undefinedExpressionEditorDefinition.getModelClass()).thenReturn(Optional.empty());
    when(undefinedExpressionEditorDefinition.getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt())).thenReturn(Optional.of(undefinedExpressionEditor));
    expressionGridCache = spy(new ExpressionGridCacheImpl());
    mapper = new ExpressionContainerUIModelMapper(parent, () -> uiModel, () -> Optional.ofNullable(expression), () -> NODE_UUID, () -> hasExpression, () -> Optional.of(hasName), () -> isOnlyVisualChangeAllowed, expressionEditorDefinitionsSupplier, () -> expressionGridCache, 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) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) Optional(java.util.Optional) ExpressionGridCacheImpl(org.kie.workbench.common.dmn.client.widgets.grid.ExpressionGridCacheImpl) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)

Example 3 with ExpressionGridCacheImpl

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

the class ExpressionContainerGridTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    this.expressionGridCache = new ExpressionGridCacheImpl();
    this.gridLayer = spy(new DMNGridLayer());
    this.grid = new ExpressionContainerGrid(gridLayer, cellEditorControls, translationService, listSelector, sessionManager, sessionCommandManager, canvasCommandFactory, expressionEditorDefinitionsSupplier, () -> expressionGridCache, onHasExpressionChanged, onHasNameChanged, refreshFormPropertiesEvent, domainObjectSelectionEvent) {

        @Override
        public CellSelectionManager getCellSelectionManager() {
            return cellSelectionManager;
        }
    };
    this.gridLayer.add(grid);
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
    expressionEditorDefinitions.add(literalExpressionEditorDefinition);
    when(expressionEditorDefinitionsSupplier.get()).thenReturn(expressionEditorDefinitions);
    when(literalExpressionEditor.isCacheable()).thenReturn(true);
    when(literalExpressionEditor.getParentInformation()).thenReturn(parent);
    when(literalExpressionEditor.getModel()).thenReturn(new BaseGridData());
    when(literalExpressionEditorDefinition.getModelClass()).thenReturn(Optional.of(literalExpression));
    when(literalExpressionEditorDefinition.getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt())).thenReturn(Optional.of(literalExpressionEditor));
    when(undefinedExpressionEditor.getParentInformation()).thenReturn(parent);
    when(undefinedExpressionEditor.getModel()).thenReturn(new BaseGridData());
    when(undefinedExpressionEditorDefinition.getModelClass()).thenReturn(Optional.empty());
    when(undefinedExpressionEditorDefinition.getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt())).thenReturn(Optional.of(undefinedExpressionEditor));
    when(sessionManager.getCurrentSession()).thenReturn(session);
    when(session.getCanvasHandler()).thenReturn(canvasHandler);
    when(canvasHandler.getGraphExecutionContext()).thenReturn(graphExecutionContext);
    doReturn(mock(Bounds.class)).when(gridLayer).getVisibleBounds();
    when(canvasHandler.getDiagram()).thenReturn(diagram);
    when(diagram.getGraph()).thenReturn(graph);
    when(graph.nodes()).thenReturn(Collections.singletonList(node));
    when(parent.getGridWidget()).thenReturn(grid);
    when(parent.getRowIndex()).thenReturn(0);
    when(parent.getColumnIndex()).thenReturn(0);
    doAnswer((i) -> i.getArguments()[0].toString()).when(translationService).format(Mockito.<String>any());
}
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) ExpressionGridCacheImpl(org.kie.workbench.common.dmn.client.widgets.grid.ExpressionGridCacheImpl) CellSelectionManager(org.uberfire.ext.wires.core.grids.client.widget.grid.selections.CellSelectionManager) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) DMNGridLayer(org.kie.workbench.common.dmn.client.widgets.layer.DMNGridLayer) Before(org.junit.Before)

Example 4 with ExpressionGridCacheImpl

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

the class ExpressionEditorViewImplTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    this.expressionGridCache = new ExpressionGridCacheImpl();
    this.gridPanelContainer = spy(new DMNGridPanelContainer());
    when(sessionManager.getCurrentSession()).thenReturn(session);
    when(session.getExpressionGridCache()).thenReturn(expressionGridCache);
    when(session.getGridPanel()).thenReturn(gridPanel);
    when(session.getGridLayer()).thenReturn(gridLayer);
    when(session.getCellEditorControls()).thenReturn(cellEditorControls);
    when(session.getMousePanMediator()).thenReturn(mousePanMediator);
    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), anyBoolean(), anyInt());
    doReturn(new BaseGridData()).when(editor).getModel();
    this.view = spy(new ExpressionEditorViewImpl(returnToLink, expressionName, expressionType, gridPanelContainer, translationService, listSelector, sessionManager, sessionCommandManager, canvasCommandFactory, expressionEditorDefinitionsSupplier, refreshFormPropertiesEvent, domainObjectSelectionEvent));
    view.init(presenter);
    view.bind(session);
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
    expressionEditorDefinitions.add(literalExpressionEditorDefinition);
    when(expressionEditorDefinitionsSupplier.get()).thenReturn(expressionEditorDefinitions);
    when(undefinedExpressionEditorDefinition.getModelClass()).thenReturn(Optional.empty());
    when(undefinedExpressionEditorDefinition.getName()).thenReturn(UNDEFINED_EXPRESSION_DEFINITION_NAME);
    when(undefinedExpressionEditor.getModel()).thenReturn(new BaseGridData());
    when(undefinedExpressionEditorDefinition.getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt())).thenReturn(Optional.of(undefinedExpressionEditor));
    when(literalExpressionEditorDefinition.getModelClass()).thenReturn(Optional.of(new LiteralExpression()));
    when(literalExpressionEditorDefinition.getName()).thenReturn(LITERAL_EXPRESSION_DEFINITION_NAME);
    when(literalExpressionEditor.getModel()).thenReturn(new BaseGridData());
    when(literalExpressionEditorDefinition.getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt())).thenReturn(Optional.of(literalExpressionEditor));
    doAnswer((i) -> i.getArguments()[1]).when(translationService).format(Mockito.<String>any(), anyObject());
    doAnswer((i) -> i.getArguments()[0]).when(translationService).getTranslation(Mockito.<String>any());
}
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) DMNGridPanelContainer(org.kie.workbench.common.dmn.client.widgets.panel.DMNGridPanelContainer) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) ExpressionGridCacheImpl(org.kie.workbench.common.dmn.client.widgets.grid.ExpressionGridCacheImpl) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Before(org.junit.Before)

Example 5 with ExpressionGridCacheImpl

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

the class UndefinedExpressionGridTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    when(sessionManager.getCurrentSession()).thenReturn(session);
    when(session.getGridPanel()).thenReturn(gridPanel);
    when(session.getGridLayer()).thenReturn(gridLayer);
    when(session.getCellEditorControls()).thenReturn(cellEditorControls);
    expressionGridCache = spy(new ExpressionGridCacheImpl());
    when(sessionManager.getCurrentSession()).thenReturn(session);
    when(session.getExpressionGridCache()).thenReturn(expressionGridCache);
    definition = new UndefinedExpressionEditorDefinition(definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, editorSelectedEvent, refreshFormPropertiesEvent, domainObjectSelectionEvent, listSelector, translationService, undefinedExpressionSelector, expressionEditorDefinitionsSupplier, readOnlyProvider);
    expression = definition.getModelClass();
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add(definition);
    expressionEditorDefinitions.add(literalExpressionEditorDefinition);
    when(expressionEditorDefinitionsSupplier.get()).thenReturn(expressionEditorDefinitions);
    when(literalExpressionEditorDefinition.getType()).thenReturn(ExpressionType.LITERAL_EXPRESSION);
    when(literalExpressionEditorDefinition.getName()).thenReturn(LiteralExpression.class.getSimpleName());
    doCallRealMethod().when(literalExpressionEditor).selectFirstCell();
    when(literalExpressionEditor.getLayer()).thenReturn(gridLayer);
    final GridData literalExpressionUiModel = new BaseGridData();
    literalExpressionUiModel.appendColumn(mock(GridColumn.class));
    literalExpressionUiModel.appendRow(mock(GridRow.class));
    when(literalExpressionEditor.getModel()).thenReturn(literalExpressionUiModel);
    when(literalExpressionEditorDefinition.getModelClass()).thenReturn(Optional.of(literalExpression));
    when(literalExpressionEditorDefinition.getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt())).thenReturn(Optional.of(literalExpressionEditor));
    when(session.getCanvasHandler()).thenReturn(canvasHandler);
    when(canvasHandler.getDiagram()).thenReturn(diagram);
    when(diagram.getGraph()).thenReturn(graph);
    when(graph.nodes()).thenReturn(Collections.singletonList(node));
    when(parentGridWidget.getModel()).thenReturn(parentGridUiModel);
    setupParent();
}
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.model.LiteralExpression) ExpressionGridCacheImpl(org.kie.workbench.common.dmn.client.widgets.grid.ExpressionGridCacheImpl) 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) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow) Before(org.junit.Before)

Aggregations

ExpressionGridCacheImpl (org.kie.workbench.common.dmn.client.widgets.grid.ExpressionGridCacheImpl)5 Optional (java.util.Optional)4 Before (org.junit.Before)4 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)4 ExpressionEditorDefinitions (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions)4 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)4 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)4 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)2 HasName (org.kie.workbench.common.dmn.api.definition.HasName)1 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)1 Definitions (org.kie.workbench.common.dmn.api.definition.model.Definitions)1 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)1 ExpressionGridCache (org.kie.workbench.common.dmn.client.widgets.grid.ExpressionGridCache)1 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)1 DMNGridLayer (org.kie.workbench.common.dmn.client.widgets.layer.DMNGridLayer)1 DMNGridPanelContainer (org.kie.workbench.common.dmn.client.widgets.panel.DMNGridPanelContainer)1 Bounds (org.uberfire.ext.wires.core.grids.client.model.Bounds)1 GridColumn (org.uberfire.ext.wires.core.grids.client.model.GridColumn)1 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)1 GridRow (org.uberfire.ext.wires.core.grids.client.model.GridRow)1