Class OutboundSyncStreamConfigurationBuilder

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

public final class OutboundSyncStreamConfigurationBuilder extends org.junit.rules.ExternalResource
A builder for conveniently creating OutboundSyncStreamConfigurationModels in integration tests. If this class is used with Rule annotation, then the created models will be also automatically cleaned up after the test(s) execution.
  • Method Details

    • outboundSyncStreamConfigurationBuilder

      public static OutboundSyncStreamConfigurationBuilder outboundSyncStreamConfigurationBuilder()
      Creates instance of this builder.
      Returns:
      new instance of the builder.
    • getOutboundSyncStreamConfigurationById

      public static OutboundSyncStreamConfigurationModel getOutboundSyncStreamConfigurationById(String streamId)
      Retrieves model of a stream configuration matching the ID.
      Parameters:
      streamId - ID of the stream to find and to retrieve.
      Returns:
      a stream configuration model matching the ID or null, if such stream configuration is not found.
    • withId

      Specifies ID for the delta stream to create. If this method is not called, default value of the stream ID will be used, which is value of the item type code plus "Stream" literal. That is, if "Product" type code was specified, then default stream ID will be "ProductStream".
      Parameters:
      id - ID value to be used for the stream to create.
      Returns:
      a builder with the ID specified.
      See Also:
    • withOutboundSyncStreamConfigurationContainer

      public OutboundSyncStreamConfigurationBuilder withOutboundSyncStreamConfigurationContainer(OutboundSyncStreamConfigurationContainerModel container)
    • withOutboundSyncStreamConfigurationContainer

      public OutboundSyncStreamConfigurationBuilder withOutboundSyncStreamConfigurationContainer(OutboundSyncStreamConfigurationContainerBuilder builder)
    • withItemType

      public OutboundSyncStreamConfigurationBuilder withItemType(String code)
      Specifies type code of the item type to collect changes for in the created delta stream.
      Parameters:
      code - item type code to be associated with the change stream
      Returns:
      a builder with the type code specified.
    • withOutboundChannelConfiguration

      public OutboundSyncStreamConfigurationBuilder withOutboundChannelConfiguration(OutboundChannelConfigurationModel model)
      Specifies outbound channel configuration to be associated with the new stream.
      Parameters:
      model - outbound channel to associate with the stream.
      Returns:
      a builder with the outbound channel configuration specified.
    • withOutboundChannelConfiguration

      public OutboundSyncStreamConfigurationBuilder withOutboundChannelConfiguration(OutboundChannelConfigurationBuilder builder)
    • withOutboundChannelCode

      public OutboundSyncStreamConfigurationBuilder withOutboundChannelCode(String code)
      Specifies outbound channel configuration to be associated with the new stream.
      Parameters:
      code - of OutboundChannelConfigurationModel to associate with the stream.
      Returns:
      a builder with the outbound channel configuration specified.
    • withWhereClause

      public OutboundSyncStreamConfigurationBuilder withWhereClause(String expr)
      Specifies filter condition to be used for collecting changes in the stream. Once applied, only changes for items matching the condition will be reported by the stream; all other item changes will be ignored. Filtering is peformed at the database level.

      This setting does not persist between build() calls and must be explicitly specified for each build() invocation.

      Parameters:
      expr - a filter condition expression to be applied to the item changes reported by the stream. Changed item can be referenced in the condition as "{item}". For example, if an item has code attribute, then condition for that attribute may look like this: "{item.code}!=''".
      Returns:
      a builder with the filter condition specified.
    • withInfoExpression

      public OutboundSyncStreamConfigurationBuilder withInfoExpression(String expr)
      Specifies info expression to be calculated on the changed items in the stream. This setting does not persist between build() calls and must be explicitly specified for each build() invocation.
      Parameters:
      expr - a Groovy expression that will be applied to the changed item; and result of that calculation will be reported in the created stream's change DTOs. The item, to which the expression is being applied, is implied in the expression and does not need to be explicitly present. Any methods/properties of the items can be referred to in Groovy style. For example, if item type has code and name properties and we want to capture their values as a Groovy map style string, the expression may look like: "[code: '#{getCode()', name: '#{getName()}'}]".
      Returns:
      a builder with the info expression specified.
    • withExcludedTypes

      public OutboundSyncStreamConfigurationBuilder withExcludedTypes(Set<String> types)
    • build

      Creates a stream configuration based on the specifications done before calling this method.
      Returns:
      stream configuration created in this method or null, if the created stream was not found in the database.
      Throws:
      ImpExException - if this builder failed to create the stream.
    • lastBuiltStreamConfiguration

      public OutboundSyncStreamConfigurationModel lastBuiltStreamConfiguration()
      Retrieves last stream configuration created by this builder.
      Returns:
      the last created stream configuration.
      Throws:
      IllegalStateException - if the build() method has not been called yet even once.
    • before

      protected void before() throws ImpExException
      Overrides:
      before in class org.junit.rules.ExternalResource
      Throws:
      ImpExException
    • after

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

      public void cleanup()
      Removes all stream configurations created by this builder since previous cleanup() invocation and consumes all changes in those streams.
      See Also:
    • consumeAllChanges

      public void consumeAllChanges()
      Consumes all changes in the delta streams created by this builder.
    • getAllChanges

      public List<ItemChangeDTO> getAllChanges()
      Retrieves all changes in the delta streams created by this builder since last cleanup() invocation. Retrieving the changes does not consume them.
      Returns:
      a list of all unconsumed changes in all streams created by this builder or an empty list, if there are not changes in the streams.
      See Also: