Class EventConfigurationBuilder

java.lang.Object
org.junit.rules.ExternalResource
de.hybris.platform.webhookservices.EventConfigurationBuilder
All Implemented Interfaces:
org.junit.rules.TestRule

public class EventConfigurationBuilder extends org.junit.rules.ExternalResource
A helper to be used in integration tests for creating and persisting EventConfigurations
  • Method Details

    • eventConfiguration

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

      public EventConfigurationBuilder withEventClass(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(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(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)
      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
    • withDestination

      public EventConfigurationBuilder withDestination(String code)
      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
    • withDestination

      public EventConfigurationBuilder withDestination(DestinationTargetModel model)
      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
    • 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(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(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
    • withPriority

      public EventConfigurationBuilder withPriority(EventPriority p)
      Specifies priority of the event export. If this method is not called, default EventPriority.LOW will be used.
      Returns:
      a builder with the priority 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
    • after

      protected void after()
      Overrides:
      after in class org.junit.rules.ExternalResource
    • cleanup

      public void cleanup()
      Deletes all data created by this builder.