@Test public void getValuesReturnsTheDisplayNamesOfAllTheAltNames() throws Exception { String displayName1 = "displayName1"; String displayName2 = "displayName2"; AltNames altNames = new AltNames(); altNames.list = Lists.newArrayList(new AltName("nameType", displayName1), new AltName("nameType", displayName2)); String altNamesPropValue = new ObjectMapper().writeValueAsString(altNames); Vertex vertex = vertex().withProperty(PROPERTY_NAME, altNamesPropValue).build(); AltNameFacetDescription instance = new AltNameFacetDescription("facetName", PROPERTY_NAME); List<String> values = instance.getValues(vertex); assertThat(values, containsInAnyOrder(displayName1, displayName2)); }
@Override public List<String> getValues(Vertex vertex) { List<String> values = Lists.newArrayList(); VertexProperty<String> property = vertex.property(propertyName); if (property.isPresent()) { String value = property.value(); try { AltNames altNames = objectMapper.readValue(value, AltNames.class); altNames.list.forEach(altName -> values.add(altName.getDisplayName())); } catch (IOException e) { LOG.error("Could not convert '{}'", value); LOG.error("Exception throw.", e); } } return values; }
AltNameFacetDescription extends AbstractFacetDescription { @Override public List<String> getValues(Vertex vertex) { List<String> values = Lists.newArrayList(); VertexProperty<String> property = vertex.property(propertyName); if (property.isPresent()) { String value = property.value(); try { AltNames altNames = objectMapper.readValue(value, AltNames.class); altNames.list.forEach(altName -> values.add(altName.getDisplayName())); } catch (IOException e) { LOG.error("Could not convert '{}'", value); LOG.error("Exception throw.", e); } } return values; } }
AltNameFacetDescription extends AbstractFacetDescription { @Override public List<String> getValues(Vertex vertex) { List<String> values = Lists.newArrayList(); VertexProperty<String> property = vertex.property(propertyName); if (property.isPresent()) { String value = property.value(); try { AltNames altNames = objectMapper.readValue(value, AltNames.class); altNames.list.forEach(altName -> values.add(altName.getDisplayName())); } catch (IOException e) { LOG.error("Could not convert '{}'", value); LOG.error("Exception throw.", e); } } return values; } AltNameFacetDescription(String facetName, String propertyName); }
AltNameFacetDescription extends AbstractFacetDescription { @Override public List<String> getValues(Vertex vertex) { List<String> values = Lists.newArrayList(); VertexProperty<String> property = vertex.property(propertyName); if (property.isPresent()) { String value = property.value(); try { AltNames altNames = objectMapper.readValue(value, AltNames.class); altNames.list.forEach(altName -> values.add(altName.getDisplayName())); } catch (IOException e) { LOG.error("Could not convert '{}'", value); LOG.error("Exception throw.", e); } } return values; } AltNameFacetDescription(String facetName, String propertyName); @Override void filter(GraphTraversal<Vertex, Vertex> graphTraversal, List<FacetValue> facetValues); @Override List<String> getValues(Vertex vertex); }
AltNameFacetDescription extends AbstractFacetDescription { @Override public List<String> getValues(Vertex vertex) { List<String> values = Lists.newArrayList(); VertexProperty<String> property = vertex.property(propertyName); if (property.isPresent()) { String value = property.value(); try { AltNames altNames = objectMapper.readValue(value, AltNames.class); altNames.list.forEach(altName -> values.add(altName.getDisplayName())); } catch (IOException e) { LOG.error("Could not convert '{}'", value); LOG.error("Exception throw.", e); } } return values; } AltNameFacetDescription(String facetName, String propertyName); @Override void filter(GraphTraversal<Vertex, Vertex> graphTraversal, List<FacetValue> facetValues); @Override List<String> getValues(Vertex vertex); static final Logger LOG; }