@Override
    public Object intercept(final Invocation invocation) throws Throwable {
        Object[] args = invocation.getArgs();
        MappedStatement ms = (MappedStatement) args[0];
        Object parameter = args[1];
        RowBounds rowBounds = (RowBounds) args[2];
        ResultHandler<?> resultHandler = (ResultHandler<?>) args[3];
        Executor executor = (Executor) invocation.getTarget();
        CacheKey cacheKey;
        BoundSql boundSql;
        if (args.length == 4) {
            boundSql = ms.getBoundSql(parameter);
            cacheKey = executor.createCacheKey(ms, parameter, rowBounds, boundSql);
        } else {
            cacheKey = (CacheKey) args[4];
            boundSql = (BoundSql) args[5];
        }
        return executor.query(ms, parameter, rowBounds, resultHandler, cacheKey, boundSql);
    }
@Test
    public void interceptTest() throws SQLException {
        final PostgreSQLQueryInterceptor postgreSQLQueryInterceptor = new PostgreSQLQueryInterceptor();
        final Invocation invocation = mock(Invocation.class);
        Object[] args = new Object[4];
        args[0] = mock(MappedStatement.class);
        args[1] = mock(Object.class);
        args[2] = mock(RowBounds.class);
        args[3] = mock(ResultHandler.class);
        when(invocation.getArgs()).thenReturn(args);
        final Executor executor = mock(Executor.class);
        when(invocation.getTarget()).thenReturn(executor);
        when(executor.createCacheKey(any(), any(), any(), any())).thenReturn(mock(CacheKey.class));
        when(executor.query(any(), any(), any(), any(), any(), any())).thenReturn(new ArrayList<>());
        Assertions.assertDoesNotThrow(() -> postgreSQLQueryInterceptor.intercept(invocation));
        args = new Object[6];
        args[0] = mock(MappedStatement.class);
        args[1] = mock(Object.class);
        args[2] = mock(RowBounds.class);
        args[3] = mock(ResultHandler.class);
        args[4] = mock(CacheKey.class);
        args[5] = mock(BoundSql.class);
        when(invocation.getArgs()).thenReturn(args);
        Assertions.assertDoesNotThrow(() -> postgreSQLQueryInterceptor.intercept(invocation));
    }