### Question:
DerivedPropertyValueGetter implements PropertyValueGetter { @Override public List<String> getValues(Vertex vertex, String propertyName) { List<String> result = new ArrayList<>(); vertex.vertices(Direction.BOTH, relations).forEachRemaining(targetVertex -> { targetVertex.vertices(Direction.BOTH, relationNames).forEachRemaining(finalVertex -> { if (finalVertex.property(propertyName).isPresent()) { result.add((String) finalVertex.property(propertyName).value()); } }); }); return result; } DerivedPropertyValueGetter(String[] relationNames, String... relations); @Override List<String> getValues(Vertex vertex, String propertyName);  }### Answer:
@Test public void getValuesReturnsEmptyListIfThePropertyIsNotPresent() { DerivedPropertyValueGetter instance = new DerivedPropertyValueGetter(RELATIONS, RELATION_NAME); GraphTraversal<Vertex, Vertex> traversal = newGraph() .withVertex("finalTarget1", v -> v.withProperty(PROPERTY_NOT_PRESENT, "value1")) .withVertex("finalTarget2", v -> v.withProperty(PROPERTY_NOT_PRESENT, "value2")) .withVertex("target1", v -> v.withOutgoingRelation(RELATION_NAME, "finalTarget1")) .withVertex("target2", v -> v.withOutgoingRelation(RELATION_NAME, "finalTarget2")) .withVertex(v -> v.withOutgoingRelation(RELATIONS[0], "target1")) .withVertex(v -> v.withOutgoingRelation(RELATIONS[0], "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())); }
@Test public void getValuesReturnsListOfStringsIfThePropertyIsPresent() { DerivedPropertyValueGetter instance = new DerivedPropertyValueGetter(RELATIONS, RELATION_NAME); GraphTraversal<Vertex, Vertex> traversal = newGraph() .withVertex("finalTarget1", v -> v.withProperty(PROPERTY, "value1")) .withVertex("target1", v -> v.withOutgoingRelation(RELATIONS[0], "finalTarget1")) .withVertex(v -> v.withOutgoingRelation(RELATION_NAME, "target1")) .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.get(0), contains(is("value1"))); }