@Test public void testInstanceIdMandatory() throws Exception { DestroyInstanceCommand command = new DestroyInstanceCommand(); int rc = command.run(null, out, err, Collections.<String>emptyList()); assertThat(rc, is(-1)); String errOutput = errBytes.toString(); assertThat(errOutput, containsString("--instance-id is a mandatory argument")); }
@Override public int run(InputStream in, PrintStream out, PrintStream err, List<String> args) throws Exception { OptionSet optionSet = parser.parse(args.toArray(new String[args.size()])); if (!optionSet.nonOptionArguments().isEmpty()) { printUsage(err); return -1; } try { if (!optionSet.hasArgument(instanceOption)) { throw new IllegalArgumentException("--instance-id is a mandatory argument"); } ClusterSpec clusterSpec = getClusterSpec(optionSet); String instanceId = optionSet.valueOf(instanceOption); printProviderInfo(out, err, clusterSpec, optionSet); return run(in, out, err, clusterSpec, instanceId); } catch (IllegalArgumentException e) { printErrorAndHelpHint(err, e); return -1; } }
DestroyInstanceCommand extends AbstractClusterCommand { @Override public int run(InputStream in, PrintStream out, PrintStream err, List<String> args) throws Exception { OptionSet optionSet = parser.parse(args.toArray(new String[args.size()])); if (!optionSet.nonOptionArguments().isEmpty()) { printUsage(err); return -1; } try { if (!optionSet.hasArgument(instanceOption)) { throw new IllegalArgumentException("--instance-id is a mandatory argument"); } ClusterSpec clusterSpec = getClusterSpec(optionSet); String instanceId = optionSet.valueOf(instanceOption); printProviderInfo(out, err, clusterSpec, optionSet); return run(in, out, err, clusterSpec, instanceId); } catch (IllegalArgumentException e) { printErrorAndHelpHint(err, e); return -1; } } }
DestroyInstanceCommand extends AbstractClusterCommand { @Override public int run(InputStream in, PrintStream out, PrintStream err, List<String> args) throws Exception { OptionSet optionSet = parser.parse(args.toArray(new String[args.size()])); if (!optionSet.nonOptionArguments().isEmpty()) { printUsage(err); return -1; } try { if (!optionSet.hasArgument(instanceOption)) { throw new IllegalArgumentException("--instance-id is a mandatory argument"); } ClusterSpec clusterSpec = getClusterSpec(optionSet); String instanceId = optionSet.valueOf(instanceOption); printProviderInfo(out, err, clusterSpec, optionSet); return run(in, out, err, clusterSpec, instanceId); } catch (IllegalArgumentException e) { printErrorAndHelpHint(err, e); return -1; } } DestroyInstanceCommand();  DestroyInstanceCommand(ClusterControllerFactory factory); }
DestroyInstanceCommand extends AbstractClusterCommand { @Override public int run(InputStream in, PrintStream out, PrintStream err, List<String> args) throws Exception { OptionSet optionSet = parser.parse(args.toArray(new String[args.size()])); if (!optionSet.nonOptionArguments().isEmpty()) { printUsage(err); return -1; } try { if (!optionSet.hasArgument(instanceOption)) { throw new IllegalArgumentException("--instance-id is a mandatory argument"); } ClusterSpec clusterSpec = getClusterSpec(optionSet); String instanceId = optionSet.valueOf(instanceOption); printProviderInfo(out, err, clusterSpec, optionSet); return run(in, out, err, clusterSpec, instanceId); } catch (IllegalArgumentException e) { printErrorAndHelpHint(err, e); return -1; } } DestroyInstanceCommand();  DestroyInstanceCommand(ClusterControllerFactory factory); @Override int run(InputStream in, PrintStream out,
                 PrintStream err, List<String> args); int run(InputStream in, PrintStream out, PrintStream err,
                 ClusterSpec clusterSpec, String instanceId); @Override void printUsage(PrintStream stream); }
DestroyInstanceCommand extends AbstractClusterCommand { @Override public int run(InputStream in, PrintStream out, PrintStream err, List<String> args) throws Exception { OptionSet optionSet = parser.parse(args.toArray(new String[args.size()])); if (!optionSet.nonOptionArguments().isEmpty()) { printUsage(err); return -1; } try { if (!optionSet.hasArgument(instanceOption)) { throw new IllegalArgumentException("--instance-id is a mandatory argument"); } ClusterSpec clusterSpec = getClusterSpec(optionSet); String instanceId = optionSet.valueOf(instanceOption); printProviderInfo(out, err, clusterSpec, optionSet); return run(in, out, err, clusterSpec, instanceId); } catch (IllegalArgumentException e) { printErrorAndHelpHint(err, e); return -1; } } DestroyInstanceCommand();  DestroyInstanceCommand(ClusterControllerFactory factory); @Override int run(InputStream in, PrintStream out,
                 PrintStream err, List<String> args); int run(InputStream in, PrintStream out, PrintStream err,
                 ClusterSpec clusterSpec, String instanceId); @Override void printUsage(PrintStream stream);  }