EnvironmentAlertHandlersImpl implements EnvironmentAlertHandlers { @Override @SuppressWarnings( "unchecked" ) public Collection<AlertHandler> getEffectiveHandlers() { return CollectionUtils.select( handlers.values(), new Predicate() { @Override public boolean evaluate( final Object o ) { return o != null; } } ); } EnvironmentAlertHandlersImpl( final EnvironmentId environmentId ); @Override void add( EnvironmentAlertHandler environmentAlertHandler, AlertHandler alertHandler ); @Override EnvironmentId getEnvironmentId(); @Override Map<EnvironmentAlertHandler, AlertHandler> getAllHandlers(); @Override @SuppressWarnings( "unchecked" ) Collection<AlertHandler> getEffectiveHandlers(); @Override AlertHandler getHandler( final EnvironmentAlertHandler handlerId );  }
@Test public void testGetEffectiveHandlers() { environmentAlertHandlers.add( normalId, normalHandler ); environmentAlertHandlers.add( highId, highHandler ); environmentAlertHandlers.add( lowId, lowHandler ); environmentAlertHandlers.add( nullHandlerId, null ); final Collection<AlertHandler> allHandlers = environmentAlertHandlers.getEffectiveHandlers(); final Iterator<AlertHandler> i2 = allHandlers.iterator(); assertEquals( 3, allHandlers.size() ); AlertHandler h = i2.next(); assertEquals( highHandler, h ); h = i2.next(); assertEquals( normalHandler, h ); h = i2.next(); assertEquals( lowHandler, h ); }