Skip to content

Commit

Permalink
Merge pull request #178 from CJSCommonPlatform/test-utils
Browse files Browse the repository at this point in the history
Clean processed_event table
  • Loading branch information
justin-r-oliver committed Oct 14, 2019
2 parents 9a85ff0 + 1ea8b32 commit 93d5210
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ public void cleanStreamStatusTable(final String contextName) {
cleanViewStoreTables(contextName, "stream_status");
}

/**
* Deletes all the data in the 'processed_event' table
*
* @param contextName the name of the context who's tables you are cleaning
*/
public void cleanProcessedEventTable(final String contextName) {
cleanViewStoreTables(contextName, "processed_event");
}

/**
* Deletes all the data in the Event-Store tables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,25 @@ public void shouldCleanTheStreamStatusTable() throws Exception {
verify(preparedStatement).close();
}

@Test
public void shouldCleanTheProcessedEventTable() throws Exception {

final String tableName = "processed_event";
final String contextName = "my-context";

final Connection connection = mock(Connection.class);
final PreparedStatement preparedStatement = mock(PreparedStatement.class);

when(testJdbcConnectionProvider.getViewStoreConnection(contextName)).thenReturn(connection);
when(connection.prepareStatement("DELETE FROM " + tableName)).thenReturn(preparedStatement);

databaseCleaner.cleanProcessedEventTable(contextName);

verify(preparedStatement).executeUpdate();
verify(connection).close();
verify(preparedStatement).close();
}

@Test
public void shouldThrowADataAccessExceptionIfCleaningAViewStoreTableFails() throws Exception {

Expand Down

0 comments on commit 93d5210

Please sign in to comment.