@Override
    public ExecuteContext doBefore(ExecuteContext context) {
        DatabaseInfo databaseInfo = getDataBaseInfo(context);
        String database = databaseInfo.getDatabaseName();
        Query query = (Query) context.getArguments()[0];
        String sql = query.toString((ParameterList) context.getArguments()[1]);
        handleWriteOperationIfWriteDisabled(sql, database,
                DatabaseWriteProhibitionManager.getOpenGaussProhibitionDatabases(), context);
        return context;
    }
@Test
    public void testDoBefore() throws Exception {
        // Database write prohibition switch turned off
        GLOBAL_CONFIG.setEnableOpenGaussWriteProhibition(false);
        ExecuteContext context = ExecuteContext.forMemberMethod(queryExecutor, methodMock, argument, null, null);
        queryExecutorImplInterceptor.before(context);
        Assert.assertNull(context.getThrowableOut());

        // The database write prohibition switch is turned off, and the write prohibition database set contains the
        // intercepted database
        Set<String> databases = new HashSet<>();
        databases.add("database-test");
        GLOBAL_CONFIG.setOpenGaussDatabases(databases);
        queryExecutorImplInterceptor.before(context);
        Assert.assertNull(context.getThrowableOut());

        // The database write prohibition switch is turned on, and the write prohibition database collection contains
        // the intercepted databases
        GLOBAL_CONFIG.setEnableOpenGaussWriteProhibition(true);
        context = ExecuteContext.forMemberMethod(queryExecutor, methodMock, argument, null, null);
        queryExecutorImplInterceptor.before(context);
        Assert.assertEquals("Database prohibit to write, database: database-test",
                context.getThrowableOut().getMessage());

        // The database write prohibition switch is turned on, and the write prohibition database collection contains
        // the intercepted database. SQL does not perform write operations
        Query readQuery = new BatchedQuery(new NativeQuery(READ_SQL, null),
                null, 0, 0, false);
        context = ExecuteContext.forMemberMethod(queryExecutor, methodMock,
                new Object[]{readQuery, null, null, null, null, null, null}, null, null);
        queryExecutorImplInterceptor.before(context);
        Assert.assertNull(context.getThrowableOut());

        // The database write prohibition switch is turned on, and the write prohibition database collection does not
        // contain the intercepted database
        GLOBAL_CONFIG.setOpenGaussDatabases(new HashSet<>());
        context = ExecuteContext.forMemberMethod(queryExecutor, methodMock, argument, null, null);
        queryExecutorImplInterceptor.before(context);
        Assert.assertNull(context.getThrowableOut());
    }