LDAP-271: Now propertly handling setting values to null and updating when using ODM.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user