@Override
    protected ExecuteContext doBefore(ExecuteContext context) {
        String database = getDataBaseInfo(context).getDatabaseName();
        if (!DatabaseWriteProhibitionManager.getMySqlProhibitionDatabases().contains(database)) {
            return context;
        }
        List<String> sqlList = (List) context.getArguments()[PARAM_INDEX];
        for (String sql : sqlList) {
            if (SqlParserUtils.isWriteOperation(sql)) {
                DatabaseController.disableDatabaseWriteOperation(database, context);
                return context;
            }
        }
        return context;
    }
@Test
    public void testDoBefore() throws Exception {
        // the database write prohibition switch is disabled
        globalConfig.setEnableMySqlWriteProhibition(false);
        context = ExecuteContext.forMemberMethod(protocolMock, methodMock, argument, null, null);
        interceptor.before(context);
        Assert.assertNull(context.getThrowableOut());

        // The database write prohibition function is disabled.
        // The write prohibition database set contains the database that is blocked
        Set<String> databases = new HashSet<>();
        databases.add("database-test");
        globalConfig.setMySqlDatabases(databases);
        interceptor.before(context);
        Assert.assertNull(context.getThrowableOut());

        // The database write prohibition switch is enabled, and the database set contains the database that is blocked
        globalConfig.setEnableMySqlWriteProhibition(true);
        context = ExecuteContext.forMemberMethod(protocolMock, methodMock, argument, null, null);
        interceptor.before(context);
        Assert.assertEquals("Database prohibit to write, database: database-test",
                context.getThrowableOut().getMessage());

        //The database write prohibition switch is turned on, the sql does not write,
        // and the database set contains the blocked database
        sqlList = new ArrayList<>();
        argument = new Object[]{null, null, sqlList};
        context = ExecuteContext.forMemberMethod(protocolMock, methodMock, argument, null, null);
        interceptor.before(context);
        Assert.assertNull(context.getThrowableOut());

        //The database write prohibition switch is enabled. The database set does not contain the database that is blocked
        sqlList.add("INSERT INTO table (name) VALUES ('test')");
        globalConfig.setMySqlDatabases(new HashSet<>());
        context = ExecuteContext.forMemberMethod(protocolMock, methodMock, argument, null, null);
        interceptor.before(context);
        Assert.assertNull(context.getThrowableOut());
    }