-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add setStreamId method to EventTransformation to support transformati…
…ons for new streams
- Loading branch information
1 parent
cb45b28
commit a989e19
Showing
43 changed files
with
1,307 additions
and
643 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...n/java/uk/gov/sample/event/transformation/pass/SampleTransformationSequenceScenario1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package uk.gov.sample.event.transformation.pass; | ||
|
||
import static uk.gov.justice.tools.eventsourcing.transformation.api.Action.NO_ACTION; | ||
|
||
import uk.gov.justice.services.core.enveloper.Enveloper; | ||
import uk.gov.justice.services.messaging.JsonEnvelope; | ||
import uk.gov.justice.tools.eventsourcing.transformation.api.Action; | ||
import uk.gov.justice.tools.eventsourcing.transformation.api.EventTransformation; | ||
import uk.gov.justice.tools.eventsourcing.transformation.api.annotation.Transformation; | ||
|
||
import java.util.stream.Stream; | ||
|
||
@Transformation(pass = 7) | ||
public class SampleTransformationSequenceScenario1 implements EventTransformation { | ||
|
||
private Enveloper enveloper; | ||
|
||
@Override | ||
public Action actionFor(final JsonEnvelope event) { | ||
if (event.metadata().name().equalsIgnoreCase("sample.events.name.pass1.sequence")) { | ||
return new Action(true, false, false); | ||
} | ||
return NO_ACTION; | ||
} | ||
|
||
@Override | ||
public Stream<JsonEnvelope> apply(final JsonEnvelope event) { | ||
final JsonEnvelope transformedEnvelope = enveloper.withMetadataFrom(event, "sample.events.name.pass1.sequence1").apply(event.payload()); | ||
final JsonEnvelope transformedEnvelope2 = enveloper.withMetadataFrom(event, "sample.events.name.pass1.sequence2").apply(event.payload()); | ||
final JsonEnvelope transformedEnvelope3 = enveloper.withMetadataFrom(event, "sample.events.name.pass1.sequence3").apply(event.payload()); | ||
return Stream.of(transformedEnvelope, transformedEnvelope2, transformedEnvelope3); | ||
} | ||
|
||
@Override | ||
public void setEnveloper(final Enveloper enveloper) { | ||
this.enveloper = enveloper; | ||
} | ||
} | ||
|
||
|
47 changes: 47 additions & 0 deletions
47
...n/java/uk/gov/sample/event/transformation/pass/SampleTransformationSequenceScenario2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package uk.gov.sample.event.transformation.pass; | ||
|
||
import static java.util.UUID.fromString; | ||
import static uk.gov.justice.tools.eventsourcing.transformation.api.Action.NO_ACTION; | ||
|
||
import uk.gov.justice.services.core.enveloper.Enveloper; | ||
import uk.gov.justice.services.messaging.JsonEnvelope; | ||
import uk.gov.justice.tools.eventsourcing.transformation.api.Action; | ||
import uk.gov.justice.tools.eventsourcing.transformation.api.EventTransformation; | ||
import uk.gov.justice.tools.eventsourcing.transformation.api.annotation.Transformation; | ||
|
||
import java.util.Optional; | ||
import java.util.UUID; | ||
import java.util.stream.Stream; | ||
|
||
@Transformation(pass = 8) | ||
public class SampleTransformationSequenceScenario2 implements EventTransformation { | ||
|
||
private Enveloper enveloper; | ||
|
||
@Override | ||
public Action actionFor(final JsonEnvelope event) { | ||
if (event.metadata().name().equalsIgnoreCase("sample.events.name.pass1.sequence2")) { | ||
return new Action(true, false, false); | ||
} | ||
return NO_ACTION; | ||
} | ||
|
||
@Override | ||
public Stream<JsonEnvelope> apply(final JsonEnvelope event) { | ||
final JsonEnvelope transformedEnvelope = enveloper.withMetadataFrom(event, "sample.events.name.pass1.sequence2").apply(event.payload()); | ||
return Stream.of(transformedEnvelope); | ||
} | ||
|
||
@Override | ||
public void setEnveloper(final Enveloper enveloper) { | ||
this.enveloper = enveloper; | ||
} | ||
|
||
@Override | ||
public Optional<UUID> setStreamId(final JsonEnvelope event) { | ||
return Optional.of(fromString("80764cb1-a031-4328-b59e-6c18b0974a84")); | ||
} | ||
|
||
} | ||
|
||
|
46 changes: 46 additions & 0 deletions
46
...n/java/uk/gov/sample/event/transformation/pass/SampleTransformationSequenceScenario3.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package uk.gov.sample.event.transformation.pass; | ||
|
||
import static java.util.UUID.fromString; | ||
import static uk.gov.justice.tools.eventsourcing.transformation.api.Action.NO_ACTION; | ||
|
||
import uk.gov.justice.services.core.enveloper.Enveloper; | ||
import uk.gov.justice.services.messaging.JsonEnvelope; | ||
import uk.gov.justice.tools.eventsourcing.transformation.api.Action; | ||
import uk.gov.justice.tools.eventsourcing.transformation.api.EventTransformation; | ||
import uk.gov.justice.tools.eventsourcing.transformation.api.annotation.Transformation; | ||
|
||
import java.util.Optional; | ||
import java.util.UUID; | ||
import java.util.stream.Stream; | ||
|
||
@Transformation(pass = 9) | ||
public class SampleTransformationSequenceScenario3 implements EventTransformation { | ||
|
||
private Enveloper enveloper; | ||
|
||
@Override | ||
public Action actionFor(final JsonEnvelope event) { | ||
if (event.metadata().name().equalsIgnoreCase("sample.events.name.pass1.sequence3")) { | ||
return new Action(true, false, false); | ||
} | ||
return NO_ACTION; | ||
} | ||
|
||
@Override | ||
public Stream<JsonEnvelope> apply(final JsonEnvelope event) { | ||
final JsonEnvelope transformedEnvelope = enveloper.withMetadataFrom(event, "sample.events.name.pass1.sequence3").apply(event.payload()); | ||
return Stream.of(transformedEnvelope); | ||
} | ||
|
||
@Override | ||
public void setEnveloper(final Enveloper enveloper) { | ||
this.enveloper = enveloper; | ||
} | ||
|
||
@Override | ||
public Optional<UUID> setStreamId(final JsonEnvelope event) { | ||
return Optional.of(fromString("80764cb1-a031-4328-b59e-6c18b0974a84")); | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...n/java/uk/gov/sample/event/transformation/transform/SampleTransformationWithStreamId.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package uk.gov.sample.event.transformation.transform; | ||
|
||
import static java.util.UUID.fromString; | ||
import static uk.gov.justice.tools.eventsourcing.transformation.api.Action.NO_ACTION; | ||
import static uk.gov.justice.tools.eventsourcing.transformation.api.Action.TRANSFORM; | ||
|
||
import uk.gov.justice.services.core.enveloper.Enveloper; | ||
import uk.gov.justice.services.messaging.JsonEnvelope; | ||
import uk.gov.justice.tools.eventsourcing.transformation.api.Action; | ||
import uk.gov.justice.tools.eventsourcing.transformation.api.EventTransformation; | ||
import uk.gov.justice.tools.eventsourcing.transformation.api.annotation.Transformation; | ||
|
||
import java.util.Optional; | ||
import java.util.UUID; | ||
import java.util.stream.Stream; | ||
|
||
@Transformation | ||
public class SampleTransformationWithStreamId implements EventTransformation { | ||
|
||
private Enveloper enveloper; | ||
|
||
@Override | ||
public Action actionFor(final JsonEnvelope event) { | ||
if (event.metadata().name().equalsIgnoreCase("sample.transformation.with.stream.id")) { | ||
return TRANSFORM; | ||
} | ||
return NO_ACTION; | ||
} | ||
|
||
@Override | ||
public Stream<JsonEnvelope> apply(final JsonEnvelope event) { | ||
final JsonEnvelope transformedEnvelope = enveloper.withMetadataFrom(event, "sample.transformation.with.stream.id.transformed").apply(event.payload()); | ||
return Stream.of(transformedEnvelope); | ||
} | ||
|
||
@Override | ||
public void setEnveloper(final Enveloper enveloper) { | ||
this.enveloper = enveloper; | ||
} | ||
|
||
@Override | ||
public Optional<UUID> setStreamId(final JsonEnvelope event) { | ||
return Optional.of(fromString("80764cb1-a031-4328-b59e-6c18b0974a84")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.