### Question:
DNBuilder { public static DN create(ManagedObjectPath<?, ?> path) { return path.toDN(); } private  DNBuilder(); static DN create(ManagedObjectPath<?, ?> path); static DN create(ManagedObjectPath<?, ?> path, RelationDefinition<?, ?> relation);  }### Answer:
@Test public void createWithInstantiableRelationDefinition() throws Exception { ManagedObjectPath<?, ?> parentPath = ManagedObjectPath.emptyPath(). child(TestCfg.getTestOneToManyParentRelationDefinition(), "test-parent-1"); ManagedObjectPath<?, ?> childPath = parentPath.child(TestParentCfgDefn.getInstance(). getTestChildrenRelationDefinition(), "test-child-1"); assertEquals( DNBuilder.create(childPath), DN.valueOf("cn=test-child-1,cn=test children,cn=test-parent-1,cn=test parents,cn=config")); }
@Test public void createWithSingletonRelationDefinition() throws Exception { SingletonRelationDefinition.Builder<TestChildCfgClient, TestChildCfg> builder = new SingletonRelationDefinition.Builder<>( TestParentCfgDefn.getInstance(), "singleton-test-child", TestChildCfgDefn.getInstance()); final SingletonRelationDefinition<TestChildCfgClient, TestChildCfg> relationDef = builder.getInstance(); LDAPProfile.Wrapper wrapper = new LDAPProfile.Wrapper() { public String getRelationRDNSequence(RelationDefinition<?, ?> r) { return (r == relationDef) ? "cn=singleton-test-child" : null; } }; ManagedObjectPath<?, ?> path = ManagedObjectPath.emptyPath(). child(TestCfg.getTestOneToManyParentRelationDefinition(), "test-parent-1"); ManagedObjectPath<?, ?> childPath = path.child(relationDef); LDAPProfile.getInstance().pushWrapper(wrapper); try { assertEquals( DNBuilder.create(childPath), DN.valueOf("cn=singleton-test-child,cn=test-parent-1,cn=test parents,cn=config")); } finally { LDAPProfile.getInstance().popWrapper(); } }
@Test public void createWithOptionalRelationDefinition() throws Exception { ManagedObjectPath<?, ?> path = ManagedObjectPath .emptyPath().child(TestCfg.getTestOneToManyParentRelationDefinition(), "test-parent-1"); ManagedObjectPath<?, ?> childPath = path.child(TestParentCfgDefn.getInstance().getOptionalTestChildRelationDefinition()); assertEquals( DNBuilder.create(childPath), DN.valueOf("cn=optional test child,cn=test-parent-1,cn=test parents,cn=config")); }