use of org.apache.directory.api.ldap.model.entry.DefaultEntry in project directory-ldap-api by apache.
the class SchemaAwareEntryTest method testSize.
/**
* Test method for size()
*/
@Test
public void testSize() throws LdapException {
Entry entry = new DefaultEntry(exampleDn);
assertEquals(0, entry.size());
entry.add("ObjectClass", "top", "person");
entry.add("cn", "test");
entry.add("sn", "Test");
assertEquals(3, entry.size());
entry.clear();
assertEquals(0, entry.size());
}
use of org.apache.directory.api.ldap.model.entry.DefaultEntry in project directory-ldap-api by apache.
the class DefaultSchemaLoader method getEntry.
private Entry getEntry(SyntaxCheckerDescription syntaxCheckerDescription) {
Entry entry = new DefaultEntry();
entry.put(SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_TOP_OC, MetaSchemaConstants.META_SYNTAX_CHECKER_OC);
entry.put(MetaSchemaConstants.M_OID_AT, syntaxCheckerDescription.getOid());
entry.put(MetaSchemaConstants.M_FQCN_AT, syntaxCheckerDescription.getFqcn());
if (syntaxCheckerDescription.getBytecode() != null) {
entry.put(MetaSchemaConstants.M_BYTECODE_AT, Base64.decode(syntaxCheckerDescription.getBytecode().toCharArray()));
}
if (syntaxCheckerDescription.getDescription() != null) {
entry.put(MetaSchemaConstants.M_DESCRIPTION_AT, syntaxCheckerDescription.getDescription());
}
return entry;
}
use of org.apache.directory.api.ldap.model.entry.DefaultEntry in project directory-ldap-api by apache.
the class DefaultSchemaLoader method getEntry.
private Entry getEntry(LdapComparatorDescription comparatorDescription) {
Entry entry = new DefaultEntry();
entry.put(SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_TOP_OC, MetaSchemaConstants.META_COMPARATOR_OC);
entry.put(MetaSchemaConstants.M_OID_AT, comparatorDescription.getOid());
entry.put(MetaSchemaConstants.M_FQCN_AT, comparatorDescription.getFqcn());
if (comparatorDescription.getBytecode() != null) {
entry.put(MetaSchemaConstants.M_BYTECODE_AT, Base64.decode(comparatorDescription.getBytecode().toCharArray()));
}
if (comparatorDescription.getDescription() != null) {
entry.put(MetaSchemaConstants.M_DESCRIPTION_AT, comparatorDescription.getDescription());
}
return entry;
}
use of org.apache.directory.api.ldap.model.entry.DefaultEntry in project directory-ldap-api by apache.
the class DefaultSchemaLoader method getEntry.
private Entry getEntry(NormalizerDescription normalizerDescription) {
Entry entry = new DefaultEntry();
entry.put(SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_TOP_OC, MetaSchemaConstants.META_NORMALIZER_OC);
entry.put(MetaSchemaConstants.M_OID_AT, normalizerDescription.getOid());
entry.put(MetaSchemaConstants.M_FQCN_AT, normalizerDescription.getFqcn());
if (normalizerDescription.getBytecode() != null) {
entry.put(MetaSchemaConstants.M_BYTECODE_AT, Base64.decode(normalizerDescription.getBytecode().toCharArray()));
}
if (normalizerDescription.getDescription() != null) {
entry.put(MetaSchemaConstants.M_DESCRIPTION_AT, normalizerDescription.getDescription());
}
return entry;
}
use of org.apache.directory.api.ldap.model.entry.DefaultEntry in project directory-ldap-api by apache.
the class LdifUtilsTest method testReverseModifyDNSuperior.
/**
* Check that the correct reverse LDIF is produced for a modifyDn
* operation that moves and renames the entry while preserving the
* old rdn.
*
* @throws NamingException on error
*/
@Test
public void testReverseModifyDNSuperior() throws LdapException {
Dn dn = new Dn("cn=john doe, dc=example, dc=com");
Dn newSuperior = new Dn("ou=system");
Entry entry = new DefaultEntry(dn);
entry.add("objectClass", "person", "uidObject");
entry.add("cn", "john doe", "jack doe");
entry.add("sn", "doe");
entry.add("uid", "jdoe");
List<LdifEntry> reverseds = LdifRevertor.reverseMoveAndRename(entry, newSuperior, new Rdn("cn=jack doe"), false);
assertNotNull(reverseds);
assertEquals(1, reverseds.size());
LdifEntry reversed = reverseds.get(0);
assertEquals("cn=jack doe,ou=system", reversed.getDn().getName());
assertEquals(ChangeType.ModRdn, reversed.getChangeType());
assertFalse(reversed.isDeleteOldRdn());
assertEquals("cn=john doe", reversed.getNewRdn());
assertEquals("dc=example, dc=com", Strings.trim(reversed.getNewSuperior()));
assertNull(reversed.getEntry());
}
Aggregations