diff --git a/CHANGELOG.md b/CHANGELOG.md
index 779b2c09..1b588b48 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,19 @@ on [Keep a CHANGELOG](http://keepachangelog.com/). This project adheres to
## [Unreleased]
+### Changed
+- Update framework-api to 3.1.0-M2
+- Update framework to 5.1.0-M3
+- Update framework-domain to 1.1.0-M3
+- Update event-store to 1.1.0-M1
+- Update framework-generators to 1.1.0-M1
+- Update test-utils to 1.19.0
+
+### Added
+- Liquibase script to add events into event_log before startup
+- CakeShopReplayEvents IT to test the replaying of events on startup
+- SubscriptionEventInterceptor into Event Listener to update Subscription event number
+
## [1.0.1] - 2018-12-11
### Changed
diff --git a/example-context/example-service/example-event/example-event-listener/pom.xml b/example-context/example-service/example-event/example-event-listener/pom.xml
index 1f07d4ed..d11d988a 100644
--- a/example-context/example-service/example-event/example-event-listener/pom.xml
+++ b/example-context/example-service/example-event/example-event-listener/pom.xml
@@ -51,6 +51,11 @@
event-subscription-registry
${event-store.version}
+
+ uk.gov.justice.event-store
+ subscription-event-interceptors
+ ${event-store.version}
+
uk.gov.justice.event-store
event-listener-interceptors
diff --git a/example-context/example-service/example-event/example-event-listener/src/main/java/uk/gov/justice/services/example/cakeshop/event/listener/provider/ExampleEventListenerInterceptorChainProvider.java b/example-context/example-service/example-event/example-event-listener/src/main/java/uk/gov/justice/services/example/cakeshop/event/listener/provider/ExampleEventListenerInterceptorChainProvider.java
new file mode 100644
index 00000000..a2bb7ad2
--- /dev/null
+++ b/example-context/example-service/example-event/example-event-listener/src/main/java/uk/gov/justice/services/example/cakeshop/event/listener/provider/ExampleEventListenerInterceptorChainProvider.java
@@ -0,0 +1,27 @@
+package uk.gov.justice.services.example.cakeshop.event.listener.provider;
+
+import uk.gov.justice.services.core.interceptor.InterceptorChainEntry;
+import uk.gov.justice.services.core.interceptor.InterceptorChainEntryProvider;
+import uk.gov.justice.services.event.source.subscriptions.interceptors.SubscriptionEventInterceptor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ExampleEventListenerInterceptorChainProvider implements InterceptorChainEntryProvider {
+
+ private final List interceptorChainEntries = new ArrayList();
+
+ public ExampleEventListenerInterceptorChainProvider() {
+ interceptorChainEntries.add(new InterceptorChainEntry(1000, SubscriptionEventInterceptor.class));
+ }
+
+ @Override
+ public String component() {
+ return "EVENT_LISTENER";
+ }
+
+ @Override
+ public List interceptorChainTypes() {
+ return interceptorChainEntries;
+ }
+}
diff --git a/example-context/example-service/example-event/example-event-listener/src/test/java/uk/gov/justice/services/example/cakeshop/event/listener/provider/ExampleEventListenerInterceptorChainProviderTest.java b/example-context/example-service/example-event/example-event-listener/src/test/java/uk/gov/justice/services/example/cakeshop/event/listener/provider/ExampleEventListenerInterceptorChainProviderTest.java
new file mode 100644
index 00000000..d5b554ca
--- /dev/null
+++ b/example-context/example-service/example-event/example-event-listener/src/test/java/uk/gov/justice/services/example/cakeshop/event/listener/provider/ExampleEventListenerInterceptorChainProviderTest.java
@@ -0,0 +1,30 @@
+package uk.gov.justice.services.example.cakeshop.event.listener.provider;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import uk.gov.justice.services.core.interceptor.InterceptorChainEntry;
+
+import java.util.List;
+
+import org.junit.Test;
+
+public class ExampleEventListenerInterceptorChainProviderTest {
+
+ @Test
+ public void shouldCreateInterceptorChainEntriesWithSubscriptionEventInterceptor() {
+
+ final List interceptorChainEntries = new ExampleEventListenerInterceptorChainProvider().interceptorChainTypes();
+
+ assertThat(interceptorChainEntries.size(), is(1));
+
+ final InterceptorChainEntry interceptorChainEntry = interceptorChainEntries.get(0);
+ assertThat(interceptorChainEntry.getInterceptorType().getName(), is("uk.gov.justice.services.event.source.subscriptions.interceptors.SubscriptionEventInterceptor"));
+ assertThat(interceptorChainEntry.getPriority(), is(1000));
+ }
+
+ @Test
+ public void shouldReturnComponentName() {
+ assertThat(new ExampleEventListenerInterceptorChainProvider().component(), is("EVENT_LISTENER"));
+ }
+}
\ No newline at end of file
diff --git a/example-context/example-service/example-initialisation-liquibase/pom.xml b/example-context/example-service/example-initialisation-liquibase/pom.xml
new file mode 100644
index 00000000..d09bd99c
--- /dev/null
+++ b/example-context/example-service/example-initialisation-liquibase/pom.xml
@@ -0,0 +1,18 @@
+
+
+
+ example-service
+ uk.gov.justice.services.example
+ 1.1.0-SNAPSHOT
+
+ 4.0.0
+
+ example-initialisation-liquibase
+
+
+ true
+
+
+
\ No newline at end of file
diff --git a/example-context/example-service/example-initialisation-liquibase/src/main/resources/liquibase.properties b/example-context/example-service/example-initialisation-liquibase/src/main/resources/liquibase.properties
new file mode 100644
index 00000000..cfe971b8
--- /dev/null
+++ b/example-context/example-service/example-initialisation-liquibase/src/main/resources/liquibase.properties
@@ -0,0 +1 @@
+changeLogFile=liquibase/initialise-event-log-db-changelog.xml
diff --git a/example-context/example-service/example-initialisation-liquibase/src/main/resources/liquibase/initialise-event-log-db-changelog.xml b/example-context/example-service/example-initialisation-liquibase/src/main/resources/liquibase/initialise-event-log-db-changelog.xml
new file mode 100644
index 00000000..f43a0928
--- /dev/null
+++ b/example-context/example-service/example-initialisation-liquibase/src/main/resources/liquibase/initialise-event-log-db-changelog.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
diff --git a/example-context/example-service/example-initialisation-liquibase/src/main/resources/liquibase/initialise-event-log-db-changesets/001-add-initial-events.xml b/example-context/example-service/example-initialisation-liquibase/src/main/resources/liquibase/initialise-event-log-db-changesets/001-add-initial-events.xml
new file mode 100644
index 00000000..4ad440b2
--- /dev/null
+++ b/example-context/example-service/example-initialisation-liquibase/src/main/resources/liquibase/initialise-event-log-db-changesets/001-add-initial-events.xml
@@ -0,0 +1,54 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/example-context/example-service/example-it/pom.xml b/example-context/example-service/example-it/pom.xml
index 9bdcb3ae..d99e8bf4 100644
--- a/example-context/example-service/example-it/pom.xml
+++ b/example-context/example-service/example-it/pom.xml
@@ -152,6 +152,17 @@
update
+
+ initialise-event-log-liquibase
+
+ liquibase/initialise-event-log-db-changelog.xml
+ jdbc:postgresql://localhost:5432/frameworkeventstore
+
+ pre-integration-test
+
+ update
+
+
event-buffer-liquibase
@@ -175,10 +186,23 @@
update
+
+ subscriptions-liquibase
+
+ liquibase/subscription-repository-changelog.xml
+
+ jdbc:postgresql://localhost:5432/frameworkviewstore
+
+ pre-integration-test
+
+ update
+
+
file-service-liquibase
- liquibase/file-service-liquibase-db-changelog.xml
+ liquibase/file-service-liquibase-db-changelog.xml
+
jdbc:postgresql://localhost:5432/frameworkfilestore
pre-integration-test
@@ -214,6 +238,16 @@
file-service-liquibase
${file.service.version}
+
+ uk.gov.justice.event-store
+ subscription-repository-liquibase
+ ${event-store.version}
+
+
+ uk.gov.justice.services.example
+ example-initialisation-liquibase
+ ${project.version}
+
org.postgresql
postgresql
@@ -311,8 +345,8 @@
${jboss.home}
${server.config}
120
- -DDEFAULT_PORT=${random-http-port}
+ -DDEFAULT_PORT=${random-http-port}
${random-management-port}
diff --git a/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/eventsourcing/jdbc/snapshot/StandaloneSnapshotJdbcRepositoryFactory.java b/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/eventsourcing/jdbc/snapshot/StandaloneSnapshotJdbcRepositoryFactory.java
index ae150586..180206d0 100644
--- a/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/eventsourcing/jdbc/snapshot/StandaloneSnapshotJdbcRepositoryFactory.java
+++ b/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/eventsourcing/jdbc/snapshot/StandaloneSnapshotJdbcRepositoryFactory.java
@@ -1,6 +1,6 @@
package uk.gov.justice.services.eventsourcing.jdbc.snapshot;
-import static uk.gov.justice.services.test.utils.common.reflection.ReflectionUtils.setField;
+import static uk.gov.justice.services.test.utils.core.reflection.ReflectionUtil.setField;
import javax.sql.DataSource;
diff --git a/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/example/cakeshop/it/CakeShopReplayEventsIT.java b/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/example/cakeshop/it/CakeShopReplayEventsIT.java
new file mode 100644
index 00000000..97319ecd
--- /dev/null
+++ b/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/example/cakeshop/it/CakeShopReplayEventsIT.java
@@ -0,0 +1,81 @@
+package uk.gov.justice.services.example.cakeshop.it;
+
+import static com.jayway.jsonassert.JsonAssert.with;
+import static java.util.UUID.fromString;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+import static uk.gov.justice.services.example.cakeshop.it.params.CakeShopMediaTypes.CONTEXT_NAME;
+
+import uk.gov.justice.services.event.buffer.core.repository.subscription.Subscription;
+import uk.gov.justice.services.example.cakeshop.it.helpers.ApiResponse;
+import uk.gov.justice.services.example.cakeshop.it.helpers.CakeShopRepositoryManager;
+import uk.gov.justice.services.example.cakeshop.it.helpers.CommandFactory;
+import uk.gov.justice.services.example.cakeshop.it.helpers.EventFactory;
+import uk.gov.justice.services.example.cakeshop.it.helpers.EventFinder;
+import uk.gov.justice.services.example.cakeshop.it.helpers.Querier;
+import uk.gov.justice.services.example.cakeshop.it.helpers.RestEasyClientFactory;
+
+import javax.ws.rs.client.Client;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class CakeShopReplayEventsIT {
+
+ private static final CakeShopRepositoryManager CAKE_SHOP_REPOSITORY_MANAGER = new CakeShopRepositoryManager();
+
+ private final EventFactory eventFactory = new EventFactory();
+ private final EventFinder eventFinder = new EventFinder(CAKE_SHOP_REPOSITORY_MANAGER);
+ private final CommandFactory commandFactory = new CommandFactory();
+
+ private Client client;
+ private Querier querier;
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ CAKE_SHOP_REPOSITORY_MANAGER.initialise();
+ }
+
+ @Before
+ public void before() {
+ client = new RestEasyClientFactory().createResteasyClient();
+ querier = new Querier(client);
+ }
+
+ @After
+ public void cleanup() {
+ client.close();
+ }
+
+ @Test
+ public void shouldFindReplayedRecipesInViewStore() {
+
+ final String recipeId_1 = "489c5e3b-8c0c-4e26-855f-34592604bd98";
+ final String recipeId_2 = "8440bcc3-a4d6-4bd1-817c-ab89ffd307ae";
+
+ final ApiResponse response_1 = querier.queryForRecipe(recipeId_1);
+ final ApiResponse response_2 = querier.queryForRecipe(recipeId_2);
+
+ with(response_1.body())
+ .assertThat("$.id", equalTo(recipeId_1))
+ .assertThat("$.name", equalTo("Turnip Cake"));
+
+ with(response_2.body())
+ .assertThat("$.id", equalTo(recipeId_2))
+ .assertThat("$.name", equalTo("Rock Cake"));
+
+ assertThat(subscription(recipeId_1).getPosition(), is(2L));
+ assertThat(subscription(recipeId_2).getPosition(), is(2L));
+ }
+
+ @SuppressWarnings("OptionalGetWithoutIsPresent")
+ private Subscription subscription(final String recipeId) {
+ return CAKE_SHOP_REPOSITORY_MANAGER
+ .getSubscriptionJdbcRepository()
+ .findByStreamIdAndSource(fromString(recipeId), CONTEXT_NAME)
+ .get();
+ }
+}
diff --git a/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/example/cakeshop/it/SnapshotCakeShopIT.java b/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/example/cakeshop/it/SnapshotCakeShopIT.java
index 75185e67..daf2769b 100644
--- a/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/example/cakeshop/it/SnapshotCakeShopIT.java
+++ b/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/example/cakeshop/it/SnapshotCakeShopIT.java
@@ -4,7 +4,7 @@
import static com.jayway.jsonassert.JsonAssert.with;
import static java.util.UUID.randomUUID;
import static org.hamcrest.core.IsCollectionContaining.hasItem;
-import static uk.gov.justice.services.test.utils.common.reflection.ReflectionUtils.setField;
+import static uk.gov.justice.services.test.utils.core.reflection.ReflectionUtil.setField;
import uk.gov.justice.domain.snapshot.AggregateSnapshot;
import uk.gov.justice.domain.snapshot.DefaultObjectInputStreamStrategy;
diff --git a/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/example/cakeshop/it/helpers/StandaloneSubscriptionJdbcRepositoryFactory.java b/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/example/cakeshop/it/helpers/StandaloneSubscriptionJdbcRepositoryFactory.java
index 657f7194..2903d6c5 100644
--- a/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/example/cakeshop/it/helpers/StandaloneSubscriptionJdbcRepositoryFactory.java
+++ b/example-context/example-service/example-it/src/test/java/uk/gov/justice/services/example/cakeshop/it/helpers/StandaloneSubscriptionJdbcRepositoryFactory.java
@@ -1,6 +1,6 @@
package uk.gov.justice.services.example.cakeshop.it.helpers;
-import static uk.gov.justice.services.test.utils.common.reflection.ReflectionUtils.setField;
+import static uk.gov.justice.services.test.utils.core.reflection.ReflectionUtil.setField;
import uk.gov.justice.services.event.buffer.core.repository.subscription.SubscriptionJdbcRepository;
import uk.gov.justice.services.jdbc.persistence.JdbcRepositoryHelper;
diff --git a/example-context/example-service/pom.xml b/example-context/example-service/pom.xml
index 9365b165..35d0788f 100644
--- a/example-context/example-service/pom.xml
+++ b/example-context/example-service/pom.xml
@@ -27,6 +27,7 @@
example-it
example-liquibase
example-single
+ example-initialisation-liquibase
diff --git a/pom.xml b/pom.xml
index d3c6acb6..4a566035 100644
--- a/pom.xml
+++ b/pom.xml
@@ -31,19 +31,19 @@
cake-shop
1.28.0
- 5.0.4
+ 5.1.0-M3
1.2.0
- 1.0.4
- 1.0.3
- 1.0.2
+ 1.1.0-M1
+ 1.1.0-M3
+ 1.1.0-M1
1.17.1
- 3.0.1
+ 3.1.0-M2
2.6.1
1.4.2
2.2.0.Final
3.2.12.Final
1.6.3
- 1.18.1
+ 1.19.0
1.16.1