### Question:
CommandArguments { public String popString(String argName) throws ArgumentParseException { String arg = currentArgument(argName); return success(argName, arg); } CommandArguments(String commandName, List<String> args);  CommandArguments(String commandName, String... args); List<String> get(); int length(); boolean hasMore(); CommandFlags flags(); ArgumentParseException failure(String argName, String error, boolean silenceable, String... completions); T success(String argName, T parsedValue); T success(String argName, T parsedValue, boolean fallbackValue); T potentialDefault(ArgumentParseException e, T def); String currentArgument(String argName); boolean advance(); void assertCompletelyParsed(); String popString(String argName); String popString(String argName, String def); int popInteger(String argName); int popInteger(String argName, int def); float popFloat(String argName); float popFloat(String argName, float def); double popDouble(String argName); double popDouble(String argName, double def); boolean popBoolean(String argName); boolean popBoolean(String argName, boolean def); Player popPlayer(String argName); Player popPlayerOrMe(String argName, CommandSource me); World popWorld(String argName); World popWorld(String argName, CommandSource source); World popWorld(String argName, World def); Vector3f popVector3(String argName); Vector3f popVector3(String argName, Vector3f def); Point popPoint(String argName, CommandSource source); Point popPoint(String argName, CommandSource source, Point def); T popEnumValue(String argName, Class<T> enumClass); T popEnumValue(String argName, Class<T> enumClass, T def); String popRemainingStrings(String argName); String popRemainingStrings(String argName, String def); Player checkPlayer(CommandSource source); void logAndNotify(Engine loggerSource, CommandSource source, String message); void logAndNotify(Plugin loggerSource, CommandSource source, String message); void logAndNotify(Logger logger, CommandSource source, String message); T get(String key, Class<T> type); T get(String key, Class<T> type, T def); boolean has(String key); String getString(String key); String getString(String key, String def); int getInteger(String key, int def); float getFloat(String key, float def); String[] toArray(); @Override String toString();  }### Answer:
@Test public void testQuotedString() throws Exception { CommandArguments validDouble = new CommandArguments("qtest", "\"Hi", "there\""); assertEquals("Hi there", validDouble.popString("joined")); CommandArguments validSingle = new CommandArguments("qtest", "'Hi", "there'"); assertEquals("Hi there", validSingle.popString("joined")); CommandArguments validSame = new CommandArguments("qtest", "'word'"); assertEquals("word", validSame.popString("single")); CommandArguments validEmpty = new CommandArguments("qtest", "\"\""); assertEquals("", validEmpty.popString("empty")); CommandArguments valid = new CommandArguments("qtest", "'Hi", "there'", "another"); assertEquals("Hi there", valid.popString("quoted")); assertEquals("another", valid.popString("unquoted")); }
@Test public void testUnmatchedQuoteString() throws ArgumentParseException { CommandArguments invalid = new CommandArguments("qtest", "'Hehehe"); thrown.expect(ArgumentParseException.class); invalid.popString("gonnathrowanerror"); }
@Test public void testNotEnoughArgs() throws ArgumentParseException { CommandArguments args = new CommandArguments("cmd", "arg1"); assertEquals("arg1", args.popString("1")); thrown.expect(ArgumentParseException.class); args.popString("2"); }