@Before
  public void setup() {
    recipientListRouter = mock(CustomRecipientListRouter.class);

    configurableApplicationContext = mock(ConfigurableApplicationContext.class);
    beanFactory = mock(ConfigurableListableBeanFactory.class);
    when(configurableApplicationContext.getBeanFactory()).thenReturn(beanFactory);

    TaskScheduler taskScheduler = mock(TaskScheduler.class);
    Executor executor = mock(Executor.class);

    monitorRegistry = new MonitorRegistry();
    monitorRegistry.setRecipientListRouter(recipientListRouter);
    monitorRegistry.setConfigurableApplicationContext(configurableApplicationContext);
    monitorRegistry.setExecutor(executor);
    monitorRegistry.setTaskScheduler(taskScheduler);
  }
  @Test
  public void testRegisterNewMonitor() {

    Monitor monitor = mock(Monitor.class);

    monitorRegistry.registerNewMonitor(monitor);

    verify(recipientListRouter, times(1))
        .addRecipient(any(MessageChannel.class), any(MonitorEventSelector.class));

    verify(configurableApplicationContext, times(3)).getBeanFactory();

    verify(beanFactory, times(2)).registerSingleton(any(String.class), any());
  }