### Question:
MongodbSerializer implements Visitor<Object, Void> { @Override public Object visit(Constant<?> expr, Void context) { if (Enum.class.isAssignableFrom(expr.getType())) { @SuppressWarnings("unchecked") Constant<? extends Enum<?>> expectedExpr = (Constant<? extends Enum<?>>) expr; return expectedExpr.getConstant().name(); } else { return expr.getConstant(); } }  Object handle(Expression<?> expression); DBObject toSort(List<OrderSpecifier<?>> orderBys); @Override Object visit(Constant<?> expr, Void context); @Override Object visit(TemplateExpression<?> expr, Void context); @Override Object visit(FactoryExpression<?> expr, Void context); @SuppressWarnings("unchecked") @Override Object visit(Operation<?> expr, Void context); @Override String visit(Path<?> expr, Void context); @Override Object visit(SubQueryExpression<?> expr, Void context); @Override Object visit(ParamExpression<?> expr, Void context);  }### Answer:
@Test public void paths() { QUser user = QUser.user; assertEquals("user", serializer.visit(user, null)); assertEquals("addresses", serializer.visit(user.addresses, null)); assertEquals("addresses", serializer.visit(user.addresses.any(), null)); assertEquals("addresses.street", serializer.visit(user.addresses.any().street, null)); assertEquals("firstName", serializer.visit(user.firstName, null)); }
@Test public void propertyAnnotation() { QDummyEntity entity = QDummyEntity.dummyEntity; assertEquals("prop", serializer.visit(entity.property, null)); }
@Test public void indexedAccess() { QUser user = QUser.user; assertEquals("addresses.0.street", serializer.visit(user.addresses.get(0).street, null)); }
@Test public void path() { QUser user = QUser.user; assertEquals("firstName", serializer.visit(user.firstName, null)); assertEquals("firstName", serializer.visit(user.as(QUser.class).firstName, null)); assertEquals("mainAddress.street", serializer.visit(user.mainAddress().street, null)); assertEquals("mainAddress.street", serializer.visit(user.mainAddress().as(QAddress.class).street, null)); }