### Question:
AbstractFeatureService { public boolean isEnabled(final Feature feature) { final FeaturesContext featuresContext = FeaturesContextHolder.get(); return enabledFeatures(featuresContext == null ? null : featuresContext.featureSetId()).contains(feature); }  abstract Set<String> featureSetIds(); abstract Set<Feature> enabledFeatures(final String featureSetId); boolean isEnabled(final Feature feature);  }### Answer:
@Test public void shouldEnableDefaultFeatures_withNullFeaturesContext() throws Exception { featureService.setFeatures(null, Sets.newSet(StubFeature.FEATURE1)); FeaturesContextHolder.set(null); final boolean enabled = featureService.isEnabled(StubFeature.FEATURE1); assertTrue(enabled); }
@Test public void shouldEnableFeature_withFeaturesContext() throws Exception { final String featureSetId = randomId(); featureService.setFeatures(null, Sets.newSet()); featureService.setFeatures(featureSetId, Sets.newSet(StubFeature.FEATURE1)); FeaturesContextHolder.set(new FeaturesContext(featureSetId)); final boolean enabled = featureService.isEnabled(StubFeature.FEATURE1); assertTrue(enabled); }
@Test public void shouldNotEnableFeature_withIncorrectFeaturesContext() throws Exception { final String featureSetId = randomId(); featureService.setFeatures(null, Sets.newSet()); featureService.setFeatures(featureSetId, Sets.newSet(StubFeature.FEATURE1)); FeaturesContextHolder.set(new FeaturesContext(randomId())); final boolean enabled = featureService.isEnabled(StubFeature.FEATURE1); assertFalse(enabled); }
@Test public void shouldNotEnableNonDefaultFeature_withNullFeaturesContext() throws Exception { final String featureSetId = randomId(); featureService.setFeatures(null, Sets.newSet(StubFeature.FEATURE1)); featureService.setFeatures(featureSetId, Sets.newSet(StubFeature.FEATURE2)); FeaturesContextHolder.set(null); final boolean enabled = featureService.isEnabled(StubFeature.FEATURE2); assertFalse(enabled); }