@Test public void test() throws Exception { byte[][] args = new byte[2][]; args[0] = new byte[]{(byte) Command.DELETE.ordinal()}; args[1] = "abc".getBytes(); DeleteCommand d = new DeleteCommand(null); ReplyMessage reply = d.run(1, args); assertEquals(reply, ErrorMessage.WrongArgcMessage); }
@Override public ReplyMessage run(int argc, byte[][] argv) throws Exception { if (argc != 2) { return ErrorMessage.WrongArgcMessage; } String val = map.remove(new String(argv[1], Protocol.KEYCAFE_CHARSET)); if (val != null) { return new BulkStringMessage(val); } else { return StringMessage.OkMessage; } }
DeleteCommand implements CommandRunnable { @Override public ReplyMessage run(int argc, byte[][] argv) throws Exception { if (argc != 2) { return ErrorMessage.WrongArgcMessage; } String val = map.remove(new String(argv[1], Protocol.KEYCAFE_CHARSET)); if (val != null) { return new BulkStringMessage(val); } else { return StringMessage.OkMessage; } } }
DeleteCommand implements CommandRunnable { @Override public ReplyMessage run(int argc, byte[][] argv) throws Exception { if (argc != 2) { return ErrorMessage.WrongArgcMessage; } String val = map.remove(new String(argv[1], Protocol.KEYCAFE_CHARSET)); if (val != null) { return new BulkStringMessage(val); } else { return StringMessage.OkMessage; } } DeleteCommand(Map<String, String> map); }
DeleteCommand implements CommandRunnable { @Override public ReplyMessage run(int argc, byte[][] argv) throws Exception { if (argc != 2) { return ErrorMessage.WrongArgcMessage; } String val = map.remove(new String(argv[1], Protocol.KEYCAFE_CHARSET)); if (val != null) { return new BulkStringMessage(val); } else { return StringMessage.OkMessage; } } DeleteCommand(Map<String, String> map); @Override ReplyMessage run(int argc, byte[][] argv); @Override int keyIndex(); }
DeleteCommand implements CommandRunnable { @Override public ReplyMessage run(int argc, byte[][] argv) throws Exception { if (argc != 2) { return ErrorMessage.WrongArgcMessage; } String val = map.remove(new String(argv[1], Protocol.KEYCAFE_CHARSET)); if (val != null) { return new BulkStringMessage(val); } else { return StringMessage.OkMessage; } } DeleteCommand(Map<String, String> map); @Override ReplyMessage run(int argc, byte[][] argv); @Override int keyIndex();  }