@Test public void testNoId() throws Exception { when(options.getString("host")).thenReturn(HOST); final int ret = command.run(options, client, out, false, null); assertThat(ret, equalTo(1)); assertThat(baos.toString(), containsString("You must specify the hostname and id.")); }
@Override int run(final Namespace options, final HeliosClient client, PrintStream out, final boolean json, final BufferedReader stdin) throws ExecutionException, InterruptedException { final String host = options.getString(hostArg.getDest()); final String id = options.getString(idArg.getDest()); if (isNullOrEmpty(host) || isNullOrEmpty(id)) { out.print("You must specify the hostname and id."); return 1; } out.printf("Registering host %s with id %s%n", host, id); int code = 0; out.printf("%s: ", host); final int result = client.registerHost(host, id).get(); if (result == 200) { out.printf("done%n"); } else { out.printf("failed: %s%n", result); code = 1; } return code; }
HostRegisterCommand extends ControlCommand { @Override int run(final Namespace options, final HeliosClient client, PrintStream out, final boolean json, final BufferedReader stdin) throws ExecutionException, InterruptedException { final String host = options.getString(hostArg.getDest()); final String id = options.getString(idArg.getDest()); if (isNullOrEmpty(host) || isNullOrEmpty(id)) { out.print("You must specify the hostname and id."); return 1; } out.printf("Registering host %s with id %s%n", host, id); int code = 0; out.printf("%s: ", host); final int result = client.registerHost(host, id).get(); if (result == 200) { out.printf("done%n"); } else { out.printf("failed: %s%n", result); code = 1; } return code; } }
HostRegisterCommand extends ControlCommand { @Override int run(final Namespace options, final HeliosClient client, PrintStream out, final boolean json, final BufferedReader stdin) throws ExecutionException, InterruptedException { final String host = options.getString(hostArg.getDest()); final String id = options.getString(idArg.getDest()); if (isNullOrEmpty(host) || isNullOrEmpty(id)) { out.print("You must specify the hostname and id."); return 1; } out.printf("Registering host %s with id %s%n", host, id); int code = 0; out.printf("%s: ", host); final int result = client.registerHost(host, id).get(); if (result == 200) { out.printf("done%n"); } else { out.printf("failed: %s%n", result); code = 1; } return code; } HostRegisterCommand(final Subparser parser); }
HostRegisterCommand extends ControlCommand { @Override int run(final Namespace options, final HeliosClient client, PrintStream out, final boolean json, final BufferedReader stdin) throws ExecutionException, InterruptedException { final String host = options.getString(hostArg.getDest()); final String id = options.getString(idArg.getDest()); if (isNullOrEmpty(host) || isNullOrEmpty(id)) { out.print("You must specify the hostname and id."); return 1; } out.printf("Registering host %s with id %s%n", host, id); int code = 0; out.printf("%s: ", host); final int result = client.registerHost(host, id).get(); if (result == 200) { out.printf("done%n"); } else { out.printf("failed: %s%n", result); code = 1; } return code; } HostRegisterCommand(final Subparser parser);  }
HostRegisterCommand extends ControlCommand { @Override int run(final Namespace options, final HeliosClient client, PrintStream out, final boolean json, final BufferedReader stdin) throws ExecutionException, InterruptedException { final String host = options.getString(hostArg.getDest()); final String id = options.getString(idArg.getDest()); if (isNullOrEmpty(host) || isNullOrEmpty(id)) { out.print("You must specify the hostname and id."); return 1; } out.printf("Registering host %s with id %s%n", host, id); int code = 0; out.printf("%s: ", host); final int result = client.registerHost(host, id).get(); if (result == 200) { out.printf("done%n"); } else { out.printf("failed: %s%n", result); code = 1; } return code; } HostRegisterCommand(final Subparser parser);   }