@Override
    public void beforeRejectedExecution(Runnable runnable, ThreadPoolExecutor executor) {
        if (!(executor instanceof ExtensibleThreadPoolExecutor)) {
            return;
        }
        String threadPoolId = ((ExtensibleThreadPoolExecutor) executor).getThreadPoolId();
        threadPoolCheckAlarm.asyncSendRejectedAlarm(threadPoolId);
    }
@Test
    public void testBeforeRejectedExecution() {
        ExtensibleThreadPoolExecutor executor = new ExtensibleThreadPoolExecutor(
                "test", new DefaultThreadPoolPluginManager(),
                1, 1, 1000L, TimeUnit.MILLISECONDS,
                new ArrayBlockingQueue<>(1), Thread::new, new ThreadPoolExecutor.DiscardPolicy());

        TestAlarm alarm = new TestAlarm();
        executor.register(new TaskRejectNotifyAlarmPlugin(alarm));
        executor.submit(() -> ThreadUtil.sleep(200L));
        executor.submit(() -> ThreadUtil.sleep(200L));
        executor.submit(() -> ThreadUtil.sleep(200L));

        // waiting for shutdown
        executor.shutdown();
        while (!executor.isTerminated()) {
        }
        Assert.assertEquals(1, alarm.getNumberOfAlarms().get());
    }