001package org.eclipse.aether.util.graph.transformer; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import static org.junit.Assert.*; 023 024import java.util.Map; 025 026import org.eclipse.aether.collection.DependencyGraphTransformer; 027import org.eclipse.aether.graph.DependencyNode; 028import org.eclipse.aether.internal.test.util.DependencyGraphParser; 029import org.eclipse.aether.util.graph.transformer.ConflictMarker; 030import org.eclipse.aether.util.graph.transformer.TransformationContextKeys; 031import org.junit.Test; 032 033/** 034 */ 035public class ConflictMarkerTest 036 extends AbstractDependencyGraphTransformerTest 037{ 038 039 @Override 040 protected DependencyGraphTransformer newTransformer() 041 { 042 return new ConflictMarker(); 043 } 044 045 @Override 046 protected DependencyGraphParser newParser() 047 { 048 return new DependencyGraphParser( "transformer/conflict-marker/" ); 049 } 050 051 @Test 052 public void testSimple() 053 throws Exception 054 { 055 DependencyNode root = parseResource( "simple.txt" ); 056 057 assertSame( root, transform( root ) ); 058 059 Map<?, ?> ids = (Map<?, ?>) context.get( TransformationContextKeys.CONFLICT_IDS ); 060 assertNotNull( ids ); 061 062 assertNull( ids.get( root ) ); 063 assertNotNull( ids.get( root.getChildren().get( 0 ) ) ); 064 assertNotNull( ids.get( root.getChildren().get( 1 ) ) ); 065 assertNotSame( ids.get( root.getChildren().get( 0 ) ), ids.get( root.getChildren().get( 1 ) ) ); 066 assertNotEquals( ids.get( root.getChildren().get( 0 ) ), ids.get( root.getChildren().get( 1 ) ) ); 067 } 068 069 @Test 070 public void testRelocation1() 071 throws Exception 072 { 073 DependencyNode root = parseResource( "relocation1.txt" ); 074 075 assertSame( root, transform( root ) ); 076 077 Map<?, ?> ids = (Map<?, ?>) context.get( TransformationContextKeys.CONFLICT_IDS ); 078 assertNotNull( ids ); 079 080 assertNull( ids.get( root ) ); 081 assertNotNull( ids.get( root.getChildren().get( 0 ) ) ); 082 assertNotNull( ids.get( root.getChildren().get( 1 ) ) ); 083 assertSame( ids.get( root.getChildren().get( 0 ) ), ids.get( root.getChildren().get( 1 ) ) ); 084 } 085 086 @Test 087 public void testRelocation2() 088 throws Exception 089 { 090 DependencyNode root = parseResource( "relocation2.txt" ); 091 092 assertSame( root, transform( root ) ); 093 094 Map<?, ?> ids = (Map<?, ?>) context.get( TransformationContextKeys.CONFLICT_IDS ); 095 assertNotNull( ids ); 096 097 assertNull( ids.get( root ) ); 098 assertNotNull( ids.get( root.getChildren().get( 0 ) ) ); 099 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}