PluginParser extends Parser<T> { @Override protected void check(Set<T> types) { if (types.isEmpty()) { environment.error("Project does not contain a @Plugin annotation, should contain one @Plugin annotation"); } else if (types.size() > 1) { for (var type : types) { environment.error(type, "Project contains " + types.size() + " @Plugin annotations, should contain one @Plugin annotation"); } } else { check(new ArrayList<>(types).get(0)); } } PluginParser(Environment<T> environment); static PluginParser<Class<?>> type(Environment<Class<?>> environment); static PluginParser<Element> element(Environment<Element> environment, Elements elements, Types types);  }
@Test void check() { parser.check(Set.of(PluginParserTest.class)); verify(environment, times(0)).error(any(), any()); verify(environment, times(0)).warn(any(), any()); }
@Test void check_none() { parser.check(Set.of()); verify(environment).error("Project does not contain a @Plugin annotation, should contain one @Plugin annotation"); }
@Test void check_many() { parser.check(Set.of(Errors.class, Empty.class)); verify(environment).error(Errors.class, "Project contains 2 @Plugin annotations, should contain one @Plugin annotation"); verify(environment).error(Empty.class, "Project contains 2 @Plugin annotations, should contain one @Plugin annotation"); }
@Test void check() { parser.check(Valid.class); verify(environment, times(0)).error(any(), any()); verify(environment, times(0)).warn(any(), any()); }
@Test void check_abstract() { parser.check(Abstract.class); verify(environment).error(Abstract.class, quote(Abstract.class.getName()) + " is not a valid main class, should not be abstract"); }
@Test void check_superclass() { parser.check(ClassPluginParserTest.class); verify(environment).error( ClassPluginParserTest.class, quote(ClassPluginParserTest.class.getName()) + " is not a valid main class, should inherit from " + quote(org.bukkit.plugin.Plugin.class.getName()) ); }
@Test void check_constructor() { parser.check(Constructor.class); verify(environment).error(Constructor.class, quote(Constructor.class.getName()) + " is not a valid main class, should not contain a constructor with parameters"); }
@Test void check() { when(element.accept(parser.visitor, false)).thenReturn(true); parser.check(element); verify(element).accept(parser.visitor, false); }