DropOnlineModelCommand extends AbstractCommand { public static DropOnlineModelCommand parse(String commandString, ExecutionContext sessionContext) throws ODPSConsoleException { boolean ifExists = false; if (commandString.toUpperCase().matches("\\s*DROP\\s+ONLINEMODEL\\s+.*")) { String line = commandString.trim().replaceAll("\\s+", " "); line = line.substring("DROP ONLINEMODEL ".length()).trim(); if (line.toUpperCase().startsWith("IF EXISTS ")) { ifExists = true; line = line.substring("IF EXISTS ".length()).trim(); } String temp[] = line.split(" "); if (temp.length == 1) { DropOnlineModelCommand command = new DropOnlineModelCommand(temp[0], commandString, sessionContext); command.setIfExists(ifExists); return command; } else throw new ODPSConsoleException(ODPSConsoleConstants.BAD_COMMAND); } return null; } DropOnlineModelCommand(String modelName, String commandString, ExecutionContext sessionContext); static void printUsage(PrintStream stream); @Override void run(); static DropOnlineModelCommand parse(String commandString, ExecutionContext sessionContext); static final String[] HELP_TAGS; }
@Test public void testNegativeCommand() throws ODPSConsoleException, OdpsException { ExecutionContext context = ExecutionContext.init(); String cmd = "DropOnlineModel not_exists"; DropOnlineModelCommand command = DropOnlineModelCommand.parse(cmd, context); assertNull(command); }