Class EventConfigurationBuilder


  • public class EventConfigurationBuilder
    extends java.lang.Object
    A helper to be used in integration tests for creating and persisting EventConfigurations
    • Method Detail

      • eventConfiguration

        public static EventConfigurationBuilder eventConfiguration()
        Instantiates this builder.
        Returns:
        a builder instance to be used for further specification.
      • withEventClass

        public EventConfigurationBuilder withEventClass​(java.lang.Class<?> c)
        Specifies event class, for which the configuration has to be created. If this method is not called, the event class will default to AfterSaveEvent
        Parameters:
        c - an event class to build configuration for.
        Returns:
        a builder with the event class specified
      • withEventClass

        public EventConfigurationBuilder withEventClass​(java.lang.String className)
        Specifies event class, for which the configuration has to be created. If this method is not called, the event class will default to ItemSavedEvent
        Parameters:
        className - class name, i.e. Class.getName(), to be used for the event configuration.
        Returns:
        a builder with the event class specified
      • withVersion

        public EventConfigurationBuilder withVersion​(int v)
        Specifies version of the event configuration.
        Parameters:
        v - version number to use for the event configuration being built. If the specified version has a non-positive value or this method is not called, default value of 1 will be used.
        Returns:
        a builder with the event configuration version specified
      • withExportName

        public EventConfigurationBuilder withExportName​(java.lang.String name)
        Specifies name of the event in the export. If this method is not called, default value of "webhookservices.<event_class_simple_name>" will be used. For example, if event class is de.hybris.platform.tx.AfterSaveEvent, then the default export name will be "webhookservices.AfterSaveEvent".
        Parameters:
        name - export name to be used for the event configuration being built
        Returns:
        a builder with the event export name specified
      • withDestination

        public EventConfigurationBuilder withDestination​(DestinationTargetBuilder builder)
                                                  throws ImpExException
        Specifies destination for event export. If this method is not called, default destination will be used.
        Parameters:
        builder - a builder specifying destination target parameters
        Returns:
        a builder with the event export destination specified
        Throws:
        ImpExException
      • withDestination

        public EventConfigurationBuilder withDestination​(java.lang.String code)
                                                  throws ImpExException
        Specifies destination for event export. If this method is not called, default destination will be used.
        Parameters:
        code - a destination target to use for the event configuration being built
        Returns:
        a builder with the event export destination specified
        Throws:
        ImpExException - when code does not correspond to an already persited destination target and the creation of the new destination target with that code fails.
      • withDestination

        public EventConfigurationBuilder withDestination​(DestinationTargetModel model)
                                                  throws ImpExException
        Specifies destination for event export. If this method is not called, default destination will be used.
        Parameters:
        model - a destination target to use for the event configuration being built
        Returns:
        a builder with the event export destination specified
        Throws:
        ImpExException - if the model was not persisted and fails while this method attempts to persist it.
      • withoutExport

        public EventConfigurationBuilder withoutExport()
        Specifies that the event should not be exported. If this method is not called, then the exportFlag of the built configuration will have value of true.
        Returns:
        a builder with false export flag specified
      • withExport

        public EventConfigurationBuilder withExport​(java.lang.Boolean flag)
        Specifies whether the event should be exported. If this method is not called, then the exportFlag of the built configuration will have value of true.
        Parameters:
        flag - true or null, if the event should be exported; false, otherwise.
        Returns:
        a builder with false export flag specified
      • withExtensionName

        public EventConfigurationBuilder withExtensionName​(java.lang.String name)
        Specifies name of the extension that owns the event configuration. If this method is not called, then the extension name will be defaulted to "webhookservices".
        Returns:
        a builder with the extension name specified
      • build

        public EventConfigurationModel build()
                                      throws ImpExException
        Persists an EventConfigurationModel according to the specifications done so far in this builder.
        Returns:
        the persisted event configuration or null, if the created configuration was not saved in the database for some reason.
        Throws:
        ImpExException - if persistence crashes