Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update framework to version 3.0.0 #25

Merged
merged 1 commit into from
Jan 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on [Keep a CHANGELOG](http://keepachangelog.com/). This project adheres to

## [Unreleased]

### Changed
- Update to use framework version 3.0.0

## [2.0.1] - 2017-11-09

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions archive-loader-fraction/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>uk.gov.justice.services</groupId>
<groupId>uk.gov.justice.framework-api</groupId>
<artifactId>framework-api-core</artifactId>
<version>${framework.version}</version>
<version>${framework-api.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void process() {

final FrameworkLibraries frameworkLibraries = new FrameworkLibraries(
"uk.gov.justice.services:event-repository-jdbc",
"uk.gov.justice.services:framework-api-core",
"uk.gov.justice.framework-api:framework-api-core",
"uk.gov.justice.services:core",
"uk.gov.justice.services:persistence-jdbc",
"uk.gov.justice.services:event-buffer-core");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class FrameworkLibrariesTest {
public void shouldReturnShrinkwrapArchives() throws Exception {
FrameworkLibraries frameworkLibraries = new FrameworkLibraries(
"uk.gov.justice.services:event-repository-jdbc:",
"uk.gov.justice.services:framework-api-core");
"uk.gov.justice.framework-api:framework-api-core");

Archive[] archives = frameworkLibraries.shrinkWrapArchives();

Expand All @@ -28,7 +28,7 @@ public void shouldReturnShrinkwrapArchives() throws Exception {
public void shouldReturnExclusionFilter() {
Filter<ArchivePath> filter = new FrameworkLibraries(
"uk.gov.justice.services:event-repository-jdbc",
"uk.gov.justice.services:framework-api-core")
"uk.gov.justice.framework-api:framework-api-core")
.exclusionFilter();

assertThat(filter.include(new BasicPath("/WEB-INF/lib/event-repository-jdbc")), is(false));
Expand Down
4 changes: 4 additions & 0 deletions framework-tools-replay/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
</exclusion>
<exclusion>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</exclusion>
</exclusions>
</dependency>

Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
<parent>
<groupId>uk.gov.justice</groupId>
<artifactId>maven-framework-parent-pom</artifactId>
<version>1.6.1</version>
<version>1.10.1</version>
</parent>

<artifactId>framework-tools</artifactId>
<packaging>pom</packaging>
<version>2.1.0-SNAPSHOT</version>

<properties>
<framework.version>2.2.1</framework.version>
<framework-api.version>1.1.0</framework-api.version>
<framework.version>3.0.0</framework.version>
<wildfly.swarm.version>2017.11.0</wildfly.swarm.version>
<test.utils.core.version>1.15.0</test.utils.core.version>
<test.utils.version>1.16.0</test.utils.version>
<cpp.repo.name>framework-tools</cpp.repo.name>
<uk.gov.justice.utils.version>1.5.0</uk.gov.justice.utils.version>
<version.swarm.fraction-plugin>77</version.swarm.fraction-plugin>
<!--
note h2 version is because swarm has its own version of h2 which we must use
Expand Down
10 changes: 5 additions & 5 deletions replay-tool-test/replay-tool-integration-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<dependency>
<groupId>uk.gov.justice.utils</groupId>
<artifactId>test-utils-core</artifactId>
<version>${test.utils.core.version}</version>
<version>${test.utils.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
Expand All @@ -41,9 +41,9 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>uk.gov.justice.services</groupId>
<artifactId>framework-api-messaging</artifactId>
<version>${framework.version}</version>
<groupId>uk.gov.justice.framework-api</groupId>
<artifactId>framework-api-core</artifactId>
<version>${framework-api.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -75,7 +75,7 @@
<artifactId>test-utils-logging-simple</artifactId>
<type>pom</type>
<scope>test</scope>
<version>${uk.gov.justice.utils.version}</version>
<version>${test.utils.version}</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ public class ReplayIntegrationIT {
private static final String PROCESS_FILE_LOCATION = TEST_PROPERTIES.value("process.file.location");
private static final String EXECUTION_TIMEOUT = TEST_PROPERTIES.value("replay.execution.timeout");

private static TestEventLogRepository EVENT_LOG_REPOSITORY;
private static TestEventRepository EVENT_LOG_REPOSITORY;

private static DataSource viewStoreDataSource;

@Before
public void setUpDB() throws Exception {
EVENT_LOG_REPOSITORY = new TestEventLogRepository();
EVENT_LOG_REPOSITORY = new TestEventRepository();
viewStoreDataSource = initViewStoreDb();
createProcessFile();
}

@Test
public void runReplayTool() throws Exception {
List<String> insertedEvents = EVENT_LOG_REPOSITORY.insertEventLogData(randomUUID());
final List<String> insertedEvents = EVENT_LOG_REPOSITORY.insertEventData(randomUUID());
runCommand(createCommandToExecuteReplay());
viewStoreEvents(viewStoreDataSource).forEach(viewStoreEvent -> {
System.out.println(format("viewStoreEvent with id %s", viewStoreEvent));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,45 @@
package uk.gov.justice.framework.tools.replay;


import org.apache.commons.dbcp2.BasicDataSource;
import static java.lang.String.format;
import static java.util.stream.Collectors.toList;
import static java.util.stream.LongStream.range;
import static uk.gov.justice.framework.tools.replay.DatabaseUtils.initEventStoreDb;
import static uk.gov.justice.services.test.utils.common.reflection.ReflectionUtils.setField;
import static uk.gov.justice.services.test.utils.core.messaging.JsonEnvelopeBuilder.envelope;
import static uk.gov.justice.services.test.utils.core.messaging.MetadataBuilderFactory.metadataWithRandomUUID;

import uk.gov.justice.services.eventsourcing.repository.jdbc.AnsiSQLEventLogInsertionStrategy;
import uk.gov.justice.services.eventsourcing.repository.jdbc.eventlog.EventLog;
import uk.gov.justice.services.eventsourcing.repository.jdbc.eventlog.EventLogJdbcRepository;
import uk.gov.justice.services.eventsourcing.repository.jdbc.event.Event;
import uk.gov.justice.services.eventsourcing.repository.jdbc.event.EventJdbcRepository;
import uk.gov.justice.services.eventsourcing.repository.jdbc.exception.InvalidSequenceIdException;
import uk.gov.justice.services.jdbc.persistence.JdbcRepositoryHelper;
import uk.gov.justice.services.messaging.JsonEnvelope;
import uk.gov.justice.services.messaging.Metadata;

import javax.sql.DataSource;
import java.sql.SQLException;
import java.time.ZonedDateTime;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;

import static java.lang.String.format;
import static uk.gov.justice.framework.tools.replay.DatabaseUtils.initEventStoreDb;
import static uk.gov.justice.services.messaging.JsonObjectMetadata.metadataWithRandomUUID;
import static uk.gov.justice.services.test.utils.common.reflection.ReflectionUtils.setField;
import static uk.gov.justice.services.test.utils.core.messaging.JsonEnvelopeBuilder.envelope;
import javax.sql.DataSource;

import org.apache.commons.dbcp2.BasicDataSource;

/**
* Standalone repository class to access event streams. To be used in integration testing
*/
public class TestEventLogRepository extends EventLogJdbcRepository {
public class TestEventRepository extends EventJdbcRepository {

private final DataSource datasource;

public TestEventLogRepository() throws Exception {
public TestEventRepository() throws Exception {
this.datasource = initEventStoreDb();
setField(this, "eventLogInsertionStrategy", new AnsiSQLEventLogInsertionStrategy());
setField(this, "eventInsertionStrategy", new AnsiSQLEventLogInsertionStrategy());
setField(this, "dataSource", datasource);
setField(this, "jdbcRepositoryHelper", new JdbcRepositoryHelper());
}

public TestEventLogRepository(final String url, final String username, final String password, final String driverClassName) {
public TestEventRepository(final String url, final String username, final String password, final String driverClassName) {
final BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName(driverClassName);
dataSource.setUrl(url);
Expand All @@ -43,26 +48,31 @@ public TestEventLogRepository(final String url, final String username, final Str
this.datasource = dataSource;
}

@Override
protected DataSource getDataSource() {
public DataSource getDataSource() {
return datasource;
}

public List<String> insertEventData(final UUID streamId) {
return range(1L, 6L)
.mapToObj(sequenceId -> insertEvent(streamId, sequenceId))
.collect(toList());
}

private String insertEvent(final UUID streamId, final long sequenceId) {
final Event event = eventFrom("framework.example-test", streamId, sequenceId);

System.out.println(format("Inserting event-stream with id %s", event.getId()));

public List<String> insertEventLogData(UUID streamId) throws InvalidSequenceIdException {
List<String> insertedEvents = new LinkedList<>();
Long sequenceId = 0L;
for (int count = 0; count < 5; count++) {
EventLog eventLog = eventLogFrom("framework.example-test", streamId, ++sequenceId);
System.out.println(format("Inserting event-stream with id %s", eventLog.getId()));
this.insert(eventLog);
insertedEvents.add(eventLog.getId().toString());
try {
insert(event);
} catch (final InvalidSequenceIdException e) {
throw new RuntimeException(e);
}
return insertedEvents;
}

return event.getId().toString();
}

private EventLog eventLogFrom(final String eventName, final UUID eventStreamId, final Long sequenceId) {
private Event eventFrom(final String eventName, final UUID eventStreamId, final long sequenceId) {

final JsonEnvelope jsonEnvelope = envelope()
.with(metadataWithRandomUUID(eventName)
Expand All @@ -80,7 +90,6 @@ private EventLog eventLogFrom(final String eventName, final UUID eventStreamId,
final String payload = jsonEnvelope.payloadAsJsonObject().toString();
final ZonedDateTime createdAt = metadata.createdAt().orElse(null);

return new EventLog(id, streamId, sequenceId, name, metadata.asJsonObject().toString(), payload, createdAt);
return new Event(id, streamId, sequenceId, name, metadata.asJsonObject().toString(), payload, createdAt);
}

}
12 changes: 6 additions & 6 deletions replay-tool-test/replay-tool-it-example-listener/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@
</properties>

<dependencies>
<dependency>
<groupId>uk.gov.justice.services</groupId>
<artifactId>event-listener</artifactId>
<version>${framework.version}</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>uk.gov.justice.services</groupId>
<artifactId>messaging-adapter-core</artifactId>
<version>${framework.version}</version>
</dependency>
<dependency>
<groupId>uk.gov.justice.services</groupId>
<artifactId>persistence-deltaspike</artifactId>
<version>2.2.1</version>
<version>${framework.version}</version>
</dependency>

<dependency>
Expand Down