@Test public void shouldDelegatePutPropertyToLazyProperties() { // Given final Edge edge = new Edge.Builder().build(); final ElementValueLoader edgeLoader = mock(ElementValueLoader.class); final LazyEdge lazyEdge = new LazyEdge(edge, edgeLoader); final String propertyName = "property name"; final String propertyValue = "property value"; // When lazyEdge.putProperty(propertyName, propertyValue); // Then assertEquals(propertyValue, edge.getProperty(propertyName)); assertEquals(propertyValue, lazyEdge.getProperty(propertyName)); }
@Test public void shouldBuildEdge() { // Given final String source = "source vertex"; final String destination = "dest vertex"; final boolean directed = true; final String propValue = "propValue"; // When final Edge edge = new Edge.Builder() .group(TestGroups.EDGE) .source(source) .dest(destination) .directed(directed) .property(TestPropertyNames.STRING, propValue) .build(); // Then assertEquals(TestGroups.EDGE, edge.getGroup()); assertEquals(source, edge.getSource()); assertEquals(destination, edge.getDestination()); assertTrue(edge.isDirected()); assertEquals(propValue, edge.getProperty(TestPropertyNames.STRING)); }
@Test public void shouldConstructEdge() { // Given final String source = "source vertex"; final String destination = "dest vertex"; final boolean directed = true; final String propValue = "propValue"; // When final Edge edge = new Edge.Builder() .group(TestGroups.EDGE) .source(source) .dest(destination) .directed(directed) .build(); edge.putProperty(TestPropertyNames.STRING, propValue); // Then assertEquals(TestGroups.EDGE, edge.getGroup()); assertEquals(source, edge.getSource()); assertEquals(destination, edge.getDestination()); assertTrue(edge.isDirected()); assertEquals(propValue, edge.getProperty(TestPropertyNames.STRING)); }
@SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST", justification = "If an element is not an Entity it must be an Edge") @Override public String getObject(final Element element) { if (element instanceof Entity) { throw new UnsupportedOperationException(); } else { final Edge edge = ((Edge) element); return edge.getSource() + "," + edge.getDestination() + "," + edge.getProperty("startDate") + "," + edge.getProperty("visibility"); } } }
@SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST", justification = "If an element is not an Entity it must be an Edge") @Override public String getObject(final Element element) { if (element instanceof Entity) { throw new UnsupportedOperationException(); } else { final Edge edge = ((Edge) element); return edge.getSource() + "," + edge.getDestination() + "," + edge.getProperty("count"); } } }
@SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST", justification = "If an element is not an Entity it must be an Edge") @Override public String getObject(final Element element) { if (element instanceof Entity) { throw new UnsupportedOperationException(); } else { final Edge edge = ((Edge) element); return edge.getSource() + "," + edge.getDestination() + "," + edge.getProperty("count"); } } }
@Override public String _apply(final Element element) { if (!(element instanceof Edge && "RoadUse".equals(element.getGroup()))) { throw new UnsupportedOperationException("Only RoadUse edges should be used"); } final Edge edge = ((Edge) element); return edge.getSource() + "," + edge.getDestination() + "," + edge.getProperty("count"); } }
@SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST", justification = "If an element is not an Entity it must be an Edge") @Override public String getObject(final Element element) { if (element instanceof Entity) { final Entity entity = ((Entity) element); return entity.getVertex() + "," + entity.getProperty("count"); } else { final Edge edge = ((Edge) element); return edge.getSource() + "," + edge.getDestination() + "," + edge.getProperty("count"); } } }
@SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST", justification = "If an element is not an Entity it must be an Edge") @Override public String _apply(final Element element) { if (element instanceof Entity) { final Entity entity = (Entity) element; return entity.getVertex() + "," + entity.getProperty("count"); } else { final Edge edge = (Edge) element; return edge.getSource() + "," + edge.getDestination() + "," + edge.getProperty("count"); } } }
@SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST", justification = "If an element is not an Entity it must be an Edge") @Override public Object getObject(final Element element) { if (element instanceof Entity) { return new DomainObject1((int) ((Entity) element).getVertex(), (int) element.getProperty("count")); } else { final Edge edge = (Edge) element; return new DomainObject2((int) edge.getSource(), (int) edge.getDestination(), (int) edge.getProperty("count")); } } }
@SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST", justification = "If an element is not an Entity it must be an Edge") @Override public Object _apply(final Element element) { if (element instanceof Entity) { return new DomainObject1((int) ((Entity) element).getVertex(), (int) element.getProperty("count")); } else { final Edge edge = (Edge) element; return new DomainObject2((int) edge.getSource(), (int) edge.getDestination(), (int) edge.getProperty("count")); } } }
final Iterable<Edge> edges = graph.execute(query, user); final Edge edge = edges.iterator().next(); final ReservoirItemsSketch<String> stringsSketch = ((ReservoirItemsUnion<String>) edge.getProperty("stringsSample")) .getResult(); final String[] samples = stringsSketch.getSamples();
final Iterable<Edge> edges = graph.execute(query, user); final Edge edge = edges.iterator().next(); final DoublesUnion doublesUnion = (DoublesUnion) edge.getProperty("doublesUnion"); final double[] quantiles = doublesUnion.getResult().getQuantiles(new double[]{0.25D, 0.5D, 0.75D}); final String quantilesEstimate = "Edge A-B with percentiles of double property - 25th percentile: " + quantiles[0] final Iterable<Edge> edges2 = graph.execute(query2, user); final Edge edge2 = edges2.iterator().next(); final DoublesSketch doublesSketch2 = ((DoublesUnion) edge2.getProperty("doublesUnion")).getResult(); final double[] cdf = doublesSketch2.getCDF(new double[]{0.0D, 1.0D, 2.0D}); final String cdfEstimate = "Edge A-B with CDF values at 0: " + cdf[0]
final Iterable<Edge> edges = graph.execute(query, user); final Edge edge = edges.iterator().next(); final LongsSketch longsSketch = (LongsSketch) edge.getProperty("longsSketch"); final String estimates = "Edge A-B: 1L seen approximately " + longsSketch.getEstimate(1L) + " times, 9L seen approximately " + longsSketch.getEstimate(9L) + " times.";