CommandParser extends Parser<T> { protected void check(T type, Command command) { check(type, command, command.name(), NAME); for (var alias : command.aliases()) { check(type, command, alias, ALIAS); } } CommandParser(Environment<T> environment);   }
@Test void check_whitespaced_name() { parser.check(Object.class, command, "invalid name", Label.NAME); assertTrue(parser.names.isEmpty()); verify(environment).error(Object.class, "\"invalid name\" is not a valid command name, should not contain whitespaces"); }
@Test void check_empty_name() { parser.check(Object.class, command, "", Label.NAME); assertTrue(parser.names.isEmpty()); verify(environment).error(Object.class, "Command name should not be empty"); }
@Test void check_adds_name() { parser.check(Object.class, command, "alias", Label.ALIAS); var entry = parser.names.get("alias"); verify(environment, times(0)).error(any(), any()); verify(environment, times(0)).warn(any(), any()); assertEquals(command, entry.getKey()); assertEquals(Label.ALIAS, entry.getValue()); }
@Test void check_existing_namespace() { parser.names.put("something", new SimpleEntry<>(command, Label.ALIAS)); parser.check(Object.class, command, "something", Label.NAME); verify(environment).error(Object.class, "\"something\" already exists, commands should not have the same aliases and names"); }