VertexWrapper { public Map<String, Object> getPropertyMap() { Map<String, Object> props = new TreeMap<>(resourceComparator); for (String p : vertex.getPropertyKeys()) { String cleanName = propertyMapper.toCleanName(p, vertexType); if (! removedProperties.contains(cleanName)) { Object val = vertex.getProperty(p); if (propertyValueFormatters.containsKey(cleanName)) { val = propertyValueFormatters.get(cleanName).format(val); } props.put(cleanName, val); } } return props; } VertexWrapper(Vertex v, ResourceDefinition resourceDefinition);  VertexWrapper(Vertex v,
                         PropertyMapper mapper,
                         Map<String, PropertyValueFormatter> formatters); Vertex getVertex(); T getProperty(String name); void setProperty(String name, Object value); Collection<String> getPropertyKeys(); Map<String, Object> getPropertyMap(); void removeProperty(String name); boolean isPropertyRemoved(String name); String toString();  }
@Test public void testGetPropertyMap() { String testType = "testType"; Set<String> propertyKeys = new HashSet<>(); propertyKeys.add("Prefix.foo"); propertyKeys.add("Prefix.bar"); propertyKeys.add("foobar"); Vertex v = createMock(Vertex.class); PropertyMapper propertyMapper = createMock(PropertyMapper.class); PropertyValueFormatter formatter = createMock(PropertyValueFormatter.class); Map<String, PropertyValueFormatter> valueFormatters = new HashMap<>(); valueFormatters.put("foo", formatter); valueFormatters.put("bar", formatter); expect(v.<String>getProperty(Constants.ENTITY_TYPE_PROPERTY_KEY)).andReturn(testType); expect(v.getPropertyKeys()).andReturn(propertyKeys); expect(v.getProperty("Prefix.foo")).andReturn("Prefix.foo:Value"); expect(v.getProperty("Prefix.bar")).andReturn("Prefix.bar:Value"); expect(v.getProperty("foobar")).andReturn("foobarValue"); expect(propertyMapper.toCleanName("Prefix.bar", testType)).andReturn("bar"); expect(propertyMapper.toCleanName("Prefix.foo", testType)).andReturn("foo"); expect(propertyMapper.toCleanName("foobar", testType)).andReturn("foobar"); expect(formatter.format("Prefix.foo:Value")).andReturn("fooValue"); expect(formatter.format("Prefix.bar:Value")).andReturn("barValue"); replay(v, propertyMapper, formatter); VertexWrapper vWrapper = new VertexWrapper(v, propertyMapper, valueFormatters); Map<String, Object> resultMap = vWrapper.getPropertyMap(); assertEquals(resultMap.size(), 3); Iterator<Map.Entry<String, Object>> iter = resultMap.entrySet().iterator(); Map.Entry<String, Object> entry1 = iter.next(); assertEquals(entry1.getKey(), "bar"); assertEquals(entry1.getValue(), "barValue"); Map.Entry<String, Object> entry2 = iter.next(); assertEquals(entry2.getKey(), "foo"); assertEquals(entry2.getValue(), "fooValue"); Map.Entry<String, Object> entry3 = iter.next(); assertEquals(entry3.getKey(), "foobar"); assertEquals(entry3.getValue(), "foobarValue"); verify(v, propertyMapper, formatter); }