View Javadoc
1   package org.eclipse.aether.util.graph.transformer;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   * 
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   * 
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import static org.junit.Assert.*;
23  
24  import java.util.Map;
25  
26  import org.eclipse.aether.collection.DependencyGraphTransformer;
27  import org.eclipse.aether.graph.DependencyNode;
28  import org.eclipse.aether.internal.test.util.DependencyGraphParser;
29  import org.eclipse.aether.util.graph.transformer.ConflictMarker;
30  import org.eclipse.aether.util.graph.transformer.TransformationContextKeys;
31  import org.junit.Test;
32  
33  /**
34   */
35  public class ConflictMarkerTest
36      extends AbstractDependencyGraphTransformerTest
37  {
38  
39      @Override
40      protected DependencyGraphTransformer newTransformer()
41      {
42          return new ConflictMarker();
43      }
44  
45      @Override
46      protected DependencyGraphParser newParser()
47      {
48          return new DependencyGraphParser( "transformer/conflict-marker/" );
49      }
50  
51      @Test
52      public void testSimple()
53          throws Exception
54      {
55          DependencyNode root = parseResource( "simple.txt" );
56  
57          assertSame( root, transform( root ) );
58  
59          Map<?, ?> ids = (Map<?, ?>) context.get( TransformationContextKeys.CONFLICT_IDS );
60          assertNotNull( ids );
61  
62          assertNull( ids.get( root ) );
63          assertNotNull( ids.get( root.getChildren().get( 0 ) ) );
64          assertNotNull( ids.get( root.getChildren().get( 1 ) ) );
65          assertNotSame( ids.get( root.getChildren().get( 0 ) ), ids.get( root.getChildren().get( 1 ) ) );
66          assertNotEquals( ids.get( root.getChildren().get( 0 ) ), ids.get( root.getChildren().get( 1 ) ) );
67      }
68  
69      @Test
70      public void testRelocation1()
71          throws Exception
72      {
73          DependencyNode root = parseResource( "relocation1.txt" );
74  
75          assertSame( root, transform( root ) );
76  
77          Map<?, ?> ids = (Map<?, ?>) context.get( TransformationContextKeys.CONFLICT_IDS );
78          assertNotNull( ids );
79  
80          assertNull( ids.get( root ) );
81          assertNotNull( ids.get( root.getChildren().get( 0 ) ) );
82          assertNotNull( ids.get( root.getChildren().get( 1 ) ) );
83          assertSame( ids.get( root.getChildren().get( 0 ) ), ids.get( root.getChildren().get( 1 ) ) );
84      }
85  
86      @Test
87      public void testRelocation2()
88          throws Exception
89      {
90          DependencyNode root = parseResource( "relocation2.txt" );
91  
92          assertSame( root, transform( root ) );
93  
94          Map<?, ?> ids = (Map<?, ?>) context.get( TransformationContextKeys.CONFLICT_IDS );
95          assertNotNull( ids );
96  
97          assertNull( ids.get( root ) );
98          assertNotNull( ids.get( root.getChildren().get( 0 ) ) );
99          assertNotNull( ids.get( root.getChildren().get( 1 ) ) );
100         assertSame( ids.get( root.getChildren().get( 0 ) ), ids.get( root.getChildren().get( 1 ) ) );
101     }
102 
103     @Test
104     public void testRelocation3()
105         throws Exception
106     {
107         DependencyNode root = parseResource( "relocation3.txt" );
108 
109         assertSame( root, transform( root ) );
110 
111         Map<?, ?> ids = (Map<?, ?>) context.get( TransformationContextKeys.CONFLICT_IDS );
112         assertNotNull( ids );
113 
114         assertNull( ids.get( root ) );
115         assertNotNull( ids.get( root.getChildren().get( 0 ) ) );
116         assertNotNull( ids.get( root.getChildren().get( 1 ) ) );
117         assertNotNull( ids.get( root.getChildren().get( 2 ) ) );
118         assertSame( ids.get( root.getChildren().get( 0 ) ), ids.get( root.getChildren().get( 1 ) ) );
119         assertSame( ids.get( root.getChildren().get( 1 ) ), ids.get( root.getChildren().get( 2 ) ) );
120     }
121 
122 }