class BrokerInterceptor implements Interceptor {

    @Override
    public void notifyClientConnected(final MqttConnectMessage msg) {
        for (final InterceptHandler handler : this.handlers.get(InterceptConnectMessage.class)) {
            LOG.debug("Sending MQTT CONNECT message to interceptor. CId={}, interceptorId={}",
                    msg.payload().clientIdentifier(), handler.getID());
            executor.execute(() -> handler.onConnect(new InterceptConnectMessage(msg)));
        }
    }

}

class BrokerInterceptorTest {

    private static final AtomicInteger n;
    private static final BrokerInterceptor interceptor;

    @Test
    public void testNotifyClientConnected() throws Exception {

        interceptor.notifyClientConnected(MqttMessageBuilders.connect().build());
        interval();
        assertEquals(40, n.get());
    }

}