LDAP-271: Now propertly handling setting values to null and updating when using ODM.

This commit is contained in:
Mattias Hellborg Arthursson
2013-10-22 08:51:20 +02:00
parent c4eb4fc9a2
commit 27593ac973
2 changed files with 20 additions and 0 deletions

View File

@@ -228,6 +228,8 @@ public class DefaultObjectDirectoryMapper implements ObjectDirectoryMapper {
// Convert the field value to the required type and write it into the JNDI context
context.setAttributeValue(attributeInfo.getName().toString(), converterManager.convert(fieldValue,
attributeInfo.getSyntax(), targetClass));
} else {
context.setAttributeValue(attributeInfo.getName().toString(), null);
}
}

View File

@@ -31,6 +31,7 @@ import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.springframework.ldap.query.LdapQueryBuilder.query;
@@ -164,4 +165,21 @@ public class LdapTemplateOdmWithNoDnAnnotationsITest extends AbstractLdapTemplat
assertTrue(true);
}
}
/**
* Test case for Jira LDAP-271.
*/
@Test
public void testLdap271() {
Person person = tested.findOne(query()
.where("cn").is("Some Person3"), Person.class);
// Perform test
person.setTelephoneNumber(null);
tested.update(person);
person = tested.findOne(query()
.where("cn").is("Some Person3"), Person.class);
assertNull("TelephoneNumber should be null", person.getTelephoneNumber());
}
}