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

add stream transformation support for linked events #25

Merged

Conversation

MohamedFarouk-HMCTS
Copy link
Collaborator

No description provided.

@coveralls
Copy link

coveralls commented Mar 18, 2019

Coverage Status

Coverage decreased (-0.5%) to 91.64% when pulling 0cd9e44 on add-linked-event-support-for-transformations into 8055d70 on master.


logger.info("-------------- Truncating the Linked Events Log after complete transformation --------------");

linkedEventStreamTransformationService.truncateLinkedEvents();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you need to call truncateLinkedEvents() twice?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

@@ -158,19 +168,28 @@ public void shouldRemoveFinishedTaskForAllPasses() {

startTransformation.taskDone(future3, null, null, null);
assertThat(startTransformation.outstandingTasks.size(), is(0));

// verify(linkedEventStreamTransformationService).truncateLinkedEvents();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please uncomment/delete verify (although we should verify that truncateLinkedEvents() and populateLinkedEvents() are called )

pom.xml Outdated
@@ -23,8 +23,9 @@
<properties>
<cpp.repo.name>stream-transformation-tool</cpp.repo.name>

<framework.version>5.0.4</framework.version>
<event-store.version>1.0.4</event-store.version>
<framework.version>5.1.2-SNAPSHOT</framework.version>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't use snapshots please

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

waiting for the release version of frame work api

private final LiquibaseUtil liquibaseUtil = new LiquibaseUtil();

DataSource dataSource = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why dataSource was moved outside of DatabaseUtils() constructor?

Copy link
Collaborator Author

@MohamedFarouk-HMCTS MohamedFarouk-HMCTS Mar 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

datasource required for other test classes in the same package

@@ -15,7 +16,6 @@
private EventLogBuilder() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it EventLogBuilder or just EventBuilder?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EventLogBuilder


import javax.sql.DataSource;

public class TestLinkedEventJdbcRepository extends LinkedEventJdbcRepository {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is a test helper class, but maybe it's worth considering moving this logic to framework or test-utils so can be used by other people as well

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

}

@After
public void cleanup() throws Exception {
databaseUtils.resetDatabase();
// databaseUtils.resetDatabase();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove cleanup() please

import org.mockito.runners.MockitoJUnitRunner;

@RunWith(MockitoJUnitRunner.class)
public class LinkedEventStreamTransformationServiceTest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to test anything.

@@ -95,6 +99,9 @@ public void shouldCreateTasksForEachStream() {

assertThat(startTransformation.outstandingTasks.size(), is(2));
assertTrue(startTransformation.allTasksCreated);

// verify(linkedEventStreamTransformationService).truncateLinkedEvents();
// verify(linkedEventStreamTransformationService).populateLinkedEvents();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented out code can be removed

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

@@ -119,6 +126,9 @@ public void shouldRemoveFinishedTasks() {

startTransformation.taskDone(future2, null, null, null);
assertThat(startTransformation.outstandingTasks.size(), is(0));

// verify(linkedEventStreamTransformationService).truncateLinkedEvents();
// verify(linkedEventStreamTransformationService).populateLinkedEvents();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented out code can be removed

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

private final LiquibaseUtil liquibaseUtil = new LiquibaseUtil();

DataSource dataSource = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be private (and final if possible)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private not final used outside constructor

@@ -19,11 +20,11 @@

private TestEventLogJdbcRepository eventLogJdbcRepository;
private TestEventStreamJdbcRepository eventStreamJdbcRepository;

private EventFetcherRepository eventFetcherRepository = new EventFetcherRepository();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

CHANGELOG.md Outdated
@@ -5,6 +5,9 @@ on [Keep a CHANGELOG](http://keepachangelog.com/). This project adheres to

## [Unreleased]

## [5.2.0] - 2018-12-12
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like the wrong date

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

}


@Test(expected = IllegalArgumentException.class)
public void shouldThrowExceptionWhenstreamsProcessedCountStepInfoIsNull() throws Exception {
streamsProcessedCountStepInfo.set(startTransformation, null);
startTransformation.go();
//
// verify(linkedEventStreamTransformationService).truncateLinkedEvents();
// verify(linkedEventStreamTransformationService).populateLinkedEvents();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment code should be reinstated or deleted

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done as mentioned by allan and martin

<groupId>uk.gov.justice.framework-api</groupId>
<artifactId>framework-api-core</artifactId>
<version>${framework-api.version}</version>
</dependency>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is not a test dependency then it should be higher in the list

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

<groupId>uk.gov.justice.event-store</groupId>
<artifactId>event-repository-jdbc</artifactId>
<version>${event-store.version}</version>
</dependency>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non test dependencies above should be moved above the test dependency

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -20,24 +21,25 @@
public class StreamTransformationMoveIT {

private static final UUID STREAM_ID = randomUUID();
private static final long STREAM_COUNT_REPORTING_INTERVAL = 10l;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uppercase L is easier to read - 10L

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -75,7 +75,7 @@ public UUID transformEventStream(final UUID originalStreamId, final int pass) {

if (action.isTransform()) {
final Optional<UUID> newStreamId = eventTransformationStreamIdFilter.getEventTransformationStreamId(eventTransformations, jsonEnvelopeList);
if (newStreamId.isPresent()) {
if (newStreamId.isPresent() && !newStreamId.get().equals(originalStreamId)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this check be created as a method or value and have a descriptive name?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DONE

pom.xml Outdated

<framework.version>5.0.4</framework.version>
<event-store.version>1.0.4</event-store.version>
<framework-api.version>4.0.0-M2</framework-api.version>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

framework-api version is 3.1.1

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

pom.xml Outdated
<framework.version>5.0.4</framework.version>
<event-store.version>1.0.4</event-store.version>
<framework-api.version>4.0.0-M2</framework-api.version>
<framework.version>6.0.0-M4</framework.version>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

framework version is 5.1.2

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

CHANGELOG.md Outdated
@@ -5,6 +5,9 @@ on [Keep a CHANGELOG](http://keepachangelog.com/). This project adheres to

## [Unreleased]

## [5.2.0] - 2019-03-18
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong date now

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@MohamedFarouk-HMCTS MohamedFarouk-HMCTS force-pushed the add-linked-event-support-for-transformations branch 2 times, most recently from 8221936 to a3a6b07 Compare March 20, 2019 13:55
@MohamedFarouk-HMCTS MohamedFarouk-HMCTS force-pushed the add-linked-event-support-for-transformations branch from a3a6b07 to 2a128b5 Compare March 20, 2019 14:20
@MohamedFarouk-HMCTS MohamedFarouk-HMCTS force-pushed the add-linked-event-support-for-transformations branch from 2a128b5 to 0cd9e44 Compare March 20, 2019 14:56
@MohamedFarouk-HMCTS MohamedFarouk-HMCTS merged commit f66b22f into master Mar 20, 2019
@MohamedFarouk-HMCTS MohamedFarouk-HMCTS deleted the add-linked-event-support-for-transformations branch March 20, 2019 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants