Class BrowserlessConfiguration

  • All Implemented Interfaces:
    java.io.Serializable

    
    public final class BrowserlessConfiguration
     implements Serializable
                        

    Custom Vaadin configuration to apply to a mock Vaadin environment.

    Holds Vaadin application properties (also known as init parameters) and feature flag overrides. Both are scoped to the environment they are applied to, so a configuration used by a test neither affects other tests nor requires any clean up.

    Instances are immutable and can be created with a builder or derived from a BrowserlessTestConfig annotation.

    BrowserlessConfiguration configuration = BrowserlessConfiguration.builder()
            .withApplicationProperty(
                    InitParameters.APPLICATION_PARAMETER_DEVMODE_ENABLE_SERIALIZE_SESSION,
                    "true")
            .withFeatureFlags("myExperimentalFeature") //
            .build();
    
    Since:

    25.3

    • Constructor Detail

    • Method Detail

      • getApplicationProperties

         Map<String, String> getApplicationProperties()

        Gets the Vaadin application properties (init parameters) to apply to the mock Vaadin environment.

        Returns:

        an unmodifiable map of application properties, never null

      • getFeatureFlags

         Map<String, Boolean> getFeatureFlags()

        Gets the feature flag overrides to apply to the mock Vaadin environment, as a map of feature identifiers to their enablement state.

        Returns:

        an unmodifiable map of feature flag overrides, never null

      • getLookupServices

         Set<Class<out Object>> getLookupServices()

        Gets the service implementation classes to be used to initialize the Vaadin com.vaadin.flow.di.Lookup.

        Returns:

        an unmodifiable set of service implementation classes, never null

      • empty

         static BrowserlessConfiguration empty()

        Gets a configuration that does not customize the Vaadin environment.

        Returns:

        an empty configuration, never null

      • from

         static BrowserlessConfiguration from(AnnotatedElement element)

        Creates a configuration from the BrowserlessTestConfig annotation potentially present on the given element.

        Meta annotations are not taken into account; use from with an annotation resolved by other means, such as JUnit AnnotationSupport, for a more thorough lookup.

        Parameters:
        element - the annotated element to inspect, not null
        Returns:

        the configuration declared by the element, or an empty configuration if the annotation is not present, never null

      • isEmpty

         boolean isEmpty()

        Checks if this configuration does not customize the Vaadin environment at all.

        Returns:

        true if neither application properties, nor feature flags, nor lookup services are defined, false otherwise

      • merge

         BrowserlessConfiguration merge(BrowserlessConfiguration overrides)

        Creates a new configuration by merging the given configuration into this one. Application properties and feature flags defined by the given configuration win over the ones defined by this configuration, while lookup services of both configurations are accumulated.

        Parameters:
        overrides - the configuration to merge into this one, not null
        Returns:

        a new merged configuration, never null