added ITs

This commit is contained in:
Konrad Windszus
2016-10-26 10:28:09 +02:00
committed by Rob Winch
parent 8dd61f9b6a
commit dd73c9c0a2
7 changed files with 77 additions and 44 deletions

View File

@@ -16,11 +16,11 @@
package org.springframework.ldap.odm.core;
import javax.naming.Name;
import org.springframework.LdapDataEntry;
import org.springframework.ldap.filter.Filter;
import javax.naming.Name;
/**
* The ObjectDirectoryMapper keeps track of managed class metadata and is used by {@link org.springframework.ldap.core.LdapTemplate}
* to map to/from entity objects annotated with the annotations specified in the {@link org.springframework.ldap.odm.annotations}
@@ -88,13 +88,11 @@ public interface ObjectDirectoryMapper {
*/
String attributeFor(Class<?> clazz, String fieldName);
/**
* Check if the specified class is already managed by this instance; if not, check the metadata and add the class to the
* managed classes.
/** Check if the specified class is already managed by this instance; if not, check the metadata and add the class to the managed
* classes.
*
* @param clazz the class to manage.
* @return all relevant attribute names used in the given class.
* @throws org.springframework.ldap.NamingException on error.
*/
* @return all relevant attribute names used in the given class (either for reading from LDAP or for writing to LDAP or both)
* @throws org.springframework.ldap.NamingException on error. */
String[] manageClass(Class<?> clazz);
}

View File

@@ -70,7 +70,7 @@ public class DefaultObjectDirectoryMapper implements ObjectDirectoryMapper {
public DefaultObjectDirectoryMapper() {
this.converterManager = createDefaultConverterManager();
converterManager = createDefaultConverterManager();
}
private static ConverterManager createDefaultConverterManager() {
@@ -117,19 +117,19 @@ public class DefaultObjectDirectoryMapper implements ObjectDirectoryMapper {
Set<String> managedAttributeNames = new HashSet<String>();
// extract all relevant attributes
for (Field field : entityData.metaData) {
AttributeMetaData attributeMetaData = entityData.metaData.getAttribute(field);
// skip transient field
if (attributeMetaData.isTransient()) {
continue;
}
String[] attributesOfField = attributeMetaData.getAttributes();
if (attributesOfField != null && attributesOfField.length > 0) {
// attribute names are either given through annotation
managedAttributeNames.addAll(Arrays.asList(attributesOfField));
} else {
// or implicitly by relying on the field name
managedAttributeNames.add(field.getName());
}
AttributeMetaData attributeMetaData = entityData.metaData.getAttribute(field);
// skip transient fields
if (attributeMetaData.isTransient()) {
continue;
}
String[] attributesOfField = attributeMetaData.getAttributes();
if (attributesOfField != null && attributesOfField.length > 0) {
// attribute names are either given through annotation
managedAttributeNames.addAll(Arrays.asList(attributesOfField));
} else {
// or implicitly by relying on the field name
managedAttributeNames.add(field.getName());
}
}
// always add the mandatory attribute objectclass (which is always used for the mapping)
managedAttributeNames.add(OBJECT_CLASS_ATTRIBUTE);

View File

@@ -114,8 +114,8 @@ public class DefaultObjectDirectoryMapperTest {
String expectedDnAttributeName,
boolean expectedBinary,
boolean expectedTransient,
boolean expectedList,
boolean expectedReadOnly) {
boolean expectedList,
boolean expectedReadOnly) {
for (Field field : entityData.metaData) {
if (fieldName.equals(field.getName())) {