EndpointsTool { public void execute(String[] args) throws Exception { if (args.length < 1) { printUsage(); return; } EndpointsToolAction action = getActions().get(args[0]); if (action == null) { printUsage(); return; } Parser parser = new Parser(); ParseResult r = parser.parseArgs(action, action.getOptions(), Arrays.copyOfRange(args, 1, args.length)); r.applyArgs(); if (!action.execute()) { printUsage(action); } } EndpointsTool(); void execute(String[] args); void printUsage(); void printUsage(Action action); static void main(String[] args);  }
@Test public void testNoArguments() throws Exception { tool.execute(new String[]{}); assertTrue(usagePrinted); }
@Test public void testMissingCommand() throws Exception { tool.execute(new String[]{option(GetClientLibAction.OPTION_CLASS_PATH_SHORT), "classPath", option(GetClientLibAction.OPTION_OUTPUT_DIR_SHORT), "outputDir", "MyService"}); assertTrue(usagePrinted); }
@Test public void testUnknownCommand() throws Exception { tool.execute(new String[]{"no-such-command"}); assertTrue(usagePrinted); }