private void verifyFeedEntityEdges(String feedName, String tag, String group) { Vertex feedVertex = getEntityVertex(feedName, RelationshipType.FEED_ENTITY); // verify edge to cluster vertex verifyVertexForEdge( feedVertex, Direction.OUT, RelationshipLabel.FEED_CLUSTER_EDGE.getName(), CLUSTER_ENTITY_NAME, RelationshipType.CLUSTER_ENTITY.getName()); // verify edge to user vertex verifyVertexForEdge( feedVertex, Direction.OUT, RelationshipLabel.USER.getName(), FALCON_USER, RelationshipType.USER.getName()); // verify edge to tags vertex verifyVertexForEdge( feedVertex, Direction.OUT, "classified-as", tag, RelationshipType.TAGS.getName()); // verify edge to group vertex verifyVertexForEdge( feedVertex, Direction.OUT, RelationshipLabel.GROUPS.getName(), group, RelationshipType.GROUPS.getName()); }
private void verifyClusterEntityEdges() { Vertex clusterVertex = getEntityVertex(CLUSTER_ENTITY_NAME, RelationshipType.CLUSTER_ENTITY); // verify edge to user vertex verifyVertexForEdge( clusterVertex, Direction.OUT, RelationshipLabel.USER.getName(), FALCON_USER, RelationshipType.USER.getName()); // verify edge to colo vertex verifyVertexForEdge( clusterVertex, Direction.OUT, RelationshipLabel.CLUSTER_COLO.getName(), COLO_NAME, RelationshipType.COLO.getName()); // verify edge to tags vertex verifyVertexForEdge( clusterVertex, Direction.OUT, "classification", "production", RelationshipType.TAGS.getName()); }
private void verifyProcessEntityEdges() { Vertex processVertex = getEntityVertex(PROCESS_ENTITY_NAME, RelationshipType.PROCESS_ENTITY); // verify edge to cluster vertex verifyVertexForEdge( processVertex, Direction.OUT, RelationshipLabel.FEED_CLUSTER_EDGE.getName(), CLUSTER_ENTITY_NAME, RelationshipType.CLUSTER_ENTITY.getName()); // verify edge to user vertex verifyVertexForEdge( processVertex, Direction.OUT, RelationshipLabel.USER.getName(), FALCON_USER, RelationshipType.USER.getName()); // verify edge to tags vertex verifyVertexForEdge( processVertex, Direction.OUT, "classified-as", "Critical", RelationshipType.TAGS.getName()); // verify edges to inputs List<String> actual = new ArrayList<String>(); for (Edge edge : processVertex.getEdges(Direction.IN, RelationshipLabel.FEED_PROCESS_EDGE.getName())) { Vertex outVertex = edge.getVertex(Direction.OUT); Assert.assertEquals( RelationshipType.FEED_ENTITY.getName(), outVertex.getProperty(RelationshipProperty.TYPE.getName())); actual.add(outVertex.<String>getProperty(RelationshipProperty.NAME.getName())); } Assert.assertTrue( actual.containsAll(Arrays.asList("impression-feed", "clicks-feed")), "Actual does not contain expected: " + actual); actual.clear(); // verify edges to outputs for (Edge edge : processVertex.getEdges(Direction.OUT, RelationshipLabel.PROCESS_FEED_EDGE.getName())) { Vertex outVertex = edge.getVertex(Direction.IN); Assert.assertEquals( RelationshipType.FEED_ENTITY.getName(), outVertex.getProperty(RelationshipProperty.TYPE.getName())); actual.add(outVertex.<String>getProperty(RelationshipProperty.NAME.getName())); } Assert.assertTrue( actual.containsAll(Arrays.asList("imp-click-join1", "imp-click-join2")), "Actual does not contain expected: " + actual); }
private void verifyFeedsOwnedByUserAndClassification( String feedType, String classification, List<String> expected) { List<String> actual = new ArrayList<String>(); Vertex userVertex = getEntityVertex(FALCON_USER, RelationshipType.USER); for (Vertex feed : userVertex.getVertices(Direction.IN, RelationshipLabel.USER.getName())) { if (feed.getProperty(RelationshipProperty.TYPE.getName()).equals(feedType)) { for (Vertex classVertex : feed.getVertices(Direction.OUT, "classified-as")) { if (classVertex.getProperty(RelationshipProperty.NAME.getName()).equals(classification)) { actual.add(feed.<String>getProperty(RelationshipProperty.NAME.getName())); System.out.println( classification + " feed owned by falcon-user -> " + GraphUtils.vertexString(feed)); } } } } Assert.assertTrue(actual.containsAll(expected), "Actual does not contain expected: " + actual); }
private List<String> getFeedsOwnedByAUser(String feedType) { GraphQuery userQuery = getQuery() .has(RelationshipProperty.NAME.getName(), FALCON_USER) .has(RelationshipProperty.TYPE.getName(), RelationshipType.USER.getName()); List<String> feedNames = new ArrayList<String>(); for (Vertex userVertex : userQuery.vertices()) { for (Vertex feed : userVertex.getVertices(Direction.IN, RelationshipLabel.USER.getName())) { if (feed.getProperty(RelationshipProperty.TYPE.getName()).equals(feedType)) { System.out.println(FALCON_USER + " owns -> " + GraphUtils.vertexString(feed)); feedNames.add(feed.<String>getProperty(RelationshipProperty.NAME.getName())); } } } return feedNames; }