BackendExperimentalFeaturesRegistryServiceImpl implements ExperimentalFeaturesRegistryService,
                                                                       BackendExperimentalFeaturesRegistryService,
                                                                       FeaturesEditorService { @Override public void save(EditableExperimentalFeature editableFeature) { if(!isExperimentalEnabled()) { throw new IllegalStateException("Impossible edit feature '" + editableFeature.getFeatureId() + "': Experimental Framework is disabled"); } Optional<ExperimentalFeatureDefinition> optional = Optional.ofNullable(defRegistry.getFeatureById(editableFeature.getFeatureId())); if (optional.isPresent()) { ExperimentalFeatureImpl feature = new ExperimentalFeatureImpl(editableFeature.getFeatureId(), editableFeature.isEnabled()); globalStorage.store(feature); } else { throw new IllegalArgumentException("Cannot find ExperimentalFeature '" + editableFeature.getFeatureId() + "'"); } } @Inject  BackendExperimentalFeaturesRegistryServiceImpl(final ExperimentalFeatureDefRegistry defRegistry, @Named("global") final ExperimentalFeaturesStorage globalStorage); @Override ExperimentalFeaturesRegistryImpl getFeaturesRegistry(); @Override Boolean isExperimentalEnabled(); @Override boolean isFeatureEnabled(String featureId); @Override void save(EditableExperimentalFeature editableFeature); @Override ExperimentalFeaturesSession getExperimentalFeaturesSession(); static final String EXPERIMENTAL_FEATURES_PROPERTY_NAME; }
@Test public void testStoreWrongFeature() { init(true); Assertions.assertThatThrownBy(() -> service.save(new EditableExperimentalFeature(UNEXISTING_FEATURE, true))) .hasMessage("Cannot find ExperimentalFeature '" + UNEXISTING_FEATURE + "'") .isInstanceOf(IllegalArgumentException.class); }