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));
}
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);
}
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());
}
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());
}
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();
}
Aggregations