DescribeTableCommand extends AbstractCommand { public static DescribeTableCommand parse(String cmd, ExecutionContext cxt) { if (cmd == null || cxt == null) { return null; } DescribeTableCommand r = null; Matcher m = PATTERN.matcher(cmd); boolean match = m.matches(); if (!match) { return r; } cmd = m.group(2); TablePart tablePart = ODPSConsoleUtils.getTablePart(cmd); if (tablePart.tableName != null) { String[] tableSpec = ODPSConsoleUtils.parseTableSpec(tablePart.tableName); String project = tableSpec[0]; String table = tableSpec[1]; r = new DescribeTableCommand(cmd, cxt, project, table, tablePart.partitionSpec); } return r; } DescribeTableCommand(String cmd, ExecutionContext cxt, String project, String table,
      String partition); static void printUsage(PrintStream stream); @Override void run(); static DescribeTableCommand parse(String cmd, ExecutionContext cxt); static String getScreenDisplay(Table t, Partition meta, boolean isExtended); static final String[] HELP_TAGS; }
@Test public void testCommandParse() throws ODPSConsoleException { ExecutionContext context = ExecutionContext.init(); for (String cmd : p_positives) { AbstractCommand command = DescribeTableCommand.parse(cmd, context); assertNotNull(command); assertTrue(command instanceof DescribeTableCommand); } for (String cmd : positives) { AbstractCommand command = DescribeTableCommand.parse(cmd, context); assertNotNull(command); assertTrue(command instanceof DescribeTableCommand); } }
@Test public void testCommandNeagetive() throws ODPSConsoleException { ExecutionContext context = ExecutionContext.init(); for (String cmd : negatives) { AbstractCommand command = DescribeTableCommand.parse(cmd, context); assertNull(command); } }