Class BrowserlessFeatureFlags

  • All Implemented Interfaces:
    java.io.Serializable

    
    public class BrowserlessFeatureFlags
    extends FeatureFlags
                        

    FeatureFlags implementation that applies test defined feature flag overrides on top of the ones resolved by Vaadin.

    The instance is installed into the VaadinContext of the mock environment before the Vaadin servlet is initialized, so that everything reading feature flags during startup, for example a com.vaadin.flow.server.VaadinServiceInitListener, already observes the test configuration.

    For internal use only. May be renamed or removed in a future release.

    Since:

    25.3

    • Constructor Detail

    • Method Detail

      • install

         static void install(VaadinContext context, Map<String, Boolean> overrides)

        Installs a FeatureFlags instance applying the given overrides into the given Vaadin context.

        Must be invoked before anything requests the feature flags for the context, otherwise Vaadin creates and caches its own instance.

        Parameters:
        context - the Vaadin context of the mock environment, not null
        overrides - feature identifiers mapped to their enablement state, not null
      • loadProperties

         void loadProperties()

        Re-applies the test defined overrides, so that they are not silently discarded by code reloading the feature flags, for example through setPropertiesLocation.

      • setEnabled

         void setEnabled(String featureId, boolean enabled)

        Toggles the feature for the current test only. Unlike the default implementation, it neither requires development mode nor stores the new state into the vaadin-featureflags.properties file of the project.

        The new state is recorded among the overrides, so that it survives a later reload of the feature flags, exactly like the states declared by the test configuration.