DropFunctionCommand extends AbstractCommand { public static DropFunctionCommand parse(String commandString, ExecutionContext sessionContext) throws ODPSConsoleException { String[] args = CommandParserUtils.getCommandTokens(commandString); if (args.length < 2) { return null; } if (args[0].equalsIgnoreCase("DROP") && args[1].equalsIgnoreCase("FUNCTION")) { if (args.length == 3) { return new DropFunctionCommand(null, args[2], commandString, sessionContext); } else { return parseExistsCommand(args, null, commandString, sessionContext); } } else if (args[0].equalsIgnoreCase("DELETE") && args[1].equalsIgnoreCase("FUNCTION")) { Options opts = initOptions(); CommandLine cl=CommandParserUtils.getCommandLine(args, opts); String project = cl.getOptionValue("p"); if (cl.getArgs().length == 3) { return new DropFunctionCommand(project, cl.getArgs()[2], commandString, sessionContext); } else { return parseExistsCommand(cl.getArgs(), project, commandString, sessionContext); } } return null; } DropFunctionCommand(String projectName, String resourceName, String commandText, ExecutionContext context);  DropFunctionCommand(boolean isCheckExistence, String projectName, String resourceName,
      String commandText, ExecutionContext context); static void printUsage(PrintStream out); @Override void run(); static DropFunctionCommand parse(String commandString, ExecutionContext sessionContext); static final String[] HELP_TAGS; }
@Test public void testDropFunctionCommandPositive() throws ODPSConsoleException { ExecutionContext ctx = ExecutionContext.init(); DropFunctionCommand command = null; command = DropFunctionCommand.parse("drop function test_drop", ctx); Assert.assertNotNull(command); Assert.assertFalse(command.isCheckExistence); command = DropFunctionCommand.parse("drop function if exists test_drop", ctx); Assert.assertNotNull(command); Assert.assertTrue(command.isCheckExistence); }
@Test public void testDropFunctionCommandNegtive() throws ODPSConsoleException { thrown.expect(ODPSConsoleException.class); ExecutionContext ctx = ExecutionContext.init(); DropFunctionCommand command = null; command = DropFunctionCommand.parse("drop function teststee test_drop", ctx); }