### Question:
KeyUpdateCommand implements Callable<CliResult> { Path privateKeyPath() { if (Files.notExists(privateKeyPath)) { throw new IllegalArgumentException("Private key path must exist when updating key password"); } return privateKeyPath; } KeyUpdateCommand(KeyEncryptorFactory keyEncryptorFactory, PasswordReader passwordReader); @Override CliResult call(); CliResult execute(); @CommandLine.Option(names = "--keys.keyData.privateKeyPath", required = true)
    public Path privateKeyPath; @CommandLine.Option(names = "--keys.keyData.config.data.aopts.algorithm", defaultValue = "i")
    public String algorithm; @CommandLine.Option(names = "--keys.keyData.config.data.aopts.iterations", defaultValue = "10")
    public Integer iterations; @CommandLine.Option(names = "--keys.keyData.config.data.aopts.memory", defaultValue = "1048576")
    public Integer memory; @CommandLine.Option(names = "--keys.keyData.config.data.aopts.parallelism", defaultValue = "4")
    public Integer parallelism; @CommandLine.Option(names = {"--keys.passwords"})
    public String password; @CommandLine.Option(names = {"--keys.passwordFile"})
    public Path passwordFile; @CommandLine.Option(
            names = {"--configfile", "-configfile"},
            description = "Path to node configuration file")
    public Config config; @CommandLine.Mixin public EncryptorOptions encryptorOptions; @CommandLine.Mixin public DebugOptions debugOptions; }### Answer:
@Test public void cantReadPrivateKeyThrowsError() { command.privateKeyPath = Paths.get("/tmp/nonexisting.txt"); final Throwable throwable = catchThrowable(() -> command.privateKeyPath()); assertThat(throwable).isInstanceOf(IllegalArgumentException.class); }
@Test public void privateKeyExistsReturnsPath() throws IOException { final Path key = Files.createTempFile("key", ".key"); command.privateKeyPath = key; final Path path = command.privateKeyPath(); assertThat(path).isEqualTo(key); }