use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.
the class DRDContextMenuServiceTest method mockNodes.
private Collection<Node<? extends Definition<?>, Edge>> mockNodes() {
final Node node = mock(Node.class);
final Node clonedNode = mock(Node.class);
final View content = mock(View.class);
final View clonedContent = mock(View.class);
final Bounds bounds = mock(Bounds.class);
final Bound upperLeft = mock(Bound.class);
final Bound lowerRight = mock(Bound.class);
final InputData inputData = spy(new InputData());
final InputData clonedInputData = spy(new InputData());
final Collection<Node<? extends Definition<?>, Edge>> nodes = new ArrayList<>();
when(node.getContent()).thenReturn(content);
when(content.getDefinition()).thenReturn(inputData);
when(content.getBounds()).thenReturn(bounds);
when(bounds.getUpperLeft()).thenReturn(upperLeft);
when(bounds.getLowerRight()).thenReturn(lowerRight);
when(factoryManager.newElement(Mockito.<String>any(), Mockito.<String>any())).thenReturn(clonedNode);
when(clonedNode.asNode()).thenReturn(clonedNode);
when(clonedNode.getContent()).thenReturn(clonedContent);
when(clonedContent.getDefinition()).thenReturn(clonedInputData);
when(dmnDeepCloneProcess.clone(eq(inputData))).thenReturn(clonedInputData);
nodes.add(node);
return nodes;
}
use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.
the class DRDContextMenuServiceTest method testAddToNewDRD.
@Test
public void testAddToNewDRD() {
final Collection<Node<? extends Definition<?>, Edge>> nodes = mock(Collection.class);
final Definitions definitions = mock(Definitions.class);
final Diagram drgDiagram = mock(Diagram.class);
final List<DMNDiagramElement> diagramElements = mock(List.class);
when(dmnDiagramsSession.getDRGDiagram()).thenReturn(drgDiagram);
when(dmnDiagramUtils.getDefinitions(drgDiagram)).thenReturn(definitions);
when(definitions.getDiagramElements()).thenReturn(diagramElements);
drdContextMenuService.addToNewDRD(nodes);
verify(diagramElements, times(1)).add(Mockito.<DMNDiagramElement>any());
verify(dmnDiagramsSession, times(1)).add(Mockito.<DMNDiagramElement>any(), Mockito.<Diagram>any());
verify(selectedEvent, times(1)).fire(Mockito.<DMNDiagramSelected>any());
}
use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.
the class ContextGridTest 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 ContextEditorDefinition(definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, editorSelectedEvent, refreshFormPropertiesEvent, domainObjectSelectionEvent, listSelector, translationService, expressionEditorDefinitionsSupplier, headerEditor, readOnlyProvider);
final Decision decision = new Decision();
decision.setName(new Name(NAME));
hasName = Optional.of(decision);
expression = definition.getModelClass();
definition.enrich(Optional.empty(), hasExpression, expression);
final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
expressionEditorDefinitions.add((ExpressionEditorDefinition) definition);
expressionEditorDefinitions.add(literalExpressionEditorDefinition);
expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
when(expressionEditorDefinitionsSupplier.get()).thenReturn(expressionEditorDefinitions);
when(literalExpressionEditor.getParentInformation()).thenReturn(parent);
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(session.getCanvasHandler()).thenReturn(canvasHandler);
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.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.
the class ExpressionContainerGridTest method testSelectCellWithDomainObjectInStunnerGraph.
@Test
public void testSelectCellWithDomainObjectInStunnerGraph() {
final int uiRowIndex = 0;
final int uiColumnIndex = 1;
final LiteralExpression domainObject = mock(LiteralExpression.class);
when(hasExpression.asDMNModelInstrumentedBase()).thenReturn(domainObject);
when(graph.nodes()).thenReturn(Collections.singletonList(node));
final Definition definition = mock(Definition.class);
when(node.getUUID()).thenReturn(NODE_UUID);
when(node.getContent()).thenReturn(definition);
when(definition.getDefinition()).thenReturn(domainObject);
grid.setExpression(NODE_UUID, hasExpression, Optional.of(hasName), false);
grid.selectCell(uiRowIndex, uiColumnIndex, false, true);
verify(gridLayer).select(eq(grid));
verify(refreshFormPropertiesEvent).fire(refreshFormPropertiesEventCaptor.capture());
final RefreshFormPropertiesEvent refreshFormPropertiesEvent = refreshFormPropertiesEventCaptor.getValue();
assertThat(refreshFormPropertiesEvent.getUuid()).isEqualTo(NODE_UUID);
assertThat(refreshFormPropertiesEvent.getSession()).isEqualTo(session);
verify(cellSelectionManager).selectCell(eq(uiRowIndex), eq(uiColumnIndex), eq(false), eq(true));
}
use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.
the class MonacoFEELSuggestionsTest method makeDecisionNode.
private NodeImpl<Definition<Decision>> makeDecisionNode(final String name, final BuiltInType builtInType) {
final NodeImpl<Definition<Decision>> node = makeNodeImpl();
final Definition<Decision> definition = makeDefinition();
final Decision decision = spy(new Decision());
final InformationItemPrimary informationItemPrimary = mock(InformationItemPrimary.class);
final QName qName = builtInType == null ? null : new QName(builtInType);
when(informationItemPrimary.getTypeRef()).thenReturn(qName);
when(node.getContent()).thenReturn(definition);
when(definition.getDefinition()).thenReturn(decision);
decision.setName(new Name(name));
decision.setVariable(informationItemPrimary);
return node;
}
Aggregations