CommandParser extends Parser<T> { @Override protected void parse(T type) { var commands = new HashMap<String, Object>(); for (var command : environment.resolver.all(type, Command.class)) { check(type, command); commands.put(command.name(), parse(type, command)); } environment.mappings.put("commands", commands); } CommandParser(Environment<T> environment);   }
@Test void parse_class() { parser.parse(Set.of(CommandParserTest.class)); var mapping = environment.mappings; var commands = (Map<String, Object>) mapping.get("commands"); var command = (Map<String, Object>) commands.get("name"); verify(environment, times(0)).error(any(), any()); verify(environment, times(0)).warn(any(), any()); assertEquals(1, mapping.size()); assertEquals(1, commands.size()); assertEquals(5, command.size()); assertArrayEquals(new String[] {"a", "b"}, (String[]) command.get("aliases")); assertEquals("desc", command.get("description")); assertEquals("syntax", command.get("usage")); assertEquals("a.b", command.get("permission")); assertEquals("message", command.get("permission-message")); }
@Test void parse_command() { var results = parser.parse(Object.class, command); assertTrue(parser.names.isEmpty()); assertEquals(5, results.size()); assertArrayEquals(new String[] {"a", "b"}, (String[]) results.get("aliases")); assertEquals("desc", results.get("description")); assertEquals("syntax", results.get("usage")); assertEquals("a.b", results.get("permission")); assertEquals("message", results.get("permission-message")); }
@Test void parse_command_warn() { var results = parser.parse(Object.class, MalformedPermission.class.getAnnotation(Command.class)); verify(environment).warn(Object.class, "\"a?s\" may be malformed"); assertEquals(2, results.size()); }