ClientExperimentalFeaturesRegistryServiceImpl implements ClientExperimentalFeaturesRegistryService { @Override public void updateExperimentalFeature(String featureId, boolean enabled) { if (isExperimentalEnabled()) { Optional<ExperimentalFeature> optional = session.getFeaturesRegistry().getFeature(featureId); if (optional.isPresent()) { ExperimentalFeatureImpl feature = (ExperimentalFeatureImpl) optional.get(); if (feature.isEnabled() != enabled) { feature.setEnabled(enabled); event.fire(new NonPortableExperimentalFeatureModifiedEvent(feature)); } } } } @Inject  ClientExperimentalFeaturesRegistryServiceImpl(Caller<BackendExperimentalFeaturesRegistryService> backendService, Event<NonPortableExperimentalFeatureModifiedEvent> event); @Override void loadRegistry(); @Override ExperimentalFeaturesRegistry getFeaturesRegistry(); @Override boolean isFeatureEnabled(String featureId); @Override void updateExperimentalFeature(String featureId, boolean enabled); @Override Boolean isExperimentalEnabled(); void onGlobalFeatureModified(@Observes PortableExperimentalFeatureModifiedEvent event);  }
@Test public void testNotifyFeatureUpdate() { initService(true); ExperimentalFeatureImpl feature = new ExperimentalFeatureImpl(FEATURE_1, false); service.updateExperimentalFeature(feature.getFeatureId(), feature.isEnabled()); checkNotifyFeatureUpdate(feature); }
@Test public void testWrongNotifyFeatureUpdate() { initService(true); ExperimentalFeatureImpl feature = new ExperimentalFeatureImpl(FEATURE_1, true); service.updateExperimentalFeature(feature.getFeatureId(), feature.isEnabled()); verify(event, never()).fire(any()); feature = new ExperimentalFeatureImpl(WRONG_FEATURE_ID, true); service.updateExperimentalFeature(feature.getFeatureId(), feature.isEnabled()); verify(event, never()).fire(any()); }
@Test public void testNotifyFeatureUpdateWhenExperimentalDisabled() { initService(false); ExperimentalFeatureImpl feature = new ExperimentalFeatureImpl(FEATURE_1, false); service.updateExperimentalFeature(feature.getFeatureId(), feature.isEnabled()); verify(event, never()).fire(any()); }