MorphiaPropertyResolver implements PropertyResolver { @Override public String resolve(String fieldName, Class<?> entityClass) { Iterable<String> fieldNames = splitter.split(fieldName); List<String> resolved = Lists.newArrayList(); Class<?> lastClass = entityClass; for (String name : fieldNames) { MappedField mappedField = mapper.getMappedClass(lastClass) .getMappedFieldByJavaField(name); if (mappedField != null) { lastClass = mappedField.getConcreteType(); resolved.add(mappedField.getNameToStore()); } else { resolved.add(name); } } return joiner.join(resolved); } MorphiaPropertyResolver();  MorphiaPropertyResolver(Mapper mapper); @Override String resolve(String fieldName, Class<?> entityClass);  }
@Test public void resolve_id() { assertEquals("_id", resolver.resolve("id", TestMappedClass.class)); }
@Test public void resolve_name() { assertEquals("name", resolver.resolve("name", TestMappedClass.class)); }
@Test public void resolve_thisProperty() { assertEquals("thatProperty", resolver.resolve("thisProperty", TestMappedClass.class)); }
@Test public void resolve_t() { assertEquals("t", resolver.resolve("t", TestMappedClass.class)); assertEquals("t.a", resolver.resolve("t.a", TestMappedClass.class)); assertEquals("t.bee", resolver.resolve("t.b", TestMappedClass.class)); }
@Test public void resolve_t2() { assertEquals("teatwo", resolver.resolve("t2", TestMappedClass.class)); assertEquals("teatwo.a", resolver.resolve("t2.a", TestMappedClass.class)); assertEquals("teatwo.bee", resolver.resolve("t2.b", TestMappedClass.class)); }