use of org.kie.workbench.common.stunner.core.graph.impl.NodeImpl in project kie-wb-common by kiegroup.
the class BPMNDiagramMarshallerTest method testUnmarshallSequenceFlow.
@Test
public void testUnmarshallSequenceFlow() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_SEQUENCEFLOW);
SequenceFlow sequenceFlow1 = null;
SequenceFlow sequenceFlow2 = null;
Iterator<Element> it = nodesIterator(diagram);
while (it.hasNext()) {
Element element = it.next();
if (element.getContent() instanceof View) {
Object oDefinition = ((View) element.getContent()).getDefinition();
if (oDefinition instanceof ExclusiveGateway) {
List<Edge> outEdges = ((NodeImpl) element).getOutEdges();
for (Edge edge : outEdges) {
SequenceFlow flow = (SequenceFlow) ((ViewConnectorImpl) ((EdgeImpl) edge).getContent()).getDefinition();
if ("route1".equals(flow.getGeneral().getName().getValue())) {
sequenceFlow1 = flow;
}
if ("route2".equals(flow.getGeneral().getName().getValue())) {
sequenceFlow2 = flow;
}
}
}
}
}
assertNotNull(sequenceFlow1);
assertNotNull(sequenceFlow1.getExecutionSet());
assertNotNull(sequenceFlow1.getExecutionSet().getConditionExpression());
assertNotNull(sequenceFlow1.getExecutionSet().getPriority());
assertNotNull(sequenceFlow1.getGeneral());
assertNotNull(sequenceFlow1.getGeneral().getName());
assertEquals("route1", sequenceFlow1.getGeneral().getName().getValue());
assertEquals("age >= 10;", sequenceFlow1.getExecutionSet().getConditionExpression().getValue().getScript());
assertEquals("javascript", sequenceFlow1.getExecutionSet().getConditionExpression().getValue().getLanguage());
assertEquals("2", sequenceFlow1.getExecutionSet().getPriority().getValue());
assertNotNull(sequenceFlow2);
assertNotNull(sequenceFlow2.getExecutionSet());
assertNotNull(sequenceFlow2.getExecutionSet().getConditionExpression());
assertNotNull(sequenceFlow2.getExecutionSet().getPriority());
assertNotNull(sequenceFlow2.getGeneral());
assertNotNull(sequenceFlow2.getGeneral().getName());
assertEquals("route2", sequenceFlow2.getGeneral().getName().getValue());
assertEquals("age\n" + "<\n" + "10;", sequenceFlow2.getExecutionSet().getConditionExpression().getValue().getScript());
assertEquals("java", sequenceFlow2.getExecutionSet().getConditionExpression().getValue().getLanguage());
assertEquals("1", sequenceFlow2.getExecutionSet().getPriority().getValue());
}
use of org.kie.workbench.common.stunner.core.graph.impl.NodeImpl in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testUnmarshallSequenceFlow.
@Test
public void testUnmarshallSequenceFlow() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_SEQUENCEFLOW);
SequenceFlow sequenceFlow1 = null;
SequenceFlow sequenceFlow2 = null;
Iterator<Element> it = nodesIterator(diagram);
while (it.hasNext()) {
Element element = it.next();
if (element.getContent() instanceof View) {
Object oDefinition = ((View) element.getContent()).getDefinition();
if (oDefinition instanceof ExclusiveGateway) {
List<Edge> outEdges = ((NodeImpl) element).getOutEdges();
for (Edge edge : outEdges) {
SequenceFlow flow = (SequenceFlow) ((ViewConnectorImpl) edge.getContent()).getDefinition();
if ("route1".equals(flow.getGeneral().getName().getValue())) {
sequenceFlow1 = flow;
}
if ("route2".equals(flow.getGeneral().getName().getValue())) {
sequenceFlow2 = flow;
}
}
}
}
}
assertNotNull(sequenceFlow1);
assertNotNull(sequenceFlow1.getExecutionSet());
assertNotNull(sequenceFlow1.getExecutionSet().getConditionExpression());
assertNotNull(sequenceFlow1.getExecutionSet().getPriority());
assertNotNull(sequenceFlow1.getGeneral());
assertNotNull(sequenceFlow1.getGeneral().getName());
assertEquals("route1", sequenceFlow1.getGeneral().getName().getValue());
assertEquals("age >= 10;", sequenceFlow1.getExecutionSet().getConditionExpression().getValue().getScript());
assertEquals("javascript", sequenceFlow1.getExecutionSet().getConditionExpression().getValue().getLanguage());
assertEquals("2", sequenceFlow1.getExecutionSet().getPriority().getValue());
assertNotNull(sequenceFlow2);
assertNotNull(sequenceFlow2.getExecutionSet());
assertNotNull(sequenceFlow2.getExecutionSet().getConditionExpression());
assertNotNull(sequenceFlow2.getExecutionSet().getPriority());
assertNotNull(sequenceFlow2.getGeneral());
assertNotNull(sequenceFlow2.getGeneral().getName());
assertEquals("route2", sequenceFlow2.getGeneral().getName().getValue());
assertEquals("age\n" + "<\n" + "10;", sequenceFlow2.getExecutionSet().getConditionExpression().getValue().getScript());
assertEquals("java", sequenceFlow2.getExecutionSet().getConditionExpression().getValue().getLanguage());
assertEquals("1", sequenceFlow2.getExecutionSet().getPriority().getValue());
}
use of org.kie.workbench.common.stunner.core.graph.impl.NodeImpl in project kie-wb-common by kiegroup.
the class CaseManagementUtilsTest method checkGetFirstDiagramNodeWithNonEmptyGraph.
@Test
@SuppressWarnings("unchecked")
public void checkGetFirstDiagramNodeWithNonEmptyGraph() {
final Graph graph = new GraphImpl<>("uuid", new GraphNodeStoreImpl());
final Node node = new NodeImpl<Definition>("node-uuid");
final CaseManagementDiagram content = new CaseManagementDiagram.CaseManagementDiagramBuilder().build();
node.setContent(new DefinitionImpl<>(content));
graph.addNode(node);
final Node<Definition<CaseManagementDiagram>, ?> fNode = CaseManagementUtils.getFirstDiagramNode(graph);
assertNotNull(fNode);
assertEquals("node-uuid", fNode.getUUID());
assertEquals(content, fNode.getContent().getDefinition());
}
use of org.kie.workbench.common.stunner.core.graph.impl.NodeImpl in project kie-wb-common by kiegroup.
the class CaseManagementCanvasHandlerTest method makeNode.
@SuppressWarnings("unchecked")
private Node<View<BPMNViewDefinition>, Edge> makeNode(final String uuid, final AbstractElementShape shape) {
final Node<View<BPMNViewDefinition>, Edge> node = new NodeImpl<>(uuid);
node.setContent(new ViewImpl(shape.getShapeDefinition(), new BoundsImpl(new BoundImpl(0.0, 0.0), new BoundImpl(10.0, 20.0))));
when(canvas.getShape(eq(uuid))).thenReturn(shape);
when(clientDefinitionManager.adapters()).thenReturn(adapterManager);
when(adapterManager.forDefinition()).thenReturn(definitionAdapter);
when(adapterManager.forProperty()).thenReturn(propertyAdapter);
when(definitionAdapter.getMetaProperty(eq(PropertyMetaTypes.NAME), anyObject())).thenReturn(PropertyMetaTypes.NAME);
when(propertyAdapter.getValue(eq(PropertyMetaTypes.NAME))).thenReturn("name");
return node;
}
use of org.kie.workbench.common.stunner.core.graph.impl.NodeImpl in project kie-wb-common by kiegroup.
the class VariablesEditorFieldRendererTest method testRemoveVariable.
@Test
public void testRemoveVariable() {
when(variablesEditorWidgetView.getVariableWidget(anyInt())).thenReturn(variableListItemWidgetView);
when(variablesEditorWidgetView.getVariableRowsCount()).thenReturn(1);
when(variableRow.getName()).thenReturn("variableName");
when(abstractClientSessionManager.getCurrentSession()).thenReturn(clientFullSession);
when(abstractClientSessionManager.getCurrentSession().getCanvasHandler()).thenReturn(canvasHandler);
when(abstractClientSessionManager.getCurrentSession().getCanvasHandler().getDiagram()).thenReturn(diagram);
when(abstractClientSessionManager.getCurrentSession().getCanvasHandler().getDiagram().getGraph()).thenReturn(graph);
final List nodes = new ArrayList<>();
final Node node = new NodeImpl<>("node1");
nodes.add(node);
when(graph.nodes()).thenReturn(nodes);
when(deleteHandler.isVariableBoundToNodes(graph, variableRow.getName())).thenReturn(true);
variablesEditorRemove.addVariable();
variablesEditorRemove.addVariable();
variablesEditorRemove.removeVariable(variableRow);
verify(variablesEditorWidgetView, times(3)).getVariableRows();
verify(variablesEditorWidgetView, times(1)).doSave();
variablesEditorRemove.removeVariable(variableRow);
verify(variablesEditorWidgetView, times(4)).getVariableRows();
verify(variablesEditorWidgetView, times(2)).doSave();
}
Aggregations