APIParser extends SingleParser<T> { @Override protected void parse(T type) { var api = environment.resolver.any(type, API.class); if (api.value() != Version.INFERRED) { environment.mappings.put("api-version", api.value().toString()); return; } for (var version : Version.values()) { if (environment.project.api.startsWith(version + ".") || environment.project.api.startsWith(version + "-")) { environment.mappings.put("api-version", version.toString()); break; } } if (!environment.mappings.containsKey("api-version")) { environment.mappings.put("api-version", Version.INFERRED.toString()); environment.warn(type, "Could not infer \"api-version\", \"" + Version.INFERRED + "\" will be used instead"); } } APIParser(Environment<T> environment);   }
@Test void parse() { parser.parse(APIParserTest.class); assertEquals("1.15", environment.mappings.get("api-version")); verify(environment, times(0)).warn(any(), any()); }
@Test void resolve_inferred() { parser.environment = StubEnvironment.of(new Project("", "", "1.15.1", List.of(), "", "")); parser.parse(Inferred.class); assertEquals("1.15", parser.environment.mappings.get("api-version")); }
@Test void resolve_inferred_default() { parser.parse(Inferred.class); assertEquals("1.13", environment.mappings.get("api-version")); verify(environment).warn(Inferred.class, "Could not infer \"api-version\", \"1.13\" will be used instead"); }