@Override
    public Map<Grantee, ShardingSpherePrivileges> build(final AuthorityRuleConfiguration ruleConfig) {
        Map<ShardingSphereUser, Collection<String>> userDatabaseMappings = convertUserDatabases();
        return ruleConfig.getUsers().stream().collect(Collectors.toMap(ShardingSphereUser::getGrantee, each -> new DatabasePermittedPrivileges(getUserDatabases(each, userDatabaseMappings))));
    }
@Test
    void assertBuild() {
        Properties props = PropertiesBuilder.build(new Property("user-database-mappings", "root@localhost=*, user1@127.0.0.1=sys_db, user1@=foo_db, user1@=bar_db, user2@=*"));
        PrivilegeProvider provider = TypedSPILoader.getService(PrivilegeProvider.class, "DATABASE_PERMITTED", props);
        AuthorityRuleConfiguration ruleConfig = new AuthorityRuleConfiguration(Arrays.asList(
                new ShardingSphereUser("root", "", "localhost"),
                new ShardingSphereUser("user1", "", "127.0.0.1"),
                new ShardingSphereUser("user1", "", "%"),
                new ShardingSphereUser("user3", "", "%")), mock(AlgorithmConfiguration.class), Collections.emptyMap(), null);
        Map<Grantee, ShardingSpherePrivileges> actual = provider.build(ruleConfig);
        assertThat(actual.size(), is(4));
        assertTrue(actual.get(new Grantee("root", "localhost")).hasPrivileges("sys_db"));
        assertTrue(actual.get(new Grantee("user1", "127.0.0.1")).hasPrivileges("sys_db"));
        assertTrue(actual.get(new Grantee("user1", "127.0.0.1")).hasPrivileges("foo_db"));
        assertTrue(actual.get(new Grantee("user1", "%")).hasPrivileges("bar_db"));
        assertFalse(actual.get(new Grantee("user1", "%")).hasPrivileges("sys_db"));
        assertFalse(actual.get(new Grantee("user3", "%")).hasPrivileges("sys_db"));
    }