View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.repository.legacy.resolver.conflict;
20  
21  import org.apache.maven.artifact.resolver.ResolutionNode;
22  import org.junit.jupiter.api.Test;
23  
24  /**
25   * Tests <code>NearestConflictResolver</code>.
26   *
27   * @see NearestConflictResolver
28   */
29  @Deprecated
30  class NearestConflictResolverTest extends AbstractConflictResolverTest {
31      // constructors -----------------------------------------------------------
32  
33      public NearestConflictResolverTest() throws Exception {
34          super("nearest");
35      }
36  
37      // tests ------------------------------------------------------------------
38  
39      /**
40       * Tests that <code>a:1.0</code> wins in the scenario:
41       * <pre>
42       * a:1.0
43       * b:1.0 -&gt; a:2.0
44       * </pre>
45       */
46      @Test
47      void testDepth() {
48          ResolutionNode a1n = createResolutionNode(a1);
49          ResolutionNode b1n = createResolutionNode(b1);
50          ResolutionNode a2n = createResolutionNode(a2, b1n);
51  
52          assertResolveConflict(a1n, a1n, a2n);
53      }
54  
55      /**
56       * Tests that <code>a:1.0</code> wins in the scenario:
57       * <pre>
58       * b:1.0 -&gt; a:2.0
59       * a:1.0
60       * </pre>
61       */
62      @Test
63      void testDepthReversed() {
64          ResolutionNode b1n = createResolutionNode(b1);
65          ResolutionNode a2n = createResolutionNode(a2, b1n);
66          ResolutionNode a1n = createResolutionNode(a1);
67  
68          assertResolveConflict(a1n, a2n, a1n);
69      }
70  
71      /**
72       * Tests that <code>a:1.0</code> wins in the scenario:
73       * <pre>
74       * a:1.0
75       * a:2.0
76       * </pre>
77       */
78      @Test
79      void testEqual() {
80          ResolutionNode a1n = createResolutionNode(a1);
81          ResolutionNode a2n = createResolutionNode(a2);
82  
83          assertResolveConflict(a1n, a1n, a2n);
84      }
85  
86      /**
87       * Tests that <code>a:2.0</code> wins in the scenario:
88       * <pre>
89       * a:2.0
90       * a:1.0
91       * </pre>
92       */
93      @Test
94      void testEqualReversed() {
95          ResolutionNode a2n = createResolutionNode(a2);
96          ResolutionNode a1n = createResolutionNode(a1);
97  
98          assertResolveConflict(a2n, a2n, a1n);
99      }
100 }