@Test public void getValuesReturnsListOfStringsIfThePropertyIsPresent() { MultiValuePropertyGetter instance = new MultiValuePropertyGetter(); GraphTraversal<Vertex, Vertex> traversal = newGraph() .withVertex(v -> v.withProperty(PROPERTY, "[\"value2\", \"value3\"]").withTimId("2")) .build().traversal().V(); List<List<String>> results = traversal.toList().stream() .map(v -> instance.getValues(v, PROPERTY)).collect(toList()); assertThat(results.get(0), contains(is("value2"), is("value3"))); }
@Override public List<String> getValues(Vertex vertex, String propertyName) { if (vertex.property(propertyName).isPresent()) { final String value = (String) vertex.property(propertyName).value(); try { return (List<String>) mapper.readValue(value, List.class); } catch (IOException e) { LOG.error("'{}' is not a valid multi valued field", value); } } return Lists.newArrayList(); }
MultiValuePropertyGetter implements PropertyValueGetter { @Override public List<String> getValues(Vertex vertex, String propertyName) { if (vertex.property(propertyName).isPresent()) { final String value = (String) vertex.property(propertyName).value(); try { return (List<String>) mapper.readValue(value, List.class); } catch (IOException e) { LOG.error("'{}' is not a valid multi valued field", value); } } return Lists.newArrayList(); } }
MultiValuePropertyGetter implements PropertyValueGetter { @Override public List<String> getValues(Vertex vertex, String propertyName) { if (vertex.property(propertyName).isPresent()) { final String value = (String) vertex.property(propertyName).value(); try { return (List<String>) mapper.readValue(value, List.class); } catch (IOException e) { LOG.error("'{}' is not a valid multi valued field", value); } } return Lists.newArrayList(); }  }
MultiValuePropertyGetter implements PropertyValueGetter { @Override public List<String> getValues(Vertex vertex, String propertyName) { if (vertex.property(propertyName).isPresent()) { final String value = (String) vertex.property(propertyName).value(); try { return (List<String>) mapper.readValue(value, List.class); } catch (IOException e) { LOG.error("'{}' is not a valid multi valued field", value); } } return Lists.newArrayList(); }  @Override List<String> getValues(Vertex vertex, String propertyName); }
MultiValuePropertyGetter implements PropertyValueGetter { @Override public List<String> getValues(Vertex vertex, String propertyName) { if (vertex.property(propertyName).isPresent()) { final String value = (String) vertex.property(propertyName).value(); try { return (List<String>) mapper.readValue(value, List.class); } catch (IOException e) { LOG.error("'{}' is not a valid multi valued field", value); } } return Lists.newArrayList(); }  @Override List<String> getValues(Vertex vertex, String propertyName); static final Logger LOG; }