DnParser { public static String getValue(final String dn, final String name) { final Collection<String> values = getValues(dn, name); if (values.isEmpty()) { return ""; } return values.iterator().next(); } private  DnParser(); static Collection<String> getValues(final String dn, final String name); static String getValue(final String dn, final String name); static String substring(final String dn, final int beginIndex); static String substring(final String dn, final int beginIndex, final int endIndex); static List<LdapAttribute> convertDnToAttributes(final String dn);  }
@Test(groups = "dnParser", dataProvider = "DNs") public void testParsing(final String dn, final String name, final String value) throws Exception { Assert.assertEquals(DnParser.getValue(dn, name), value); }
@Test(groups = "dnParser", dataProvider = "invalidDNs") public void testInvalidParsing(final String dn) throws Exception { try { DnParser.getValue(dn, ""); Assert.fail("Should have thrown IllegalArgumentException"); } catch (Exception e) { Assert.assertEquals(e.getClass(), IllegalArgumentException.class); } }