FeatureMap implements Map<Object, Boolean> { @Override public Boolean get(Object key) { Validate.notNull(key, "The feature must not be null"); Feature feature = null; if (key instanceof Feature) { feature = (Feature) key; } else { feature = new NamedFeature(key.toString()); } return manager.isActive(feature); } FeatureMap();  FeatureMap(FeatureManager manager); @Override Boolean get(Object key); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override Boolean put(Object key, Boolean value); @Override Boolean remove(Object key); @Override void putAll(Map<? extends Object, ? extends Boolean> m); @Override void clear(); @Override Set<Object> keySet(); @Override Collection<Boolean> values(); @Override Set<Map.Entry<Object, Boolean>> entrySet();  }
@Test void shouldSupportLookupByFeatureName() { FeatureManager featureManager = mock(FeatureManager.class); when(featureManager.isActive(featureNamed("test"))).thenReturn(true); FeatureMap map = new FeatureMap(featureManager); assertEquals(true, map.get("test")); assertEquals(false, map.get("other")); }
@Test void shouldSupportLookupByFeatureInstance() { FeatureManager featureManager = mock(FeatureManager.class); when(featureManager.isActive(featureNamed("test"))).thenReturn(true); FeatureMap map = new FeatureMap(featureManager); assertEquals(true, map.get("test")); assertEquals(false, map.get("other")); }