PermissionParser extends Parser<T> { @Override protected void parse(T type) { var permissions = new HashMap<String, Object>(); for (var permission : environment.resolver.all(type, Permission.class)) { check(type, permission); parse(permission, permissions); } environment.mappings.put("permissions", permissions); } PermissionParser(Environment<T> environment); @Override void clear();  }
@Test void parse() { parser.parse(PermissionParserTest.class); var mappings = environment.mappings; var permissions = (Map<String, Object>) mappings.get("permissions"); var permission = (Map<String, Object>) permissions.get("a.b"); var children = (Map<String, Boolean>) permission.get("children"); assertEquals(1, permissions.size()); assertEquals(3, permission.size()); assertEquals("desc", permission.get("description")); assertEquals("false", permission.get("default")); assertEquals(1, children.size()); assertTrue(children.get("a.b.c")); }
@Test void parse_permission() { var permissions = new HashMap<String, Object>(); parser.parse(PermissionParserTest.class.getAnnotation(Permission.class), permissions); var permission = (Map<String, Object>) permissions.get("a.b"); var children = (Map<String, Boolean>) permission.get("children"); assertEquals(1, permissions.size()); assertEquals(3, permission.size()); assertEquals("desc", permission.get("description")); assertEquals("false", permission.get("default")); assertEquals(1, children.size()); assertTrue(children.get("a.b.c")); }
@Test void parse_permission_empty() { var permissions = new HashMap<String, Object>(); parser.parse(Empty.class.getAnnotation(Permission.class), permissions); var permission = (Map<String, Object>) permissions.get("e.f"); assertEquals(1, permissions.size()); assertEquals(1, permission.size()); assertEquals("op", permission.get("default")); }