use of org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl 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.EdgeImpl in project kie-wb-common by kiegroup.
the class CaseManagementSetChildNodeGraphCommand method addRelationship.
@SuppressWarnings("unchecked")
private void addRelationship(final Node parent, final Node child, final Optional<Integer> index, final GraphCommandExecutionContext context) {
final String uuid = UUID.uuid();
final Edge<Child, Node> edge = new EdgeImpl<>(uuid);
edge.setContent(new Child());
edge.setSourceNode(parent);
edge.setTargetNode(child);
if (index.isPresent()) {
parent.getOutEdges().add(index.get(), edge);
} else {
parent.getOutEdges().add(edge);
}
child.getInEdges().add(edge);
getMutableIndex(context).addEdge(edge);
}
use of org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl in project kie-wb-common by kiegroup.
the class CaseManagementRemoveChildCommandTest method setup.
@Before
public void setup() {
super.setup();
this.parent = CommandTestUtils.makeNode("uuid1", "parent", 10.0, 20.0, 50.0, 50.0);
this.candidate = CommandTestUtils.makeNode("uuid2", "candidate", 10.0, 20.0, 50.0, 50.0);
this.command = new CaseManagementRemoveChildCommand(parent, candidate);
final Edge<Child, Node> edge = new EdgeImpl<>("edge1");
edge.setContent(new Child());
edge.setSourceNode(parent);
edge.setTargetNode(candidate);
parent.getOutEdges().add(edge);
candidate.getInEdges().add(edge);
}
use of org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl in project kie-wb-common by kiegroup.
the class ConnectorShapeTest method testApplyConnections.
@Test
@SuppressWarnings("unchecked")
public void testApplyConnections() {
final Object def = mock(Object.class);
final Edge<ViewConnector<Object>, Node> edge = new EdgeImpl<>("uuid1");
final ViewConnectorImpl<Object> content = new ViewConnectorImpl<>(def, new BoundsImpl(new BoundImpl(0d, 0d), new BoundImpl(15d, 40d)));
Connection sourceConnection = mock(Connection.class);
Connection targetConnection = mock(Connection.class);
content.setSourceConnection(sourceConnection);
content.setTargetConnection(targetConnection);
edge.setContent(content);
final ShapeView<?> source = mock(ShapeView.class);
final ShapeView<?> target = mock(ShapeView.class);
tested.applyConnections(edge, source, target, MutationContext.STATIC);
verify(((IsConnector) shapeView), times(1)).connect(eq(source), eq(sourceConnection), eq(target), eq(targetConnection));
}
use of org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl in project kie-wb-common by kiegroup.
the class EdgeFactoryImpl method build.
@Override
@SuppressWarnings("unchecked")
public Edge<Definition<Object>, Node> build(final String uuid, final Object definition) {
final EdgeImpl edge = new EdgeImpl<>(uuid);
if (null != definition) {
ViewConnector<Object> content = new ViewConnectorImpl<>(definition, buildBounds());
edge.setContent(content);
addLabels(edge.getLabels(), definition);
}
return edge;
}
Aggregations