Skip to content

Commit

Permalink
Merge 2053a44 into 09ffa12
Browse files Browse the repository at this point in the history
  • Loading branch information
allanmckenzie committed Jun 27, 2019
2 parents 09ffa12 + 2053a44 commit ed96ff8
Show file tree
Hide file tree
Showing 17 changed files with 27 additions and 44 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on [Keep a CHANGELOG](http://keepachangelog.com/). This project adheres to

## [Unreleased]

## [2.0.0-RC2] - 2019-06-27
### Fixed
- fix of the pubish_queue draining problem

## [2.0.0-RC1] - 2019-06-27

### Added
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package uk.gov.justice.services.eventstore.management.indexer.events;

import uk.gov.justice.services.eventstore.management.catchup.events.CatchupCompletedEvent;
import uk.gov.justice.services.jmx.command.SystemCommand;

import java.time.ZonedDateTime;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package uk.gov.justice.services.eventstore.management.indexer.events;

import uk.gov.justice.services.eventstore.management.catchup.events.CatchupCompletedForSubscriptionEvent;
import uk.gov.justice.services.jmx.command.SystemCommand;

import java.time.ZonedDateTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static java.lang.String.format;
import static uk.gov.justice.services.core.annotation.Component.EVENT_INDEXER;
import static uk.gov.justice.services.core.annotation.Component.EVENT_LISTENER;

import uk.gov.justice.services.eventstore.management.indexer.events.IndexerCatchupRequestedEvent;
import uk.gov.justice.subscription.domain.subscriptiondescriptor.Subscription;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

import static javax.transaction.Transactional.TxType.NOT_SUPPORTED;

import uk.gov.justice.services.eventstore.management.catchup.process.CatchupContext;
import uk.gov.justice.subscription.domain.subscriptiondescriptor.Subscription;

import javax.ejb.Stateless;
import javax.inject.Inject;
import javax.transaction.Transactional;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static uk.gov.justice.services.eventstore.management.rebuild.commands.RebuildCommand.REBUILD;

import uk.gov.justice.services.common.util.UtcClock;
import uk.gov.justice.services.eventstore.management.catchup.commands.CatchupCommand;
import uk.gov.justice.services.eventstore.management.rebuild.events.RebuildCompleteEvent;
import uk.gov.justice.services.eventstore.management.rebuild.events.RebuildRequestedEvent;
import uk.gov.justice.services.jmx.command.HandlesSystemCommand;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ public boolean pollUntilPublishQueueEmpty() {
NUMBER_OF_POLLING_ITERATIONS,
WAIT_TIME_BETWEEN_ITERATIONS_MILLIS);

return multiIteratingPoller.pollUntilTrue(() -> eventDeQueuer.getSizeOfQueue("published_event") == 0);
return multiIteratingPoller.pollUntilTrue(() -> eventDeQueuer.getSizeOfQueue("publish_queue") == 0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;

import uk.gov.justice.services.common.util.UtcClock;
import uk.gov.justice.services.eventstore.management.catchup.commands.CatchupCommand;
import uk.gov.justice.services.eventstore.management.indexer.events.IndexerCatchupCompletedEvent;
import uk.gov.justice.services.eventstore.management.indexer.events.IndexerCatchupRequestedEvent;
import uk.gov.justice.services.jmx.command.SystemCommand;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

import uk.gov.justice.services.eventstore.management.catchup.process.CatchupContext;
import uk.gov.justice.services.eventstore.management.catchup.process.EventCatchupTask;
import uk.gov.justice.subscription.domain.subscriptiondescriptor.Subscription;

import javax.enterprise.concurrent.ManagedExecutorService;

import org.junit.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import uk.gov.justice.services.eventstore.management.catchup.process.CatchupContext;
import uk.gov.justice.services.eventstore.management.indexer.process.EventIndexerCatchupProcessor;
import uk.gov.justice.subscription.domain.subscriptiondescriptor.Subscription;

import org.junit.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import uk.gov.justice.services.event.sourcing.subscription.catchup.consumer.manager.EventStreamConsumerManager;
import uk.gov.justice.services.event.sourcing.subscription.manager.PublishedEventSourceProvider;
import uk.gov.justice.services.eventsourcing.source.core.PublishedEventSource;
import uk.gov.justice.services.eventstore.management.catchup.events.CatchupCompletedForSubscriptionEvent;
import uk.gov.justice.services.eventstore.management.catchup.events.CatchupStartedForSubscriptionEvent;
import uk.gov.justice.services.eventstore.management.indexer.events.IndexerCatchupCompletedForSubscriptionEvent;
import uk.gov.justice.services.eventstore.management.indexer.events.IndexerCatchupRequestedEvent;
import uk.gov.justice.services.eventstore.management.indexer.events.IndexerCatchupStartedForSubscriptionEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import static org.mockito.Mockito.when;

import uk.gov.justice.services.common.util.UtcClock;
import uk.gov.justice.services.eventstore.management.catchup.events.CatchupCompletedForSubscriptionEvent;
import uk.gov.justice.services.eventstore.management.catchup.process.CatchupInProgress;
import uk.gov.justice.services.eventstore.management.indexer.events.IndexerCatchupCompletedForSubscriptionEvent;

import java.time.Duration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
import static java.time.ZoneOffset.UTC;
import static java.time.ZonedDateTime.of;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import uk.gov.justice.services.common.util.UtcClock;
import uk.gov.justice.services.eventsourcing.publishedevent.rebuild.PublishedEventRebuilder;
import uk.gov.justice.services.eventstore.management.rebuild.commands.RebuildCommand;
import uk.gov.justice.services.eventstore.management.rebuild.events.RebuildRequestedEvent;
import uk.gov.justice.services.eventstore.management.rebuild.events.RebuildCompleteEvent;
import uk.gov.justice.services.jmx.command.SystemCommand;
import uk.gov.justice.services.eventstore.management.rebuild.events.RebuildRequestedEvent;

import java.time.ZonedDateTime;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
package uk.gov.justice.services.eventstore.management.shuttering.observers;

import static java.lang.String.format;

import org.apache.commons.lang3.time.StopWatch;
import org.junit.runner.RunWith;
import org.mockito.InOrder;
import org.mockito.runners.MockitoJUnitRunner;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.slf4j.Logger;

import static org.hamcrest.CoreMatchers.is;
import static org.mockito.Mockito.*;

import uk.gov.justice.services.eventsourcing.util.jee.timer.StopWatchFactory;
import uk.gov.justice.services.eventstore.management.shuttering.process.PublishQueueInterrogator;
import uk.gov.justice.services.jmx.command.SystemCommand;
import uk.gov.justice.services.management.shuttering.events.ShutteringProcessStartedEvent;
import uk.gov.justice.services.management.shuttering.observers.shuttering.ShutteringRegistry;

import org.apache.commons.lang3.time.StopWatch;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InOrder;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.slf4j.Logger;


@RunWith(MockitoJUnitRunner.class)
public class PublishQueueDrainedShutteringObserverTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,22 @@
@RunWith(MockitoJUnitRunner.class)
public class PublishQueueInterrogatorTest {

private static final String PUBLISH_QUEUE_TABLE_NAME = "publish_queue";

@Mock
private EventDeQueuer eventDeQueuer;

@Mock
private MultiIteratingPollerFactory multiIteratingPollerFactory;

@InjectMocks
private PublishQueueInterrogator publishQueueInterrogator;

@Test
public void shouldPollPublishQueueUntilItIsEmpty() throws Exception {

when(multiIteratingPollerFactory.create(3, 500L, 3, 500L)).thenReturn(new DummyMultiIteratingPoller());
when(eventDeQueuer.getSizeOfQueue("published_event")).thenReturn(0);
when(eventDeQueuer.getSizeOfQueue(PUBLISH_QUEUE_TABLE_NAME)).thenReturn(0);

assertThat(publishQueueInterrogator.pollUntilPublishQueueEmpty(), is(true));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void cleanViewStoreTables(final String contextName, final String tableNam
public void cleanSystemTables(final String contextName) {

try (final Connection connection = testJdbcConnectionProvider.getSystemConnection(contextName)) {
cleanTable("shuttered_command_store", connection);
cleanTable("stored_command", connection);
} catch (SQLException e) {
throw new DataAccessException("Failed to commit or close database connection", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void shouldCleanTheSystemTables() throws Exception {
final PreparedStatement preparedStatement = mock(PreparedStatement.class);

when(testJdbcConnectionProvider.getSystemConnection(contextName)).thenReturn(connection);
when(connection.prepareStatement("DELETE FROM " + "shuttered_command_store")).thenReturn(preparedStatement);
when(connection.prepareStatement("DELETE FROM " + "stored_command")).thenReturn(preparedStatement);

databaseCleaner.cleanSystemTables(contextName);

Expand Down Expand Up @@ -203,7 +203,7 @@ public void shouldThrowADatAccessExceptionIfClosingTheViewStoreConnectionFails()
@Test
public void shouldThrowADatAccessExceptionIfClosingTheSystemConnectionFails() throws Exception {

final String tableName = "shuttered_command_store";
final String tableName = "stored_command";
final String contextName = "my-context";

final SQLException sqlException = new SQLException("Oops");
Expand All @@ -218,7 +218,7 @@ public void shouldThrowADatAccessExceptionIfClosingTheSystemConnectionFails() th
try {
databaseCleaner.cleanSystemTables(contextName);
fail();
} catch (Exception expected) {
} catch (final DataAccessException expected) {
assertThat(expected.getCause(), is(sqlException));
}

Expand Down

0 comments on commit ed96ff8

Please sign in to comment.