### Question:
ConverterCommand implements ExecutableCommand { @Override public void executeCommand(CommandSender sender, List<String> arguments) { Class<? extends Converter> converterClass = getConverterClassFromArgs(arguments); if (converterClass == null) { sender.sendMessage("Converters: " + String.join(", ", CONVERTERS.keySet())); return; } final Converter converter = converterFactory.newInstance(converterClass); bukkitService.runTaskAsynchronously(new Runnable() { @Override public void run() { try { converter.execute(sender); } catch (Exception e) { commonService.send(sender, MessageKey.ERROR); ConsoleLogger.logException("Error during conversion:", e); } } }); sender.sendMessage("[AuthMe] Successfully started " + arguments.get(0)); }  @Override void executeCommand(CommandSender sender, List<String> arguments);  }### Answer:
@Test public void shouldHandleUnknownConversionType() { CommandSender sender = mock(CommandSender.class); command.executeCommand(sender, Collections.singletonList("invalid")); String converters = String.join(", ", ConverterCommand.CONVERTERS.keySet()); verify(sender).sendMessage(argThat(containsString(converters))); verifyZeroInteractions(commonService, converterFactory, bukkitService); }
@Test public void shouldHandleCommandWithNoArgs() { CommandSender sender = mock(CommandSender.class); command.executeCommand(sender, Collections.emptyList()); String converters = String.join(", ", ConverterCommand.CONVERTERS.keySet()); verify(sender).sendMessage(argThat(containsString(converters))); verifyZeroInteractions(commonService, converterFactory, bukkitService); }
@Test public void shouldLaunchConverterForAllTypes() { String converterName = "rakamak"; Class<? extends Converter> converterClass = ConverterCommand.CONVERTERS.get(converterName); Converter converter = createMockReturnedByInjector(converterClass); CommandSender sender = mock(CommandSender.class); setBukkitServiceToRunTaskAsynchronously(bukkitService); command.executeCommand(sender, Collections.singletonList(converterName)); verify(converter).execute(sender); verifyNoMoreInteractions(converter); verify(converterFactory).newInstance(converterClass); verifyNoMoreInteractions(converterFactory); }
@Test public void shouldCatchExceptionInConverterAndInformSender() { String converterName = "vauth"; Class<? extends Converter> converterClass = ConverterCommand.CONVERTERS.get(converterName); Converter converter = createMockReturnedByInjector(converterClass); doThrow(IllegalStateException.class).when(converter).execute(any(CommandSender.class)); CommandSender sender = mock(CommandSender.class); setBukkitServiceToRunTaskAsynchronously(bukkitService); command.executeCommand(sender, Collections.singletonList(converterName.toUpperCase())); verify(converter).execute(sender); verifyNoMoreInteractions(converter); verify(converterFactory).newInstance(converterClass); verifyNoMoreInteractions(converterFactory); verify(commonService).send(sender, MessageKey.ERROR); }