use of org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple in project kie-wb-common by kiegroup.
the class LiteralExpressionPMMLDocumentModelGridTest method setup.
@Before
public void setup() {
final GridCellTuple grandParentInformation = new GridCellTuple(0, 0, grandParentFunctionGridWidget);
when(parentGridWidget.getExpressionValueEditor(LiteralExpressionPMMLDocument.VARIABLE_DOCUMENT)).thenReturn(Optional.of(pmmlValueEditor));
when(parentGridWidget.getExpressionValue(LiteralExpressionPMMLDocument.VARIABLE_DOCUMENT)).thenReturn(DOCUMENT_NAME);
when(parentGridWidget.getParentInformation()).thenReturn(grandParentInformation);
when(grandParentFunctionGridWidget.getExpression()).thenReturn(() -> Optional.of(grandParentExpression));
when(grandParentExpression.getFormalParameter()).thenCallRealMethod();
when(canvasHandler.getGraphExecutionContext()).thenReturn(graphCommandExecutionContext);
super.setup();
}
use of org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple in project kie-wb-common by kiegroup.
the class FunctionUIModelMapperTest method assertFromDMNModelEditor.
@SuppressWarnings("unchecked")
private void assertFromDMNModelEditor(final BaseExpressionGrid editor, final ExpressionEditorDefinition definition, final boolean isOnlyVisualChangeAllowedSupplier) {
assertTrue(uiModel.getCell(0, 0).getValue() instanceof ExpressionCellValue);
final ExpressionCellValue dcv = (ExpressionCellValue) uiModel.getCell(0, 0).getValue();
assertEquals(editor, dcv.getValue().get());
verify(definition).getEditor(parentCaptor.capture(), eq(Optional.empty()), eq(function), eq(Optional.empty()), eq(isOnlyVisualChangeAllowedSupplier), eq(1));
final GridCellTuple parent = parentCaptor.getValue();
assertEquals(0, parent.getRowIndex());
assertEquals(0, parent.getColumnIndex());
assertEquals(gridWidget, parent.getGridWidget());
}
use of org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple in project kie-wb-common by kiegroup.
the class InvocationUIModelMapperTest method assertFromDMNModelBindingExpression.
private void assertFromDMNModelBindingExpression(final boolean isOnlyVisualChangeAllowed) {
mapper.fromDMNModel(0, 2);
assertNotNull(uiModel.getCell(0, 2));
assertTrue(uiModel.getCell(0, 2).getValue() instanceof ExpressionCellValue);
final ExpressionCellValue dcv = (ExpressionCellValue) uiModel.getCell(0, 2).getValue();
assertEquals(literalExpressionEditor, dcv.getValue().get());
verify(literalExpressionEditorDefinition).getEditor(parentCaptor.capture(), eq(Optional.empty()), eq(invocation.getBinding().get(0)), eq(Optional.of(invocation.getBinding().get(0).getParameter())), eq(isOnlyVisualChangeAllowed), eq(1));
final GridCellTuple parent = parentCaptor.getValue();
assertEquals(0, parent.getRowIndex());
assertEquals(2, parent.getColumnIndex());
assertEquals(gridWidget, parent.getGridWidget());
}
use of org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple in project kie-wb-common by kiegroup.
the class InvocationGridTest 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);
tupleWithoutValue = new GridCellTuple(0, 1, gridWidget);
tupleWithValue = new GridCellValueTuple<>(0, 1, gridWidget, new BaseGridCellValue<>("value"));
definition = new InvocationEditorDefinition(definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, editorSelectedEvent, refreshFormPropertiesEvent, domainObjectSelectionEvent, listSelector, translationService, expressionEditorDefinitionsSupplier, headerEditor, readOnlyProvider);
expression = definition.getModelClass();
definition.enrich(Optional.empty(), hasExpression, expression);
expression.ifPresent(invocation -> ((LiteralExpression) invocation.getExpression()).getText().setValue("invocation-expression"));
final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
expressionEditorDefinitions.add((ExpressionEditorDefinition) definition);
expressionEditorDefinitions.add(literalExpressionEditorDefinition);
expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
when(expressionEditorDefinitionsSupplier.get()).thenReturn(expressionEditorDefinitions);
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(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(graphContext);
final Decision decision = new Decision();
decision.setName(new Name("name"));
hasName = Optional.of(decision);
when(gridWidget.getModel()).thenReturn(new BaseGridData(false));
when(gridLayer.getDomElementContainer()).thenReturn(gridLayerDomElementContainer);
when(gridLayerDomElementContainer.iterator()).thenReturn(mock(Iterator.class));
when(gridLayer.getVisibleBounds()).thenReturn(new BaseBounds(0, 0, 100, 200));
when(gridLayer.getViewport()).thenReturn(viewport);
when(viewport.getTransform()).thenReturn(transform);
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));
doAnswer((i) -> i.getArguments()[0].toString()).when(translationService).format(Mockito.<String>any());
doAnswer((i) -> i.getArguments()[0].toString()).when(translationService).getTranslation(Mockito.<String>any());
}
use of org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple in project kie-wb-common by kiegroup.
the class BaseExpressionGridGeneralTest method setup.
@Override
public void setup() {
super.setup();
tupleWithoutValue = new GridCellTuple(0, 0, grid);
tupleWithValue = new GridCellValueTuple<>(0, 0, grid, new BaseGridCellValue<>("value"));
when(sessionManager.getCurrentSession()).thenReturn(session);
when(session.getCanvasHandler()).thenReturn(canvasHandler);
when(canvasHandler.getDiagram()).thenReturn(diagram);
when(diagram.getGraph()).thenReturn(graph);
when(graph.nodes()).thenReturn(Collections.singletonList(node));
when(canvasHandler.getGraphIndex()).thenReturn(index);
when(element.getContent()).thenReturn(definition);
when(definition.getDefinition()).thenReturn(DEFINITION);
when(definitionUtils.getNameIdentifier(DEFINITION)).thenReturn(NAME_ID);
when(updateElementPropertyCommand.execute(canvasHandler)).thenReturn(CanvasCommandResultBuilder.SUCCESS);
when(grid.getHeader()).thenReturn(header);
when(header.getY()).thenReturn(0.0);
when(renderer.getHeaderHeight()).thenReturn(HEADER_HEIGHT);
when(renderer.getHeaderRowHeight()).thenReturn(HEADER_HEIGHT);
}
Aggregations