### Question:
ProcessCodeCommand extends PlayerCommand { @Override protected void runCommand(Player player, List<String> arguments) { String name = player.getName(); String code = arguments.get(0); if (codeService.hasTriesLeft(name)) { if (codeService.isCodeValid(name, code)) { commonService.send(player, MessageKey.RECOVERY_CODE_CORRECT); recoveryService.addSuccessfulRecovery(player); codeService.removeCode(name); } else { commonService.send(player, MessageKey.INCORRECT_RECOVERY_CODE, Integer.toString(codeService.getTriesLeft(name))); } } else { codeService.removeCode(name); commonService.send(player, MessageKey.RECOVERY_TRIES_EXCEEDED); } }    }### Answer:
@Test public void shouldProcessCorrectCode() { String name = "Dwight"; String code = "chickenDinner"; Player sender = mock(Player.class); given(sender.getName()).willReturn(name); given(codeService.hasTriesLeft(name)).willReturn(true); given(codeService.isCodeValid(name, code)).willReturn(true); command.runCommand(sender, Collections.singletonList(code)); verify(commonService).send(sender, MessageKey.RECOVERY_CODE_CORRECT); verify(recoveryService).addSuccessfulRecovery(sender); verify(codeService).removeCode(name); }