DefaultTunnelMonitorManager implements TunnelMonitorManager { @Override public TunnelMonitor getOrCreate(Tunnel tunnel) { return MapUtils.getOrCreate(tunnelMonitors, tunnel, new ObjectFactory<TunnelMonitor>() { @Override public TunnelMonitor create() { return new DefaultTunnelMonitor(resourceManager, tunnel, recorder); } }); } DefaultTunnelMonitorManager();  DefaultTunnelMonitorManager(ResourceManager resourceManager); @Override TunnelMonitor getOrCreate(Tunnel tunnel); @Override void remove(Tunnel tunnel);  }
@Test public void testGetOrCreate() { Tunnel tunnel = mock(Tunnel.class); TunnelMonitor tunnelMonitor = tunnelMonitorManager.getOrCreate(tunnel); Assert.assertNotNull(tunnelMonitor); tunnelMonitorManager.getOrCreate(tunnel); Assert.assertEquals(1, tunnelMonitorManager.getTunnelMonitors().size()); }