@Override
    public void execute(final ConnectionSession connectionSession) {
        String databaseName = SQLUtils.getExactlyValue(useStatement.getDatabase());
        AuthorityRule authorityRule = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData().getSingleRule(AuthorityRule.class);
        AuthorityChecker authorityChecker = new AuthorityChecker(authorityRule, connectionSession.getConnectionContext().getGrantee());
        ShardingSpherePreconditions.checkState(ProxyContext.getInstance().databaseExists(databaseName) && authorityChecker.isAuthorized(databaseName),
                () -> new UnknownDatabaseException(databaseName));
        connectionSession.setCurrentDatabaseName(databaseName);
    }
@Test
    void assertExecuteUseStatementBackendHandler() {
        MySQLUseStatement useStatement = mock(MySQLUseStatement.class);
        when(useStatement.getDatabase()).thenReturn(String.format(DATABASE_PATTERN, 0));
        ContextManager contextManager = mockContextManager();
        when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
        when(ProxyContext.getInstance().databaseExists("db_0")).thenReturn(true);
        UseDatabaseExecutor executor = new UseDatabaseExecutor(useStatement);
        when(connectionSession.getConnectionContext().getGrantee()).thenReturn(null);
        executor.execute(connectionSession);
        verify(connectionSession).setCurrentDatabaseName(anyString());
    }