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