@Test (dependsOnMethods = "testAddFlowEdge") public void testDeleteDataNode() throws Exception { Assert.assertTrue(graph.deleteDataNode("node1")); Assert.assertEquals(graph.getNode(node1.getId()), null); Assert.assertEquals(graph.getNode(node2.getId()), node2); Assert.assertEquals(graph.getNode(node3.getId()), node3); Assert.assertEquals(graph.getEdges(node1), null); Field field = BaseFlowGraph.class.getDeclaredField("dataNodeMap"); field.setAccessible(true); Map<String, DataNode> dataNodeMap = (Map<String, DataNode>) field.get(graph); Assert.assertTrue(!dataNodeMap.containsKey("node1")); Assert.assertEquals(dataNodeMap.get("node2"), node2); Assert.assertEquals(dataNodeMap.get("node3"), node3); Assert.assertTrue(!graph.deleteFlowEdge(edge1)); field = BaseFlowGraph.class.getDeclaredField("flowEdgeMap"); field.setAccessible(true); Map<String, FlowEdge> flowEdgeMap = (Map<String, FlowEdge>) field.get(graph); Assert.assertTrue(!flowEdgeMap.containsKey(edge1.getId())); Assert.assertEquals(flowEdgeMap.get(edge2.getId()), edge2); Assert.assertEquals(flowEdgeMap.get(edge3.getId()), edge3); graph.addDataNode(node1); graph.addFlowEdge(edge1); }
@Override public boolean deleteDataNode(String nodeId) { try { rwLock.writeLock().lock(); return this.dataNodeMap.containsKey(nodeId) && deleteDataNode(this.dataNodeMap.get(nodeId)); } finally { rwLock.writeLock().unlock(); } }
BaseFlowGraph implements FlowGraph { @Override public boolean deleteDataNode(String nodeId) { try { rwLock.writeLock().lock(); return this.dataNodeMap.containsKey(nodeId) && deleteDataNode(this.dataNodeMap.get(nodeId)); } finally { rwLock.writeLock().unlock(); } } }
BaseFlowGraph implements FlowGraph { @Override public boolean deleteDataNode(String nodeId) { try { rwLock.writeLock().lock(); return this.dataNodeMap.containsKey(nodeId) && deleteDataNode(this.dataNodeMap.get(nodeId)); } finally { rwLock.writeLock().unlock(); } }  }
BaseFlowGraph implements FlowGraph { @Override public boolean deleteDataNode(String nodeId) { try { rwLock.writeLock().lock(); return this.dataNodeMap.containsKey(nodeId) && deleteDataNode(this.dataNodeMap.get(nodeId)); } finally { rwLock.writeLock().unlock(); } }  DataNode getNode(String nodeId); @Override boolean addDataNode(DataNode node); @Override boolean addFlowEdge(FlowEdge edge); @Override boolean deleteDataNode(String nodeId); boolean deleteDataNode(DataNode node); @Override boolean deleteFlowEdge(String edgeId); boolean deleteFlowEdge(FlowEdge edge); @Override Set<FlowEdge> getEdges(String nodeId); @Override Set<FlowEdge> getEdges(DataNode node); @Override FlowGraphPath findPath(FlowSpec flowSpec); }
BaseFlowGraph implements FlowGraph { @Override public boolean deleteDataNode(String nodeId) { try { rwLock.writeLock().lock(); return this.dataNodeMap.containsKey(nodeId) && deleteDataNode(this.dataNodeMap.get(nodeId)); } finally { rwLock.writeLock().unlock(); } }  DataNode getNode(String nodeId); @Override boolean addDataNode(DataNode node); @Override boolean addFlowEdge(FlowEdge edge); @Override boolean deleteDataNode(String nodeId); boolean deleteDataNode(DataNode node); @Override boolean deleteFlowEdge(String edgeId); boolean deleteFlowEdge(FlowEdge edge); @Override Set<FlowEdge> getEdges(String nodeId); @Override Set<FlowEdge> getEdges(DataNode node); @Override FlowGraphPath findPath(FlowSpec flowSpec);  }