gnodet-bot commented on code in PR #13991: URL: https://github.com/apache/maven/pull/13991#discussion_r4570187327
########## impl/maven-core/src/test/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolverTest.java: ########## @@ -0,0 +1,169 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.plugin.version.internal; + +import org.apache.maven.plugin.MavenPluginManager; +import org.apache.maven.plugin.descriptor.PluginDescriptor; +import org.apache.maven.plugin.version.DefaultPluginVersionRequest; +import org.eclipse.aether.util.version.GenericVersionScheme; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.mockito.Mockito; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * Which versions are excluded when a plugin is resolved without a declared version. + */ +class DefaultPluginVersionResolverTest { + + private final DefaultPluginVersionResolver resolver = + new DefaultPluginVersionResolver(null, null, null, new GenericVersionScheme()); + + /** + * A resolver for which every candidate passes the compatibility check, so the tests observe the + * selection order alone. + */ + private static DefaultPluginVersionResolver resolverAcceptingEveryVersion() throws Exception { + MavenPluginManager pluginManager = Mockito.mock(MavenPluginManager.class); + Mockito.when(pluginManager.getPluginDescriptor(Mockito.any(), Mockito.any(), Mockito.any())) + .thenReturn(new PluginDescriptor()); + return new DefaultPluginVersionResolver(null, null, pluginManager, new GenericVersionScheme()); + } + + private static DefaultPluginVersionResolver.Versions versions(String release, String... available) { + DefaultPluginVersionResolver.Versions versions = new DefaultPluginVersionResolver.Versions(); + versions.releaseVersion = release; + for (String version : available) { + versions.versions.put(version, null); + } + return versions; + } Review Comment: The `versions()` helper only sets `releaseVersion` — `latestVersion` is never assigned anywhere in the test class. The `latestVersion` branch of `selectVersion` (the `else if` arm that fires when `releaseVersion` is null) is never exercised. Consider adding a `Versions` instance where `latestVersion` is set but `releaseVersion` is empty, to cover the fallback path. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
