Skip to content
This repository was archived by the owner on Aug 13, 2020. It is now read-only.

Commit 769b454

Browse files
Merge pull request #790 from CJSCommonPlatform/add-new-command
Add new ValidatePublishedEventsCommand
2 parents 1b49cb0 + c1e4c1a commit 769b454

File tree

4 files changed

+42
-0
lines changed

4 files changed

+42
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on [Keep a CHANGELOG](http://keepachangelog.com/). This project adheres to
55

66
## [Unreleased]
77

8+
## [6.2.4] - 2019-11-04
9+
### Added
10+
- New command ValidatePublishedEventsCommand that is for checking that all events fulfil their schemas
11+
812
## [6.2.3] - 2019-10-31
913
### Changed
1014
- Commands now fail with an UnrunnableSystemCommandException if the command is already in progress
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package uk.gov.justice.services.jmx.api.command;
2+
3+
public class ValidatePublishedEventsCommand extends BaseSystemCommand {
4+
5+
public static final String VALIDATE_EVENTS = "VALIDATE_EVENTS";
6+
public static final String DESCRIPTION = "Validates that all payloads of published events abide by their schemas.";
7+
8+
public ValidatePublishedEventsCommand() {
9+
super(VALIDATE_EVENTS, DESCRIPTION);
10+
}
11+
}

test-utils/test-utils-jmx/src/main/java/uk/gov/justice/services/jmx/system/command/client/SystemCommandCaller.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import uk.gov.justice.services.jmx.api.command.ShutterCommand;
1212
import uk.gov.justice.services.jmx.api.command.SystemCommand;
1313
import uk.gov.justice.services.jmx.api.command.UnshutterCommand;
14+
import uk.gov.justice.services.jmx.api.command.ValidatePublishedEventsCommand;
1415
import uk.gov.justice.services.jmx.api.command.VerifyCatchupCommand;
1516
import uk.gov.justice.services.jmx.system.command.client.connection.JmxParameters;
1617

@@ -81,6 +82,10 @@ public void callValidateCatchup() {
8182
callSystemCommand(new VerifyCatchupCommand());
8283
}
8384

85+
public void callValidatePublishedEvents() {
86+
callSystemCommand(new ValidatePublishedEventsCommand());
87+
}
88+
8489
private void callSystemCommand(final SystemCommand systemCommand) {
8590
try (final SystemCommanderClient systemCommanderClient = testSystemCommanderClientFactory.create(jmxParameters)) {
8691
systemCommanderClient.getRemote(jmxParameters.getContextName()).call(systemCommand);

test-utils/test-utils-jmx/src/test/java/uk/gov/justice/services/jmx/system/command/client/SystemCommandCallerTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import uk.gov.justice.services.jmx.api.command.RemoveTriggerCommand;
1717
import uk.gov.justice.services.jmx.api.command.ShutterCommand;
1818
import uk.gov.justice.services.jmx.api.command.UnshutterCommand;
19+
import uk.gov.justice.services.jmx.api.command.ValidatePublishedEventsCommand;
1920
import uk.gov.justice.services.jmx.api.command.VerifyCatchupCommand;
2021
import uk.gov.justice.services.jmx.api.mbean.SystemCommanderMBean;
2122
import uk.gov.justice.services.jmx.system.command.client.connection.Credentials;
@@ -202,6 +203,27 @@ public void shouldCallValidateCatchup() throws Exception {
202203
verify(systemCommanderClient).close();
203204
}
204205

206+
@Test
207+
public void shouldCallValidatePublishedEvents() throws Exception {
208+
209+
final String contextName = "contextName";
210+
211+
final JmxParameters jmxParameters = mock(JmxParameters.class);
212+
final SystemCommanderClient systemCommanderClient = mock(SystemCommanderClient.class);
213+
final SystemCommanderMBean systemCommanderMBean = mock(SystemCommanderMBean.class);
214+
215+
final SystemCommandCaller systemCommandCaller = new SystemCommandCaller(jmxParameters, testSystemCommanderClientFactory);
216+
217+
when(jmxParameters.getContextName()).thenReturn(contextName);
218+
when(testSystemCommanderClientFactory.create(jmxParameters)).thenReturn(systemCommanderClient);
219+
when(systemCommanderClient.getRemote(contextName)).thenReturn(systemCommanderMBean);
220+
221+
systemCommandCaller.callValidatePublishedEvents();
222+
223+
verify(systemCommanderMBean).call(new ValidatePublishedEventsCommand());
224+
verify(systemCommanderClient).close();
225+
}
226+
205227
@Test
206228
public void shouldCreateWithCorrectDefaultParametersIfInstantiatingUsingTheContextName() throws Exception {
207229

0 commit comments

Comments
 (0)