LdapMapper { public Set<String> getAttributeIds(Class<?> clazz) { final List<Field> fields = ReflectionUtils.getAllFields(clazz); log.trace("Mapping {} fields: {}", clazz.getName(), fields); final Builder<String> attributeIds = ImmutableSet.builder(); for (final Field field : fields) { final LdapAttribute ldapAttribute = field.getAnnotation(LdapAttribute.class); if (ldapAttribute == null) continue; attributeIds.addAll(ImmutableList.copyOf(ldapAttribute.value())); } return attributeIds.build(); } LdapMapper(); LdapMapping getMapping(final Class<?> clazz); Entry toEntry(Object obj, String baseDn); Set<String> getAttributeIds(Class<?> clazz); T fromEntry(Entry entry, Class<? extends T> entityClass); String getDn(final String rdnValue, final Class<?> clazz, final String baseDn); @Nonnull String getDn(final Object obj, final String baseDn); @Nullable String getRdnValue(final Object obj); ModifyRequest createModifyRequest(final Entry existingEntry, final T existing, final T up);  }
@Test public void includesSuperClassAttributes() throws LdapInvalidAttributeValueException, LdapInvalidDnException { final LdapMapper<SocialPerson> mapper = new LdapMapper<>(); final Set<String> expectedAttributeIds = ImmutableSet.of( "uid", "uniqueIdentifier", "gn", "givenName", "sn", "cn", "userPassword", "mail", "mobile", "telephoneNumber", "street", "postalCode", "l", "st", "c", "primaryMail", "photoId", "gender", "fbId", "facebookId", "facebookUsername", "fbUser", "fbAccessToken", "twitterId", "twitterScreenName", "virtualMail", "nickname", "primaryShippingAddress" ); final Set<String> attributeIds = mapper.getAttributeIds(SocialPerson.class); log.info("Attribute IDs of SocialPerson: {}", attributeIds); assertThat(attributeIds, Matchers.hasItems(expectedAttributeIds.toArray(new String[] {}))); }