Class BrowserlessConfiguration

java.lang.Object
com.vaadin.browserless.BrowserlessConfiguration
All Implemented Interfaces:
Serializable

public final class BrowserlessConfiguration extends Object 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
See Also:
  • Method Details

    • empty

      public static BrowserlessConfiguration empty()
      Gets a configuration that does not customize the Vaadin environment.
      Returns:
      an empty configuration, never null
    • builder

      public static BrowserlessConfiguration.Builder builder()
      Creates a new builder for a custom Vaadin configuration.
      Returns:
      a new builder, never null
    • from

      public 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(BrowserlessTestConfig) 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
    • from

      public static BrowserlessConfiguration from(BrowserlessTestConfig annotation)
      Creates a configuration from the given BrowserlessTestConfig annotation.
      Parameters:
      annotation - the annotation to convert, may be null
      Returns:
      the configuration declared by the annotation, or an empty configuration if the annotation is null, never null
      Throws:
      IllegalArgumentException - if an annotation entry is not well formed
    • getApplicationProperties

      public 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

      public 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

      public Set<Class<?>> getLookupServices()
      Gets the service implementation classes to be used to initialize the Vaadin Lookup.
      Returns:
      an unmodifiable set of service implementation classes, never null
    • isEmpty

      public 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

      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
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object