### Question:
EmailModule extends BaseJFunkGuiceModule { @Provides @Singleton SetMultimap<String, MailAccount> provideEmailAddressPools(final Configuration config) { SetMultimap<String, MailAccount> result = HashMultimap.create(); Set<String> accountIdCache = newHashSet(); for (Entry<String, String> entry : config.entrySet()) { String key = entry.getKey(); Matcher matcher = MAIL_ACCOUNT_START_PATTERN.matcher(key); if (matcher.matches()) { String pool = matcher.group(1); String suffix = substringAfterLast(key, pool + '.'); matcher = MAIL_ACCOUNT_END_PATTERN.matcher(suffix); String accountId = matcher.find() ? substringBeforeLast(suffix, ".") : suffix; if (accountIdCache.contains(accountId)) { continue; } accountIdCache.add(accountId); String user = config.processPropertyValue(format(MAIL_USER_KEY_TEMPLATE, pool, accountId, accountId)); String password = config.processPropertyValue(format(MAIL_PASSWORD_KEY_TEMPLATE, pool, accountId)); String address = config.processPropertyValue(format(MAIL_ADDRESS_KEY_TEMPLATE, pool, accountId, accountId)); result.put(pool, new MailAccount(accountId, address, user, password)); } } return result; }    }### Answer:
@Test public void testProvideEmailAddressPools() { Configuration config = new Configuration(Charsets.UTF_8); config.put("mail.default.user", "defaultuser"); config.put("mail.default.password", "defaultpass"); config.put("mail.default.domain", "defdom.com"); config.put("mail.pool.pool1.test.account.1", ""); config.put("mail.pool.pool1.test.account.2", ""); config.put("mail.pool.pool1.test.account.3.user", "foo"); config.put("mail.pool.pool1.test.account.3.password", "foopass"); config.put("mail.pool.pool1.test.account.3.address", "foo@bar.de"); config.put("mail.pool.pool2.testaccount1", ""); config.put("mail.pool.pool2.testaccount2", ""); EmailModule module = new EmailModule(); SetMultimap<String, MailAccount> pools = module.provideEmailAddressPools(config); assertThat(pools.size()).isEqualTo(5); assertThat(pools.containsEntry("pool1", new MailAccount("test.account.1", "test.account.1@defdom.com", "defaultuser", "defaultpass"))).isTrue(); assertThat(pools.containsEntry("pool1", new MailAccount("test.account.2", "test.account.2@defdom.com", "defaultuser", "defaultpass"))).isTrue(); assertThat(pools.containsEntry("pool1", new MailAccount("test.account.3", "foo@bar.de", "foo", "foopass"))).isTrue(); assertThat(pools.containsEntry("pool2", new MailAccount("testaccount1", "testaccount1@defdom.com", "defaultuser", "defaultpass"))).isTrue(); assertThat(pools.containsEntry("pool2", new MailAccount("testaccount2", "testaccount2@defdom.com", "defaultuser", "defaultpass"))).isTrue(); }