SystemCommander implements SystemCommanderMBean { @Override public List<SystemCommandDetails> listCommands() { return systemCommandScanner.findCommands().stream() .map(commandConverter::toCommandDetails) .collect(toList()); }  @Override UUID call(final String systemCommandName); @Override List<SystemCommandDetails> listCommands(); @Override SystemCommandStatus getCommandStatus(final UUID commandId);  }
@Test public void shouldListAllSystemCommands() throws Exception { final SystemCommand systemCommand_1 = mock(SystemCommand.class); final SystemCommand systemCommand_2 = mock(SystemCommand.class); final SystemCommand systemCommand_3 = mock(SystemCommand.class); final SystemCommandDetails systemCommandDetails_1 = mock(SystemCommandDetails.class); final SystemCommandDetails systemCommandDetails_2 = mock(SystemCommandDetails.class); final SystemCommandDetails systemCommandDetails_3 = mock(SystemCommandDetails.class); when(systemCommandScanner.findCommands()).thenReturn(asList( systemCommand_1, systemCommand_2, systemCommand_3)); when(commandConverter.toCommandDetails(systemCommand_1)).thenReturn(systemCommandDetails_1); when(commandConverter.toCommandDetails(systemCommand_2)).thenReturn(systemCommandDetails_2); when(commandConverter.toCommandDetails(systemCommand_3)).thenReturn(systemCommandDetails_3); final List<SystemCommandDetails> systemCommandDetails = systemCommander.listCommands(); assertThat(systemCommandDetails.size(), is(3)); assertThat(systemCommandDetails, hasItem(systemCommandDetails_1)); assertThat(systemCommandDetails, hasItem(systemCommandDetails_2)); assertThat(systemCommandDetails, hasItem(systemCommandDetails_3)); }