Package de.hybris.platform.outboundsync
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 Summary
Modifier and TypeMethodDescriptionprotected voidafter()protected voidbefore()build()Creates a stream configuration based on the specifications done before calling this method.voidcleanup()Removes all stream configurations created by this builder since previouscleanup()invocation and consumes all changes in those streams.voidConsumes all changes in the delta streams created by this builder.Retrieves all changes in the delta streams created by this builder since lastcleanup()invocation.getOutboundSyncStreamConfigurationById(String streamId) Retrieves model of a stream configuration matching the ID.Retrieves last stream configuration created by this builder.Creates instance of this builder.withExcludedTypes(Set<String> types) Specifies ID for the delta stream to create.withInfoExpression(String expr) Specifies info expression to be calculated on the changed items in the stream.withItemType(String code) Specifies type code of the item type to collect changes for in the created delta stream.Specifies outbound channel configuration to be associated with the new stream.Specifies outbound channel configuration to be associated with the new stream.withOutboundSyncStreamConfigurationContainer(OutboundSyncStreamConfigurationContainerModel container) withOutboundSyncStreamConfigurationContainer(OutboundSyncStreamConfigurationContainerBuilder builder) withWhereClause(String expr) Specifies filter condition to be used for collecting changes in the stream.Methods inherited from class org.junit.rules.ExternalResource
apply
-
Method Details
-
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
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
Specifies outbound channel configuration to be associated with the new stream.- Parameters:
code- ofOutboundChannelConfigurationModelto associate with the stream.- Returns:
- a builder with the outbound channel configuration specified.
-
withWhereClause
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 eachbuild()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 hascodeattribute, then condition for that attribute may look like this:"{item.code}!=''".- Returns:
- a builder with the filter condition specified.
-
withInfoExpression
Specifies info expression to be calculated on the changed items in the stream. This setting does not persist betweenbuild()calls and must be explicitly specified for eachbuild()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 hascodeandnameproperties 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
-
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
Retrieves last stream configuration created by this builder.- Returns:
- the last created stream configuration.
- Throws:
IllegalStateException- if thebuild()method has not been called yet even once.
-
before
- Overrides:
beforein classorg.junit.rules.ExternalResource- Throws:
ImpExException
-
after
protected void after()- Overrides:
afterin classorg.junit.rules.ExternalResource
-
cleanup
public void cleanup()Removes all stream configurations created by this builder since previouscleanup()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
Retrieves all changes in the delta streams created by this builder since lastcleanup()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:
-