@SuppressWarnings("unchecked") protected boolean doStartNodeTraversal(final Node node, final K callback) { if (node.getContent() instanceof View) { callback.startNodeTraversal((N) node); return true; } return false; }
protected BPMNDefinition getEdgeTarget(Edge edge) { Node targetNode = edge.getTargetNode(); if (targetNode != null && targetNode.getContent() instanceof View) { Object definition = ((View) targetNode.getContent()).getDefinition(); if (definition instanceof BPMNDefinition) { return (BPMNDefinition) definition; } } return null; } }
@Override public boolean startNodeTraversal(final Node node) { if (node.getContent() instanceof View) { callback.startNodeTraversal(node); return true; } return false; }
@Override public void endNodeTraversal(final Node node) { if (node.getContent() instanceof View) { callback.endNodeTraversal(node); } }
@SuppressWarnings("unchecked") protected void doEndNodeTraversal(final Node node, final K callback) { if (node.getContent() instanceof View) { callback.endNodeTraversal((N) node); } }
private Result<Out> applyFallback(Node<? extends View<? extends BPMNViewDefinition>, ?> value) { if (orElse == null) { return Result.failure(value == null ? "Null" : value.getContent().getDefinition().getClass().getName()); } else { return Result.of(orElse.apply(value)); } }
protected void setSize(final BuilderContext context, final T node) { final double[] size = GraphUtils.getNodeSize(node.getContent()); setSize(context, node, size[0], size[1]); }
@Override @SuppressWarnings("unchecked") public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { return execute(context, bounds -> node.getContent().setBounds(bounds)); }
public UpdateElementPositionCommand(final Node<? extends View<?>, Edge> node, final Point2D location) { this(node.getUUID(), location, GraphUtils.getPosition(node.getContent())); this.node = PortablePreconditions.checkNotNull("node", node); }
@SuppressWarnings("unchecked") T getGatewayNodeById(Diagram<Graph, Metadata> diagram, String id, Class<T> type) { Node<? extends Definition, ?> node = diagram.getGraph().getNode(id); assertThat(node).isNotNull(); return type.cast(node.getContent().getDefinition()); }
void cloneNodeContentWithProperties(final GraphCommandExecutionContext context) { final View cloneContent = getClone().getContent(); final View candidateContent = (View) getCandidate().getContent(); final Bounds candidateBounds = candidateContent.getBounds(); final Bounds clonedBounds = cloneBounds(candidateBounds); final CloneManager cloneManager = context.getDefinitionManager().cloneManager(); final Object clonedDefinition = cloneManager.clone(candidateContent.getDefinition(), ClonePolicy.ALL); cloneContent.setBounds(clonedBounds); cloneContent.setDefinition(clonedDefinition); }
@Before public void setUp() { event = createEvent(); when(node.getContent()).thenReturn(content); when(content.getDefinition()).thenReturn(event); bpmn2Event = createBpmn2Event(compensateEvent); when(nodeWriter.getElement()).thenReturn(bpmn2Event); when(processWriter.getProcess()).thenReturn(process); converter = createConverter(); }
@Before public void setup() throws Exception { diagram = new BPMNDiagram.BPMNDiagramBuilder().build(); diagramNodeContent = new ViewImpl<BPMNDiagram>( diagram, bounds ); graphNodes.add( diagramNode ); when( diagramNode.getContent() ).thenReturn( diagramNodeContent ); when( graph.nodes() ).thenReturn( graphNodes ); tested = new BPMNProjectDiagramFactory(); }
@Test @SuppressWarnings("unchecked") public void testOutOfBoundsFail() { when(candidate.getContent()).thenReturn(new ViewImpl<>(mock(Object.class), Bounds.create(0d, 0d, 100d, 100d))); tested = new UpdateElementPositionCommand(candidate, Point2D.create(550d, 550d)); CommandResult<RuleViolation> result = tested.execute(graphCommandExecutionContext); assertEquals(CommandResult.Type.ERROR, result.getType()); verify(content, never()).setBounds(any(Bounds.class)); } }
private PropertyWriter noneEvent(Node<View<EndNoneEvent>, ?> n) { EndEvent event = bpmn2.createEndEvent(); event.setId(n.getUUID()); BaseEndEvent definition = n.getContent().getDefinition(); ThrowEventPropertyWriter p = propertyWriterFactory.of(event); BPMNGeneralSet general = definition.getGeneral(); p.setName(general.getName().getValue()); p.setDocumentation(general.getDocumentation().getValue()); p.setBounds(n.getContent().getBounds()); return p; }
@Test public void testGetAt() { Point2D position = GraphUtils.getPosition((View) graphInstanceParent.startNode.getContent()); double[] size = GraphUtils.getNodeSize((View) graphInstanceParent.startNode.getContent()); double getAtX = position.getX() + (size[0] / 2); double getAtY = position.getY() + (size[1] / 2); Node<View<?>, Edge> node = graphBoundsIndexerImpl.getAt(getAtX, getAtY); assertNotNull(node); }
@SuppressWarnings("unchecked") T getTaskNodeById(Diagram<Graph, Metadata> diagram, String id, int amountOfIncomeEdges, boolean hasOutcomeEdge) { Node<? extends Definition, ?> node = diagram.getGraph().getNode(id); assertNotNull(node); assertEquals(amountOfIncomeEdges + 1, node.getInEdges().size()); int outcomeEdges = hasOutcomeEdge ? 1 : 0; assertEquals(outcomeEdges, node.getOutEdges().size()); return getTaskType().cast(node.getContent().getDefinition()); }
@Test @SuppressWarnings("unchecked") public void testExecuteDockedNode() { ArgumentCaptor<Bounds> boundsArgumentCaptor = ArgumentCaptor.forClass(Bounds.class); this.tested = new UpdateElementPositionCommand(dockedNode, new Point2D(600d, 600d)); final CommandResult<RuleViolation> result = tested.execute(graphCommandExecutionContext); verify((View) dockedNode.getContent(), times(1)).setBounds(boundsArgumentCaptor.capture()); assertEquals(CommandResult.Type.INFO, result.getType()); Bounds bounds = boundsArgumentCaptor.getValue(); assertEquals(bounds.getUpperLeft(), Bound.create(600d, 600d)); assertEquals(bounds.getLowerRight(), Bound.create(650d, 650d)); }
@Test @SuppressWarnings("unchecked") public void testUnmarshallBasic() throws Exception { Diagram<Graph, Metadata> diagram = unmarshall(BPMN_BASIC); assertDiagram(diagram, 4); assertEquals("Basic process", diagram.getMetadata().getTitle()); Node<? extends Definition, ?> task1 = diagram.getGraph().getNode("810797AB-7D09-4E1F-8A5B-96C424E4B031"); assertTrue(task1.getContent().getDefinition() instanceof NoneTask); }
@Test public void testBasicBidi() throws Exception { Diagram<Graph, Metadata> d = unmarshall(newMarshaller, BPMN_SERVICE_TASK_PROPERTIES_FILE_PATH); String marshall = newMarshaller.marshall(d); Diagram<Graph, Metadata> d2 = Unmarshalling.unmarshall(newMarshaller, new StringInputStream(marshall)); Node<View<ServiceTask>, ?> node = d2.getGraph().getNode(SERVICE_TASK_ID); ServiceTask definition = node.getContent().getDefinition(); assertEquals("Custom Email", definition.getGeneral().getName().getValue()); assertEquals("This is an email task", definition.getGeneral().getDocumentation().getValue()); } }