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

Commit

Permalink
Add new ValidatePublishedEventsCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
amckenzie committed Nov 4, 2019
1 parent 1b49cb0 commit c1e4c1a
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 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]

## [6.2.4] - 2019-11-04
### Added
- New command ValidatePublishedEventsCommand that is for checking that all events fulfil their schemas

## [6.2.3] - 2019-10-31
### Changed
- Commands now fail with an UnrunnableSystemCommandException if the command is already in progress
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package uk.gov.justice.services.jmx.api.command;

public class ValidatePublishedEventsCommand extends BaseSystemCommand {

public static final String VALIDATE_EVENTS = "VALIDATE_EVENTS";
public static final String DESCRIPTION = "Validates that all payloads of published events abide by their schemas.";

public ValidatePublishedEventsCommand() {
super(VALIDATE_EVENTS, DESCRIPTION);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import uk.gov.justice.services.jmx.api.command.ShutterCommand;
import uk.gov.justice.services.jmx.api.command.SystemCommand;
import uk.gov.justice.services.jmx.api.command.UnshutterCommand;
import uk.gov.justice.services.jmx.api.command.ValidatePublishedEventsCommand;
import uk.gov.justice.services.jmx.api.command.VerifyCatchupCommand;
import uk.gov.justice.services.jmx.system.command.client.connection.JmxParameters;

Expand Down Expand Up @@ -81,6 +82,10 @@ public void callValidateCatchup() {
callSystemCommand(new VerifyCatchupCommand());
}

public void callValidatePublishedEvents() {
callSystemCommand(new ValidatePublishedEventsCommand());
}

private void callSystemCommand(final SystemCommand systemCommand) {
try (final SystemCommanderClient systemCommanderClient = testSystemCommanderClientFactory.create(jmxParameters)) {
systemCommanderClient.getRemote(jmxParameters.getContextName()).call(systemCommand);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import uk.gov.justice.services.jmx.api.command.RemoveTriggerCommand;
import uk.gov.justice.services.jmx.api.command.ShutterCommand;
import uk.gov.justice.services.jmx.api.command.UnshutterCommand;
import uk.gov.justice.services.jmx.api.command.ValidatePublishedEventsCommand;
import uk.gov.justice.services.jmx.api.command.VerifyCatchupCommand;
import uk.gov.justice.services.jmx.api.mbean.SystemCommanderMBean;
import uk.gov.justice.services.jmx.system.command.client.connection.Credentials;
Expand Down Expand Up @@ -202,6 +203,27 @@ public void shouldCallValidateCatchup() throws Exception {
verify(systemCommanderClient).close();
}

@Test
public void shouldCallValidatePublishedEvents() throws Exception {

final String contextName = "contextName";

final JmxParameters jmxParameters = mock(JmxParameters.class);
final SystemCommanderClient systemCommanderClient = mock(SystemCommanderClient.class);
final SystemCommanderMBean systemCommanderMBean = mock(SystemCommanderMBean.class);

final SystemCommandCaller systemCommandCaller = new SystemCommandCaller(jmxParameters, testSystemCommanderClientFactory);

when(jmxParameters.getContextName()).thenReturn(contextName);
when(testSystemCommanderClientFactory.create(jmxParameters)).thenReturn(systemCommanderClient);
when(systemCommanderClient.getRemote(contextName)).thenReturn(systemCommanderMBean);

systemCommandCaller.callValidatePublishedEvents();

verify(systemCommanderMBean).call(new ValidatePublishedEventsCommand());
verify(systemCommanderClient).close();
}

@Test
public void shouldCreateWithCorrectDefaultParametersIfInstantiatingUsingTheContextName() throws Exception {

Expand Down

0 comments on commit c1e4c1a

Please sign in to comment.