Skip to content

Commit

Permalink
Merge 7edd1d5 into ce997bb
Browse files Browse the repository at this point in the history
  • Loading branch information
allanmckenzie committed Apr 11, 2019
2 parents ce997bb + 7edd1d5 commit bdadfbb
Show file tree
Hide file tree
Showing 35 changed files with 556 additions and 329 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ on [Keep a CHANGELOG](http://keepachangelog.com/). This project adheres to

## [Unreleased]

### Added
- Integration Test for Event Catchup
### Changed
- Update Shuttering Integration Test


## [2.0.0-M2] - 2019-04-08

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,4 @@ public void shouldHandlePhotographAddedEvent() throws Exception {
verify(recipe).setPhotoId(photoId);
verify(recipeRepository).save(recipe);
}
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

30 changes: 13 additions & 17 deletions example-context/example-service/example-it/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-jms-client</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>uk.gov.justice.event-store</groupId>
Expand Down Expand Up @@ -187,7 +188,18 @@
<artifactId>jmx</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>uk.gov.justice.event-store</groupId>
<artifactId>linked-event-processor</artifactId>
<version>${event-store.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>uk.gov.justice.services.example</groupId>
<artifactId>example-persistence</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -225,17 +237,6 @@
<goal>update</goal>
</goals>
</execution>
<execution>
<id>initialise-event-log-liquibase</id>
<configuration>
<changeLogFile>liquibase/initialise-event-log-db-changelog.xml</changeLogFile>
<url>jdbc:postgresql://localhost:5432/frameworkeventstore</url>
</configuration>
<phase>pre-integration-test</phase>
<goals>
<goal>update</goal>
</goals>
</execution>
<execution>
<id>event-buffer-liquibase</id>
<configuration>
Expand Down Expand Up @@ -316,11 +317,6 @@
<artifactId>subscription-repository-liquibase</artifactId>
<version>${event-store.version}</version>
</dependency>
<dependency>
<groupId>uk.gov.justice.services.example</groupId>
<artifactId>example-initialisation-liquibase</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public class EventRepositoryFactory {

public EventJdbcRepository getEventJdbcRepository(final DataSource dataSource) throws IllegalAccessException {
public EventJdbcRepository getEventJdbcRepository(final DataSource dataSource) {
final EventJdbcRepository eventJdbcRepository = new EventJdbcRepository(
new AnsiSQLEventLogInsertionStrategy(),
new JdbcRepositoryHelper(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package uk.gov.justice.services.eventsourcing.repository.jdbc.event;

import static org.slf4j.LoggerFactory.getLogger;
import static uk.gov.justice.services.test.utils.core.reflection.ReflectionUtil.setField;

import uk.gov.justice.services.common.util.UtcClock;
import uk.gov.justice.services.eventsourcing.repository.jdbc.eventstream.EventStreamJdbcRepository;
import uk.gov.justice.services.jdbc.persistence.DefaultJdbcDataSourceProvider;
import uk.gov.justice.services.jdbc.persistence.JdbcRepositoryHelper;

import javax.sql.DataSource;

public class EventStreamJdbsRepositoryFactory {

public EventStreamJdbcRepository getEventStreamJdbcRepository(final DataSource dataSource) {

final EventStreamJdbcRepository eventStreamJdbcRepository = new EventStreamJdbcRepository(
new JdbcRepositoryHelper(),
new DefaultJdbcDataSourceProvider(),
new UtcClock(),
null,
getLogger(EventStreamJdbcRepository.class));

setField(eventStreamJdbcRepository, "dataSource", dataSource);

return eventStreamJdbcRepository;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package uk.gov.justice.services.eventsourcing.repository.jdbc.event;

import java.sql.SQLException;

import javax.sql.DataSource;

public class LinkedEventRepositoryTruncator {

private final DataSource datasource;
private final LinkedEventJdbcRepository linkedEventJdbcRepository;

public LinkedEventRepositoryTruncator(final DataSource datasource) {
this.datasource = datasource;
this.linkedEventJdbcRepository = new LinkedEventJdbcRepository();
}

public void truncate() throws SQLException {
linkedEventJdbcRepository.truncate(datasource.getConnection());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
import static uk.gov.justice.services.example.cakeshop.it.params.CakeShopUris.RECIPES_RESOURCE_URI;

import uk.gov.justice.services.eventsourcing.repository.jdbc.event.Event;
import uk.gov.justice.services.example.cakeshop.it.helpers.CakeShopRepositoryManager;
import uk.gov.justice.services.eventsourcing.repository.jdbc.event.EventJdbcRepository;
import uk.gov.justice.services.eventsourcing.repository.jdbc.event.EventRepositoryFactory;
import uk.gov.justice.services.example.cakeshop.it.helpers.DatabaseManager;
import uk.gov.justice.services.example.cakeshop.it.helpers.EventFinder;
import uk.gov.justice.services.example.cakeshop.it.helpers.RestEasyClientFactory;
import uk.gov.justice.services.test.utils.core.http.HttpResponsePoller;
Expand All @@ -26,27 +28,23 @@
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

import javax.sql.DataSource;
import javax.ws.rs.client.Client;

import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

public class CakeShopConcurrencyIT {

private static final CakeShopRepositoryManager CAKE_SHOP_REPOSITORY_MANAGER = new CakeShopRepositoryManager();
private final DataSource eventStoreDataSource = new DatabaseManager().initEventStoreDb();
private final EventJdbcRepository eventJdbcRepository = new EventRepositoryFactory().getEventJdbcRepository(eventStoreDataSource);

private final HttpResponsePoller httpResponsePoller = new HttpResponsePoller();
private final EventFinder eventFinder = new EventFinder(CAKE_SHOP_REPOSITORY_MANAGER);
private final EventFinder eventFinder = new EventFinder(eventJdbcRepository);

private Client client;

@BeforeClass
public static void beforeClass() throws Exception {
CAKE_SHOP_REPOSITORY_MANAGER.initialise();
}

@Before
public void before() throws Exception {
client = new RestEasyClientFactory().createResteasyClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,19 @@
import static org.hamcrest.core.IsNull.nullValue;
import static uk.gov.justice.services.example.cakeshop.it.params.CakeShopUris.ORDERS_RESOURCE_URI;

import uk.gov.justice.services.example.cakeshop.it.helpers.CakeShopRepositoryManager;
import uk.gov.justice.services.example.cakeshop.it.helpers.RestEasyClientFactory;

import javax.ws.rs.client.Client;
import javax.ws.rs.core.Response;

import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

public class CakeShopCrossOriginResourceSharingIT {

private static final CakeShopRepositoryManager CAKE_SHOP_REPOSITORY_MANAGER = new CakeShopRepositoryManager();

private Client client;

@BeforeClass
public static void beforeClass() throws Exception {
CAKE_SHOP_REPOSITORY_MANAGER.initialise();
}

@Before
public void before() throws Exception {
client = new RestEasyClientFactory().createResteasyClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,32 @@
import static uk.gov.justice.services.example.cakeshop.it.params.CakeShopMediaTypes.CONTEXT_NAME;
import static uk.gov.justice.services.example.cakeshop.it.params.CakeShopUris.RECIPES_RESOURCE_URI;

import uk.gov.justice.services.event.buffer.core.repository.subscription.StreamStatusJdbcRepository;
import uk.gov.justice.services.event.buffer.core.repository.subscription.Subscription;
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.DatabaseManager;
import uk.gov.justice.services.example.cakeshop.it.helpers.RestEasyClientFactory;
import uk.gov.justice.services.example.cakeshop.it.helpers.StandaloneStreamStatusJdbcRepositoryFactory;

import java.util.Optional;

import javax.sql.DataSource;
import javax.ws.rs.client.Client;

import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

public class CakeShopEventBufferingIT {

private static final CakeShopRepositoryManager CAKE_SHOP_REPOSITORY_MANAGER = new CakeShopRepositoryManager();
private final DataSource viewStoreDatasource = new DatabaseManager().initViewStoreDb();
private final StandaloneStreamStatusJdbcRepositoryFactory standaloneStreamStatusJdbcRepositoryFactory = new StandaloneStreamStatusJdbcRepositoryFactory();
private final StreamStatusJdbcRepository streamStatusJdbcRepository = standaloneStreamStatusJdbcRepositoryFactory.getStreamStatusJdbcRepository(viewStoreDatasource);

private final CommandFactory commandFactory = new CommandFactory();

private Client client;

@BeforeClass
public static void beforeClass() throws Exception {
CAKE_SHOP_REPOSITORY_MANAGER.initialise();
}

@Before
public void before() throws Exception {
client = new RestEasyClientFactory().createResteasyClient();
Expand All @@ -61,6 +60,6 @@ public void shouldUpdateEventBufferStatus() throws Exception {

@SuppressWarnings("SameParameterValue")
private Optional<Subscription> subscription(final String recipeId) {
return CAKE_SHOP_REPOSITORY_MANAGER.getStreamStatusJdbcRepository().findByStreamIdAndSource(fromString(recipeId), CONTEXT_NAME);
return streamStatusJdbcRepository.findByStreamIdAndSource(fromString(recipeId), CONTEXT_NAME);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import static uk.gov.justice.services.test.utils.core.matchers.HttpStatusCodeMatcher.isStatus;

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.CommandSender;
import uk.gov.justice.services.example.cakeshop.it.helpers.EventFactory;
import uk.gov.justice.services.example.cakeshop.it.helpers.Querier;
Expand All @@ -34,25 +33,16 @@
import org.apache.http.message.BasicNameValuePair;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

public class CakeShopFailuresIT {

private static final CakeShopRepositoryManager CAKE_SHOP_REPOSITORY_MANAGER = new CakeShopRepositoryManager();

private final EventFactory eventFactory = new EventFactory();

private Client client;
private Querier querier;
private CommandSender commandSender;


@BeforeClass
public static void beforeClass() throws Exception {
CAKE_SHOP_REPOSITORY_MANAGER.initialise();
}

@Before
public void before() throws Exception {
client = new RestEasyClientFactory().createResteasyClient();
Expand Down
Loading

0 comments on commit bdadfbb

Please sign in to comment.