use of org.kie.workbench.common.dmn.client.editors.expressions.types.literal.LiteralExpressionEditorDefinition in project kie-wb-common by kiegroup.
the class FunctionGridTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() {
when(parent.getGridWidget()).thenReturn(parentGridWidget);
when(parentGridWidget.getModel()).thenReturn(parentGridData);
when(parentGridData.getColumns()).thenReturn(Collections.singletonList(parentGridColumn));
when(sessionManager.getCurrentSession()).thenReturn(session);
when(session.getGridPanel()).thenReturn(gridPanel);
when(session.getGridLayer()).thenReturn(gridLayer);
when(session.getCellEditorControls()).thenReturn(cellEditorControls);
definition = new FunctionEditorDefinition(definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, editorSelectedEvent, refreshFormPropertiesEvent, domainObjectSelectionEvent, listSelector, translationService, expressionEditorDefinitionsSupplier, supplementaryEditorDefinitionsSupplier, headerEditor, parametersEditor, kindEditor, readOnlyProvider);
literalExpressionEditorDefinition = spy(new LiteralExpressionEditorDefinition(definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, editorSelectedEvent, refreshFormPropertiesEvent, domainObjectSelectionEvent, listSelector, translationService, headerEditor, readOnlyProvider));
expression = definition.getModelClass();
definition.enrich(Optional.empty(), hasExpression, expression);
expression.get().getFormalParameter().add(parameter);
parameter.getName().setValue(PARAMETER_NAME);
final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
expressionEditorDefinitions.add((ExpressionEditorDefinition) definition);
expressionEditorDefinitions.add((ExpressionEditorDefinition) literalExpressionEditorDefinition);
expressionEditorDefinitions.add(supplementaryExpressionEditorDefinition);
final Decision decision = new Decision();
decision.setName(new Name("name"));
hasName = Optional.of(decision);
when(expressionEditorDefinitionsSupplier.get()).thenReturn(expressionEditorDefinitions);
when(supplementaryEditorDefinitionsSupplier.get()).thenReturn(expressionEditorDefinitions);
// Setup LiteralExpression definition and editor
doReturn(Optional.of(literalExpressionEditor)).when(literalExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt());
when(literalExpressionEditor.getGridPanel()).thenReturn(gridPanel);
when(literalExpressionEditor.getLayer()).thenReturn(gridLayer);
when(literalExpressionEditor.getModel()).thenReturn(new BaseGridData(false));
doCallRealMethod().when(literalExpressionEditor).resize(any(Function.class));
doCallRealMethod().when(literalExpressionEditor).doResize(any(PrioritizedCommand.class), any(Function.class));
doCallRealMethod().when(literalExpressionEditor).selectFirstCell();
when(literalExpressionEditor.getParentInformation()).thenReturn(parent);
// Setup Supplementary expression definition and editor
when(supplementaryExpressionEditorDefinition.getModelClass()).thenReturn(Optional.of(supplementaryExpression));
when(supplementaryExpressionEditorDefinition.getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt())).thenReturn(Optional.of(supplementaryExpressionEditor));
when(supplementaryExpressionEditor.getGridPanel()).thenReturn(gridPanel);
when(supplementaryExpressionEditor.getLayer()).thenReturn(gridLayer);
when(supplementaryExpressionEditor.getModel()).thenReturn(new BaseGridData(false));
doCallRealMethod().when(supplementaryExpressionEditor).resize(any(Function.class));
doCallRealMethod().when(supplementaryExpressionEditor).doResize(any(PrioritizedCommand.class), any(Function.class));
doCallRealMethod().when(supplementaryExpressionEditor).selectFirstCell();
when(supplementaryExpressionEditor.getParentInformation()).thenReturn(parent);
when(session.getCanvasHandler()).thenReturn(canvasHandler);
when(gridWidget.getModel()).thenReturn(new BaseGridData(false));
when(canvasHandler.getDiagram()).thenReturn(diagram);
when(diagram.getGraph()).thenReturn(graph);
when(graph.nodes()).thenReturn(Collections.singletonList(node));
when(canvasHandler.getGraphIndex()).thenReturn(index);
when(index.get(Mockito.<String>any())).thenReturn(element);
when(element.getContent()).thenReturn(mock(Definition.class));
when(definitionUtils.getNameIdentifier(any())).thenReturn("name");
when(canvasCommandFactory.updatePropertyValue(any(Element.class), Mockito.<String>any(), any())).thenReturn(mock(UpdateElementPropertyCommand.class));
when(canvasHandler.getGraphExecutionContext()).thenReturn(graphCommandExecutionContext);
doAnswer((i) -> i.getArguments()[0].toString()).when(translationService).format(Mockito.<String>any());
doAnswer((i) -> i.getArguments()[0].toString()).when(translationService).getTranslation(Mockito.<String>any());
}
Aggregations