OPENDJ-1342 Migrate AVA, RDN, and DN classes: Fix change in behaviour for DN.toString()
DN.toString() now returns the raw dn provided in DN.valueOf()
while it used to return a somewhat normalized view of the raw DN.
| | |
| | | // No differences expected. |
| | | assertThat(Entries.diffEntries(original, expectedEntry).getModifications()).isEmpty(); |
| | | |
| | | assertThat(srEntry.getName().toString()).isEqualTo("uid=user.1,o=test"); |
| | | assertThat((Object) srEntry.getName()).isEqualTo(DN.valueOf("uid=user.1,o=test")); |
| | | assertThat(srEntry.getAttributeCount()).isEqualTo(7); |
| | | assertThat(srEntry.getAttribute("description").firstValueAsString()).isEqualTo( |
| | | "This is the description for Aaren Atp."); |
| | |
| | | connection.searchSingleEntry(Requests.newSearchRequest( |
| | | "uid=user.1, o=test", SearchScope.BASE_OBJECT, "(uid=user.1)")); |
| | | assertThat(srEntry).isNotNull(); |
| | | assertThat(srEntry.getName().toString()).isEqualTo("uid=user.1,o=test"); |
| | | assertThat((Object) srEntry.getName()).isEqualTo(DN.valueOf("uid=user.1,o=test")); |
| | | |
| | | connection.close(); |
| | | } |
| | |
| | | assertThat(reader.isEntry()).isTrue(); |
| | | final SearchResultEntry entry = reader.readEntry(); |
| | | assertThat(entry).isNotNull(); |
| | | assertThat(entry.getName().toString()).isEqualTo("uid=user.1,o=test"); |
| | | assertThat((Object) entry.getName()).isEqualTo(DN.valueOf("uid=user.1,o=test")); |
| | | assertThat(reader.hasNext()).isFalse(); |
| | | } |
| | | |
| | |
| | | @Test(dataProvider = "testDNs") |
| | | public void testToString(String rawDN, String unused, String stringDN) throws Exception { |
| | | DN dn = DN.valueOf(rawDN); |
| | | assertEquals(dn.toString(), stringDN); |
| | | assertEquals(dn.toString(), rawDN); |
| | | } |
| | | |
| | | |
| | |
| | | @SuppressWarnings("javadoc") |
| | | public final class TestSubtreeSpecification extends SubtreeSpecificationTestCase { |
| | | |
| | | /** Cached root DN. */ |
| | | private DN rootDN = DN.rootDN(); |
| | | |
| | | @DataProvider |
| | | public Object[][] valueOfData() { |
| | | return new Object[][] { |
| | |
| | | "{ base \"dc=sun,dc=com\" }" }, |
| | | { "{base \"dc=sun, dc=com\"}", |
| | | "{ base \"dc=sun,dc=com\" }" }, |
| | | { "{ base \"dc=sun, dc=com\", " + "specificationFilter item:ds-config-rootDN }", |
| | | "{ base \"dc=sun,dc=com\", " + "specificationFilter item:ds-config-rootDN }" }, |
| | | { "{ base \"dc=sun, dc=com\", specificationFilter item:ds-config-rootDN }", |
| | | "{ base \"dc=sun, dc=com\", specificationFilter item:ds-config-rootDN }" }, |
| | | { "{ base \"dc=sun, dc=com\", minimum 0 , maximum 10, " |
| | | + "specificExclusions {chopBefore:\"o=abc\", " |
| | | + "chopAfter:\"o=xyz\"} , specificationFilter not:not:item:foo }", |
| | |
| | | |
| | | @Test(dataProvider = "valueOfData") |
| | | public void testValueOf(String specification, String expected) throws Exception { |
| | | SubtreeSpecification ss = SubtreeSpecification.valueOf(rootDN, specification); |
| | | SubtreeSpecification ss = SubtreeSpecification.valueOf(DN.rootDN(), specification); |
| | | assertEquals(ss.toString(), expected); |
| | | } |
| | | |
| | |
| | | @Test(dataProvider = "isWithinScopeData") |
| | | public void testIsWithinScope(String dnString, String value, boolean expected) throws Exception { |
| | | DN dn = DN.valueOf(dnString); |
| | | SubtreeSpecification ss = SubtreeSpecification.valueOf(rootDN, value); |
| | | SubtreeSpecification ss = SubtreeSpecification.valueOf(DN.rootDN(), value); |
| | | assertEquals(ss.isWithinScope(createEntry(dn, getObjectClasses())), expected); |
| | | } |
| | | } |