### Question:
ManagementService implements CacheManagerEventListener { public void notifyCacheRemoved(String cacheName) { if (registerCaches) { unregisterMBean(Cache.createObjectName(backingCacheManager.toString(), cacheName)); } if (registerCacheConfigurations) { unregisterMBean(CacheConfiguration.createObjectName(backingCacheManager.toString(), cacheName)); } if (registerCacheStatistics) { unregisterMBean(CacheStatistics.createObjectName(backingCacheManager.toString(), cacheName)); } if (registerCacheStores) { unregisterMBean(Store.createObjectName(backingCacheManager.toString(), cacheName)); } } ManagementService(net.sf.ehcache.CacheManager cacheManager,
                             MBeanServer mBeanServer,
                             boolean registerCacheManager,
                             boolean registerCaches,
                             boolean registerCacheConfigurations,
                             boolean registerCacheStatistics,
                             boolean registerCacheStores);  ManagementService(net.sf.ehcache.CacheManager cacheManager,
                                 MBeanServer mBeanServer,
                                 boolean registerCacheManager,
                                 boolean registerCaches,
                                 boolean registerCacheConfigurations,
                                 boolean registerCacheStatistics); static void registerMBeans(
            net.sf.ehcache.CacheManager cacheManager,
            MBeanServer mBeanServer,
            boolean registerCacheManager,
            boolean registerCaches,
            boolean registerCacheConfigurations,
            boolean registerCacheStatistics,
            boolean registerCacheStores); static void registerMBeans(
            net.sf.ehcache.CacheManager cacheManager,
            MBeanServer mBeanServer,
            boolean registerCacheManager,
            boolean registerCaches,
            boolean registerCacheConfigurations,
            boolean registerCacheStatistics); void init(); Status getStatus(); void dispose(); void notifyCacheAdded(String cacheName); void notifyCacheRemoved(String cacheName);  }### Answer:
@Test public void testNotifyCacheRemovedDoesNotCallWhenNotRegistered() { MBeanServer server = mock(MBeanServer.class); when(server.isRegistered(any(ObjectName.class))).thenReturn(true); net.sf.ehcache.CacheManager cm = mock(net.sf.ehcache.CacheManager.class); when(cm.toString()).thenReturn("cmName"); ManagementService managementService = new ManagementService(cm, server, false, false, false, false, false); managementService.notifyCacheRemoved("testName"); verifyZeroInteractions(server); }