Search in sources :

Example 1 with DMNGridPanelContainer

use of org.kie.workbench.common.dmn.client.widgets.panel.DMNGridPanelContainer 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)

Aggregations

Optional (java.util.Optional)1 Before (org.junit.Before)1 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)1 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)1 ExpressionEditorDefinitions (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions)1 ExpressionGridCacheImpl (org.kie.workbench.common.dmn.client.widgets.grid.ExpressionGridCacheImpl)1 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)1 DMNGridPanelContainer (org.kie.workbench.common.dmn.client.widgets.panel.DMNGridPanelContainer)1 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)1