@SuppressWarnings("unchecked") protected boolean doStartNodeTraversal(final Node node, final K callback) { if (node.getContent() instanceof View) { callback.startNodeTraversal((N) node); return true; } return false; }
@SuppressWarnings("unchecked") private void deleteChild(Node parent, Node child) { parent.getOutEdges().stream().filter(edge -> child.equals(((Edge) edge).getTargetNode())) .findAny().ifPresent(edge -> { parent.getOutEdges().remove(edge); child.getInEdges().remove(edge); }); }
@SuppressWarnings("unchecked") private void startNodeTraversal(final Node<?, Edge> node) { this.processesNodes.add(node.getUUID()); if (callback.startNodeTraversal(node)) { // Outgoing connections. node.getOutEdges().forEach(this::startEdgeTraversal); callback.endNodeTraversal(node); // Outgoing connections. pendingEdges.addAll(node.getInEdges()); } }
private static boolean isCompensationTarget(final Node<?, ? extends Edge> node) { return node.getInEdges().stream() .filter(edge -> edge.getSourceNode().getContent() instanceof View && ((View) edge.getSourceNode().getContent()).getDefinition() instanceof IntermediateCompensationEvent) .findFirst() .isPresent(); }
@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()); }
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); }
public static Node mockNode(String uuid) { Node node = mock(Node.class); when(node.getUUID()).thenReturn(uuid); when(node.asNode()).thenReturn(node); when(node.getInEdges()).thenReturn(new LinkedList()); when(node.getOutEdges()).thenReturn(new LinkedList()); return node; }
@Override public boolean startNodeTraversal(final Node node) { // Process incoming edges into the node as well. final List<? extends Edge> inEdges = node.getInEdges(); if (null != inEdges) { inEdges.stream().forEach(this::process); } return true; }
public static List<Edge<? extends ViewConnector<?>, Node>> getSourceConnections( final Node<?, ? extends Edge> element) { Objects.requireNonNull(element.getOutEdges()); return getConnections(element.getOutEdges()); }
@SuppressWarnings("unchecked") protected Node mockNode(String id, Set<String> labels) { Node e = mock(Node.class); View v = mock(View.class); Object d = mock(Object.class); when(e.getContent()).thenReturn(v); when(v.getDefinition()).thenReturn(d); when(definitionAdapter.getId(eq(d))).thenReturn(DefinitionId.build(id)); when(definitionAdapter.getLabels(eq(d))).thenReturn(labels); when(e.getLabels()).thenReturn(labels); return e; }
@Before public void setUp() { super.setUp(); candidate = graphInstance.containerNode; parent = graphInstance.parentNode; candidate.setContent(candidateContent); this.position = new Point2D(1, 1); this.cloneNodeCommand = new CloneNodeCommand(candidate, parent.getUUID(), position, null, childrenTraverseProcessorManagedInstance); }
@Test public void testBuild() { when(testingkHelper.definitionAdapter.getId(eq(definition))).thenReturn(DefinitionId.build(DEF_ID)); final Node<Definition<Object>, Edge> node = tested.build(UUID, definition); assertNotNull(node); assertEquals(UUID, node.getUUID()); assertEquals(3, node.getLabels().size()); assertTrue(node.getLabels().contains(DEF_ID)); assertTrue(node.getLabels().contains("label1")); assertTrue(node.getLabels().contains("label2")); }
private Iterable<Node<Content, Edge>> getMockNodes(final String... uuids) { final List<Node<Content, Edge>> nodes = new ArrayList<>(); for (String uuid : uuids) { final Node<Content, Edge> node = new NodeImpl<>(uuid); node.setContent(new Content()); nodes.add(node); } return nodes; }
@SuppressWarnings("unchecked") T getEndNodeById(Diagram<Graph, Metadata> diagram, String id, boolean hasIncomeEdge) { Node<? extends Definition, ?> node = diagram.getGraph().getNode(id); assertNotNull(node); int incomeEdges = hasIncomeEdge ? 2 : 1; assertEquals(incomeEdges, node.getInEdges().size()); assertEquals(0, node.getOutEdges().size()); return getEndEventType().cast(node.getContent().getDefinition()); }
@Before public void setUp() throws Exception { super.setUp(); when(candidate.getUUID()).thenReturn(C_ID); when(parent.getUUID()).thenReturn(P_ID); when(candidate.getContent()).thenReturn(view); when(view.getBounds()).thenReturn(Bounds.create(0d, 0d, 10d, 10d)); this.tested = new CaseManagementDeleteCanvasNodeCommand(candidate, parent, index); }
public static boolean isDockedNode(final Node<?, ? extends Edge> element) { return Objects.nonNull(element.getInEdges()) ? element.getInEdges() .stream() .anyMatch(edge -> edge.getContent() instanceof Dock) : false; }
private static List<Node> getNodesFromOutEdges(final Node<?, ? extends Edge> element, Predicate<Edge> filter) { Objects.requireNonNull(element.getOutEdges()); return element.getOutEdges() .stream() .filter(filter::test) .map(Edge::getTargetNode) .collect(Collectors.toList()); }
private Node<View, Edge> newNode(final Object definition) { final Node<View, Edge> node = new NodeImpl<>(UUID.uuid()); final View<Object> content = new ViewImpl<>(definition, bounds); node.setContent(content); return node; }
public Stream<EdgeT> childEdges() { return nodes() .flatMap(e -> Stream.concat( e.getInEdges().stream(), e.getOutEdges().stream())) .distinct() .filter(e -> (isChild(e))); }