### Question:
MapsTokenScanner { Map<String, String> scanMap() { Map<String, String> map = new HashMap<>(); skipWhiteSpace(); while (hasNext()) { if (peek() == ',') { next(); break; } map.put(scanKey(), scanValue()); skipWhiteSpace(); } return map; } MapsTokenScanner(String input); static String toTokenString(List<Map<String, List<String>>> maps); List<Map<String, String>> scanMaps(); List<Map<String, List<String>>> scanMultiValueMaps();  }### Answer:
@Test void testScanMap() { for (String input : List.of("foo[bar] baz[qux]", "foo[bar]baz[qux]", "foo[bar] baz[qux] ", "foo[bar] baz[qux], quux[corge]")) { assertThat(new MapsTokenScanner(input).scanMap()).isEqualTo(Map.of("foo", "bar", "baz", "qux")); } }
@Test void testMissingValue() { assertThatThrownBy(() -> new MapsTokenScanner("foo").scanMap()) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("Expected value start"); }
@Test void testMissingKey() { assertThatThrownBy(() -> new MapsTokenScanner("foo[bar] [qux]").scanMap()) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("Empty key"); }
@Test void testMissingClosingBracket() { assertThatThrownBy(() -> new MapsTokenScanner("foo[bar").scanMap()) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("Expected end value token ']'"); }
@Test void testBracketWithinValue() { assertThatThrownBy(() -> new MapsTokenScanner("foo[b[a]r]").scanMap()) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("Invalid char '[' within a value"); }