ShowTablesCommand extends AbstractCommand { public static ShowTablesCommand parse(String cmd, ExecutionContext cxt) throws ODPSConsoleException { if (cmd == null || cxt == null) { return null; } String projectName = null; String prefixName = null; Matcher matcher = matchInternalCmd(cmd); if (matcher.matches()) { projectName = getProjectName(matcher); prefixName = getPrefixName(matcher); } else { matcher = matchPublicCmd(cmd); if (matcher.matches()) { projectName = getProjectNameFromPublicCmd(cmd); } else { return null; } } return new ShowTablesCommand(cmd, cxt, projectName, prefixName); } ShowTablesCommand(String cmd, ExecutionContext cxt, String project);  ShowTablesCommand(String cmd, ExecutionContext cxt, String project, String prefix); static void printUsage(PrintStream stream); @Override void run(); static ShowTablesCommand parse(String cmd, ExecutionContext cxt); static final String[] HELP_TAGS; }
@Test public void testLackProjectName() throws ODPSConsoleException { ExecutionContext context = ExecutionContext.init(); for (String cmd : pubLackPara) { try { ShowTablesCommand command = ShowTablesCommand.parse(cmd, context); Assert.assertNotNull(null); } catch (ODPSConsoleException e) { } } }
@Test public void testInvalidParams() throws ODPSConsoleException, OdpsException { ExecutionContext context = ExecutionContext.init(); for (String cmd : pubInvalidPara) { try { ShowTablesCommand command = ShowTablesCommand.parse(cmd, context); Assert.assertNotNull(null); } catch (ODPSConsoleException e) { } } }
@Test public void testPrefixNegatives() throws ODPSConsoleException { ExecutionContext context = ExecutionContext.init(); for (String cmd : prefixMatchNegatives) { for (String prefix : prefixNegatives) { String cmdStr = String.format(cmd, prefix); ShowTablesCommand command = ShowTablesCommand.parse(cmdStr, context); Assert.assertNull(command); } } }