SystemCommandStateHandler { public void handleSystemCommandStateChanged(final SystemCommandStateChangedEvent systemCommandStateChangedEvent) { final UUID commandId = systemCommandStateChangedEvent.getCommandId(); final SystemCommand systemCommand = systemCommandStateChangedEvent.getSystemCommand(); final CommandState commandState = systemCommandStateChangedEvent.getCommandState(); final ZonedDateTime statusChangedAt = systemCommandStateChangedEvent.getStatusChangedAt(); final String message = systemCommandStateChangedEvent.getMessage(); systemCommandStateBean.addSystemCommandState(new SystemCommandStatus( commandId, systemCommand.getName(), commandState, statusChangedAt, message )); }  void handleSystemCommandStateChanged(final SystemCommandStateChangedEvent systemCommandStateChangedEvent);  }
@Test public void shouldHandleSystemCommand() throws Exception { final UUID commandId = randomUUID(); final TestCommand systemCommand = new TestCommand(); final CommandState commandState = COMMAND_IN_PROGRESS; final ZonedDateTime statusChangedAt = new UtcClock().now(); final String message = "message"; final SystemCommandStateChangedEvent systemCommandStateChangedEvent = new SystemCommandStateChangedEvent( commandId, systemCommand, commandState, statusChangedAt, message ); systemCommandStateHandler.handleSystemCommandStateChanged(systemCommandStateChangedEvent); verify(systemCommandStateBean).addSystemCommandState(systemCommandStatusCaptor.capture()); final SystemCommandStatus systemCommandStatus = systemCommandStatusCaptor.getValue(); assertThat(systemCommandStatus.getCommandId(), is(commandId)); assertThat(systemCommandStatus.getSystemCommandName(), is(systemCommand.getName())); assertThat(systemCommandStatus.getCommandState(), is(commandState)); assertThat(systemCommandStatus.getStatusChangedAt(), is(statusChangedAt)); assertThat(systemCommandStatus.getMessage(), is(message)); }