@Test public void getValuesReturnsEmptyListIfThePropertyIsNotPresent() { RelatedMultiValuePropertyGetter instance = new RelatedMultiValuePropertyGetter(RELATION); GraphTraversal<Vertex, Vertex> traversal = newGraph() .withVertex("target1", v -> v.withProperty(PROPERTY_NOT_PRESENT, "[\"value1\"]").withTimId("1")) .withVertex("target2", v -> v.withProperty(PROPERTY_NOT_PRESENT, "[\"value2\", \"value3\"]").withTimId("2")) .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)) .filter(r -> r.size() > 0).collect(toList()); assertThat(results, equalTo(Lists.newArrayList())); }
@Override public List<String> getValues(Vertex vertex, String propertyName) { List<String> result = new ArrayList<>(); vertex.vertices(Direction.BOTH, relations).forEachRemaining(targetVertex -> { List<String> values = super.getValues(targetVertex, propertyName); values.forEach(result::add); }); return result; }
RelatedMultiValuePropertyGetter extends MultiValuePropertyGetter { @Override public List<String> getValues(Vertex vertex, String propertyName) { List<String> result = new ArrayList<>(); vertex.vertices(Direction.BOTH, relations).forEachRemaining(targetVertex -> { List<String> values = super.getValues(targetVertex, propertyName); values.forEach(result::add); }); return result; } }
RelatedMultiValuePropertyGetter extends MultiValuePropertyGetter { @Override public List<String> getValues(Vertex vertex, String propertyName) { List<String> result = new ArrayList<>(); vertex.vertices(Direction.BOTH, relations).forEachRemaining(targetVertex -> { List<String> values = super.getValues(targetVertex, propertyName); values.forEach(result::add); }); return result; } RelatedMultiValuePropertyGetter(String... relations); }
RelatedMultiValuePropertyGetter extends MultiValuePropertyGetter { @Override public List<String> getValues(Vertex vertex, String propertyName) { List<String> result = new ArrayList<>(); vertex.vertices(Direction.BOTH, relations).forEachRemaining(targetVertex -> { List<String> values = super.getValues(targetVertex, propertyName); values.forEach(result::add); }); return result; } RelatedMultiValuePropertyGetter(String... relations); @Override List<String> getValues(Vertex vertex, String propertyName); }
RelatedMultiValuePropertyGetter extends MultiValuePropertyGetter { @Override public List<String> getValues(Vertex vertex, String propertyName) { List<String> result = new ArrayList<>(); vertex.vertices(Direction.BOTH, relations).forEachRemaining(targetVertex -> { List<String> values = super.getValues(targetVertex, propertyName); values.forEach(result::add); }); return result; } RelatedMultiValuePropertyGetter(String... relations); @Override List<String> getValues(Vertex vertex, String propertyName);  }