### Question:
MapperUtils { public static String buildUserId(String userId, String domain) { Optional<String> optionalDomain = Optional.of(domain); return String.format("%s%s", userId, optionalDomain.map(it -> String.format("@%s", it)) .orElse("")) .toLowerCase(); }  static Function<String, String> getRdnMappingFunction(final String key); static Stream<String> mapAttributes(String[] elements, Function<String, String> mapper); static String getAttribute(DirContextAdapter adapter, String... names); static String stripBaseFromDn(String dn, String base); static String appendToDn(String dn, String... suffixes); static String buildGroupName(String name, String domain); static String buildGroupName(String name, AcmLdapSyncConfig ldapSyncConfig); static String buildUserId(String userId, String domain); static String buildUserId(String userId, AcmLdapSyncConfig ldapSyncConfig); static byte[] encodeUTF16LE(String str); static String generatePassword(int minLength); static String buildPrincipalName(String principal, @Nullable String userPrefix, @Nullable String userDomain); static final Function<DirContextAdapter, LocalDate> convertFileTimeTimestampToDate; static final Function<DirContextAdapter, LocalDate> calculatePasswordExpirationDateByShadowAccount; static final Function<String, BasicAttribute> openLdapPasswordToAttribute; static final Function<String, BasicAttribute> openLdapCurrentPasswordToAttribute; static final Function<String, BasicAttribute> activeDirectoryPasswordToAttribute; }### Answer:
@Test public void testUserIdMoreThen20Chars() { AcmLdapSyncConfig config = new AcmLdapSyncConfig(); config.setUserPrefix("dco"); config.setUserDomain("armedia.com"); config.setUserIdAttributeName("sAMAccountName"); String userId = MapperUtils.buildUserId("veryyylongusername", config); assertEquals("dco.veryyylonguserna@armedia.com", userId); }
@Test public void testUserIdLessThen20Chars() { AcmLdapSyncConfig config = new AcmLdapSyncConfig(); config.setUserPrefix("dco"); config.setUserDomain("armedia.com"); config.setUserIdAttributeName("sAMAccountName"); String userId = MapperUtils.buildUserId("ann-acm", config); assertEquals("dco.ann-acm@armedia.com", userId); }
@Test public void testUserIdUidAttribute() { AcmLdapSyncConfig config = new AcmLdapSyncConfig(); config.setUserPrefix("dco"); config.setUserDomain("armedia.com"); config.setUserIdAttributeName("uid"); String userId = MapperUtils.buildUserId("veryyyyyylongusername", config); assertEquals("veryyyyyylongusername@armedia.com", userId); }