### 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 testCreateOneToMany() throws Exception { ManagedObjectPath<? extends ConfigurationClient, ? extends Configuration> path = ManagedObjectPath .emptyPath(); path = path.child(TestCfg.getTestOneToManyParentRelationDefinition(), "test-parent-1"); path = path.child(TestParentCfgDefn.getInstance() .getTestChildrenRelationDefinition(), "test-child-1"); DN actual = DNBuilder.create(path); DN expected = DN .valueOf("cn=test-child-1,cn=test children,cn=test-parent-1,cn=test parents,cn=config"); assertEquals(actual, expected); }
@Test public void testCreateOneToOne() throws Exception { ManagedObjectPath<? extends ConfigurationClient, ? extends Configuration> path = ManagedObjectPath .emptyPath(); SingletonRelationDefinition.Builder<TestChildCfgClient, TestChildCfg> b = new SingletonRelationDefinition.Builder<>( TestParentCfgDefn.getInstance(), "singleton-test-child", TestChildCfgDefn.getInstance()); final SingletonRelationDefinition<TestChildCfgClient, TestChildCfg> r2 = b.getInstance(); LDAPProfile.Wrapper wrapper = new LDAPProfile.Wrapper() { @Override public String getRelationRDNSequence(RelationDefinition<?, ?> r) { if (r == r2) { return "cn=singleton-test-child"; } else { return null; } } }; path = path.child(TestCfg.getTestOneToManyParentRelationDefinition(), "test-parent-1"); path = path.child(r2); LDAPProfile.getInstance().pushWrapper(wrapper); try { DN actual = DNBuilder.create(path); DN expected = DN .valueOf("cn=singleton-test-child,cn=test-parent-1,cn=test parents,cn=config"); assertEquals(actual, expected); } finally { LDAPProfile.getInstance().popWrapper(); } }
@Test public void testCreateOneToZeroOrOne() throws Exception { ManagedObjectPath<? extends ConfigurationClient, ? extends Configuration> path = ManagedObjectPath .emptyPath(); path = path.child(TestCfg.getTestOneToManyParentRelationDefinition(), "test-parent-1"); path = path.child(TestParentCfgDefn.getInstance() .getOptionalTestChildRelationDefinition()); DN actual = DNBuilder.create(path); DN expected = DN .valueOf("cn=optional test child,cn=test-parent-1,cn=test parents,cn=config"); assertEquals(actual, expected); }