@Test public void getValuesReturnsEmptyListIfThePropertyIsNotPresent() { RelatedPropertyValueGetter instance = new RelatedPropertyValueGetter(RELATION); GraphTraversal<Vertex, Vertex> traversal = newGraph() .withVertex("target1", v -> v.withProperty(PROPERTY_NOT_PRESENT, "value1")) .withVertex("target2", v -> v.withProperty(PROPERTY_NOT_PRESENT, "value2")) .withVertex(v -> v.withOutgoingRelation(RELATION, "target1")) .withVertex(v -> v.withOutgoingRelation(RELATION, "target2")) .build().traversal().V(); List<List<String>> results = traversal.toList().stream() .map(v -> instance.getValues(v, PROPERTY)).collect(toList()); assertThat(results, contains( equalTo(Lists.newArrayList()), equalTo(Lists.newArrayList()), equalTo(Lists.newArrayList()), equalTo(Lists.newArrayList()) )); }
@Override public List<String> getValues(Vertex vertex, String propertyName) { List<String> result = new ArrayList<>(); vertex.vertices(Direction.BOTH, relations).forEachRemaining(targetVertex -> { if (targetVertex.property(propertyName).isPresent()) { result.add((String) targetVertex.property(propertyName).value()); } }); return result; }
RelatedPropertyValueGetter implements PropertyValueGetter { @Override public List<String> getValues(Vertex vertex, String propertyName) { List<String> result = new ArrayList<>(); vertex.vertices(Direction.BOTH, relations).forEachRemaining(targetVertex -> { if (targetVertex.property(propertyName).isPresent()) { result.add((String) targetVertex.property(propertyName).value()); } }); return result; } }
RelatedPropertyValueGetter implements PropertyValueGetter { @Override public List<String> getValues(Vertex vertex, String propertyName) { List<String> result = new ArrayList<>(); vertex.vertices(Direction.BOTH, relations).forEachRemaining(targetVertex -> { if (targetVertex.property(propertyName).isPresent()) { result.add((String) targetVertex.property(propertyName).value()); } }); return result; } RelatedPropertyValueGetter(String... relations); }
RelatedPropertyValueGetter implements PropertyValueGetter { @Override public List<String> getValues(Vertex vertex, String propertyName) { List<String> result = new ArrayList<>(); vertex.vertices(Direction.BOTH, relations).forEachRemaining(targetVertex -> { if (targetVertex.property(propertyName).isPresent()) { result.add((String) targetVertex.property(propertyName).value()); } }); return result; } RelatedPropertyValueGetter(String... relations); @Override List<String> getValues(Vertex vertex, String propertyName); }
RelatedPropertyValueGetter implements PropertyValueGetter { @Override public List<String> getValues(Vertex vertex, String propertyName) { List<String> result = new ArrayList<>(); vertex.vertices(Direction.BOTH, relations).forEachRemaining(targetVertex -> { if (targetVertex.property(propertyName).isPresent()) { result.add((String) targetVertex.property(propertyName).value()); } }); return result; } RelatedPropertyValueGetter(String... relations); @Override List<String> getValues(Vertex vertex, String propertyName);  }