use of org.kie.workbench.common.stunner.core.graph.Element in project kie-wb-common by kiegroup.
the class SessionPreviewCanvasHandlerProxyTest method checkDeregisterDelegatesToWrapped.
@Test
public void checkDeregisterDelegatesToWrapped() {
final Element candidate = mock(Element.class);
proxy.deregister(candidate);
verify(wrapped).deregister(eq(candidate));
final Shape shape = mock(Shape.class);
final boolean fireEvents = true;
proxy.deregister(shape, candidate, fireEvents);
verify(wrapped).deregister(eq(shape), eq(candidate), eq(fireEvents));
proxy.deregister(candidate, fireEvents);
verify(wrapped).deregister(eq(candidate), eq(fireEvents));
}
use of org.kie.workbench.common.stunner.core.graph.Element in project kie-wb-common by kiegroup.
the class DecisionTableGridTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() {
this.definition = new DecisionTableEditorDefinition(gridPanel, gridLayer, definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, cellEditorControls, listSelector, translationService, hitPolicyEditor);
expression = definition.getModelClass();
doReturn(session).when(sessionManager).getCurrentSession();
doReturn(canvasHandler).when(session).getCanvasHandler();
doReturn(graphCommandContext).when(canvasHandler).getGraphExecutionContext();
when(gridWidget.getModel()).thenReturn(new BaseGridData(false));
when(canvasHandler.getGraphIndex()).thenReturn(index);
when(index.get(anyString())).thenReturn(element);
when(element.getContent()).thenReturn(mock(Definition.class));
when(definitionUtils.getNameIdentifier(any())).thenReturn("name");
when(canvasCommandFactory.updatePropertyValue(any(Element.class), anyString(), any())).thenReturn(mock(UpdateElementPropertyCommand.class));
doAnswer((i) -> i.getArguments()[0].toString()).when(translationService).format(anyString());
}
use of org.kie.workbench.common.stunner.core.graph.Element in project kie-wb-common by kiegroup.
the class FunctionGridTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() {
tupleWithoutValue = new GridCellTuple(0, 0, gridWidget);
tupleWithValue = new GridCellValueTuple<>(0, 0, gridWidget, new BaseGridCellValue<>("value"));
definition = new FunctionEditorDefinition(gridPanel, gridLayer, definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, cellEditorControls, listSelector, translationService, expressionEditorDefinitionsSupplier, supplementaryEditorDefinitionsSupplier, parametersEditor);
expression = definition.getModelClass();
expression.get().getFormalParameter().add(parameter);
parameter.getName().setValue(PARAMETER_NAME);
final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
expressionEditorDefinitions.add((ExpressionEditorDefinition) definition);
expressionEditorDefinitions.add(literalExpressionEditorDefinition);
expressionEditorDefinitions.add(supplementaryLiteralExpressionEditorDefinition);
final Decision decision = new Decision();
decision.setName(new Name("name"));
hasName = Optional.of(decision);
doReturn(expressionEditorDefinitions).when(expressionEditorDefinitionsSupplier).get();
doReturn(expressionEditorDefinitions).when(supplementaryEditorDefinitionsSupplier).get();
doReturn(ExpressionType.LITERAL_EXPRESSION).when(literalExpressionEditorDefinition).getType();
doReturn(Optional.of(literalExpression)).when(literalExpressionEditorDefinition).getModelClass();
doReturn(Optional.of(literalExpressionEditor)).when(literalExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
doReturn(Optional.of(supplementaryLiteralExpression)).when(supplementaryLiteralExpressionEditorDefinition).getModelClass();
doReturn(Optional.of(supplementaryLiteralExpressionEditor)).when(supplementaryLiteralExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
final GridData uiLiteralExpressionModel = new BaseGridData();
doReturn(uiLiteralExpressionModel).when(literalExpressionEditor).getModel();
doReturn(session).when(sessionManager).getCurrentSession();
doReturn(canvasHandler).when(session).getCanvasHandler();
when(gridWidget.getModel()).thenReturn(new BaseGridData(false));
when(canvasHandler.getGraphIndex()).thenReturn(index);
when(index.get(anyString())).thenReturn(element);
when(element.getContent()).thenReturn(mock(Definition.class));
when(definitionUtils.getNameIdentifier(any())).thenReturn("name");
when(canvasCommandFactory.updatePropertyValue(any(Element.class), anyString(), any())).thenReturn(mock(UpdateElementPropertyCommand.class));
doAnswer((i) -> i.getArguments()[0].toString()).when(translationService).format(anyString());
}
use of org.kie.workbench.common.stunner.core.graph.Element in project kie-wb-common by kiegroup.
the class InvocationGridTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() {
tupleWithoutValue = new GridCellTuple(0, 1, gridWidget);
tupleWithValue = new GridCellValueTuple<>(0, 1, gridWidget, new BaseGridCellValue<>("value"));
definition = new InvocationEditorDefinition(gridPanel, gridLayer, definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, cellEditorControls, listSelector, translationService, expressionEditorDefinitionsSupplier);
expression = definition.getModelClass();
expression.ifPresent(invocation -> ((LiteralExpression) invocation.getExpression()).setText("invocation-expression"));
final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
expressionEditorDefinitions.add((ExpressionEditorDefinition) definition);
expressionEditorDefinitions.add(literalExpressionEditorDefinition);
expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
doReturn(expressionEditorDefinitions).when(expressionEditorDefinitionsSupplier).get();
doReturn(Optional.of(literalExpression)).when(literalExpressionEditorDefinition).getModelClass();
doReturn(Optional.of(literalExpressionEditor)).when(literalExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
doReturn(parent).when(undefinedExpressionEditor).getParentInformation();
doReturn(Optional.empty()).when(undefinedExpressionEditorDefinition).getModelClass();
doReturn(Optional.of(undefinedExpressionEditor)).when(undefinedExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
doReturn(session).when(sessionManager).getCurrentSession();
doReturn(canvasHandler).when(session).getCanvasHandler();
doReturn(graphContext).when(canvasHandler).getGraphExecutionContext();
final Decision decision = new Decision();
decision.setName(new Name("name"));
hasName = Optional.of(decision);
when(gridWidget.getModel()).thenReturn(new BaseGridData(false));
when(canvasHandler.getGraphIndex()).thenReturn(index);
when(index.get(anyString())).thenReturn(element);
when(element.getContent()).thenReturn(mock(Definition.class));
when(definitionUtils.getNameIdentifier(any())).thenReturn("name");
when(canvasCommandFactory.updatePropertyValue(any(Element.class), anyString(), any())).thenReturn(mock(UpdateElementPropertyCommand.class));
doAnswer((i) -> i.getArguments()[0].toString()).when(translationService).format(anyString());
}
use of org.kie.workbench.common.stunner.core.graph.Element in project kie-wb-common by kiegroup.
the class LiteralExpressionGridTest method setup.
@Before
public void setup() {
tupleWithoutValue = new GridCellTuple(0, 0, gridWidget);
tupleWithValue = new GridCellValueTuple<>(0, 0, gridWidget, new BaseGridCellValue<>("value"));
definition = new LiteralExpressionEditorDefinition(gridPanel, gridLayer, definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, cellEditorControls, listSelector, translationService);
final Decision decision = new Decision();
decision.setName(new Name("name"));
hasName = Optional.of(decision);
expression = definition.getModelClass();
expression.ifPresent(e -> e.setText(EXPRESSION_TEXT));
doReturn(session).when(sessionManager).getCurrentSession();
doReturn(canvasHandler).when(session).getCanvasHandler();
doReturn(mock(Bounds.class)).when(gridLayer).getVisibleBounds();
when(gridWidget.getModel()).thenReturn(new BaseGridData(false));
when(canvasHandler.getGraphIndex()).thenReturn(index);
when(index.get(anyString())).thenReturn(element);
when(element.getContent()).thenReturn(mock(Definition.class));
when(definitionUtils.getNameIdentifier(any())).thenReturn("name");
when(canvasCommandFactory.updatePropertyValue(any(Element.class), anyString(), any())).thenReturn(mock(UpdateElementPropertyCommand.class));
when(parentGridWidget.getModel()).thenReturn(parentGridUiModel);
when(parent.getGridWidget()).thenReturn(parentGridWidget);
when(parent.getRowIndex()).thenReturn(0);
when(parent.getColumnIndex()).thenReturn(1);
}
Aggregations