ListFunctionsCommand extends AbstractCommand { public static ListFunctionsCommand parse(String commandString, ExecutionContext sessionContext) throws ODPSConsoleException { Matcher matcher = PATTERN.matcher(commandString); if (matcher.matches()) { String project = null; if (4 == matcher.groupCount() && matcher.group(4) != null) { CommandLine cl = getCommandLine(matcher.group(4)); if (0 != cl.getArgs().length) { throw new ODPSConsoleException(ODPSConsoleConstants.BAD_COMMAND + "[invalid paras]"); } project = cl.getOptionValue("p"); } return new ListFunctionsCommand(commandString, sessionContext, project); } return null; } ListFunctionsCommand(String commandText, ExecutionContext context, String project); static void printUsage(PrintStream out); void run(); static ListFunctionsCommand parse(String commandString, ExecutionContext sessionContext); static final String[] HELP_TAGS; }
@Test public void testMatchNegative() throws OdpsException, ODPSConsoleException { ExecutionContext ctx = ExecutionContext.init(); for (String cmd : negatives) { System.out.println(cmd); Assert.assertNull(ListFunctionsCommand.parse(cmd, ctx)); } }
@Test(expected = ODPSConsoleException.class) public void testLackParas() throws ODPSConsoleException { ExecutionContext context = ExecutionContext.init(); for (String cmd : badPara) { ListFunctionsCommand.parse(cmd, context); } }