@Test public void testNearestSoftVersionPrunedByFartherRange() throws Exception { DependencyNode a = builder.artifactId( "a" ).version( "1" ).build(); DependencyNode b = builder.artifactId( "b" ).version( "1" ).build(); DependencyNode c1 = builder.artifactId( "c" ).version( "1" ).range( "[1]" ).build(); DependencyNode c2 = builder.artifactId( "c" ).version( "2" ).build(); a.getChildren().add( c2 ); b.getChildren().add( c1 ); DependencyNode root = builder.artifactId( null ).build(); root.getChildren().add( a ); root.getChildren().add( b ); Map<DependencyNode, Object> conflictIds = new IdentityHashMap<DependencyNode, Object>(); conflictIds.put( a, "a" ); conflictIds.put( b, "b" ); conflictIds.put( c1, "c" ); conflictIds.put( c2, "c" ); context.put( TransformationContextKeys.CONFLICT_IDS, conflictIds ); NearestVersionConflictResolver transformer = new NearestVersionConflictResolver(); root = transformer.transformGraph( root, context ); assertEquals( 2, root.getChildren().size() ); assertSame( a, root.getChildren().get( 0 ) ); assertSame( b, root.getChildren().get( 1 ) ); assertTrue( a.getChildren().isEmpty() ); assertEquals( 1, b.getChildren().size() ); }
public DependencyNode transformGraph( DependencyNode node, DependencyGraphTransformationContext context ) throws RepositoryException { List<?> sortedConflictIds = (List<?>) context.get( TransformationContextKeys.SORTED_CONFLICT_IDS ); if ( sortedConflictIds == null ) { ConflictIdSorter sorter = new ConflictIdSorter(); sorter.transformGraph( node, context ); sortedConflictIds = (List<?>) context.get( TransformationContextKeys.SORTED_CONFLICT_IDS ); } Map<?, ?> conflictIds = (Map<?, ?>) context.get( TransformationContextKeys.CONFLICT_IDS ); if ( conflictIds == null ) { throw new RepositoryException( "conflict groups have not been identified" ); } Map<DependencyNode, Integer> depths = new IdentityHashMap<DependencyNode, Integer>( conflictIds.size() ); for ( Object key : sortedConflictIds ) { ConflictGroup group = new ConflictGroup( key ); depths.clear(); selectVersion( node, null, 0, depths, group, conflictIds, node ); pruneNonSelectedVersions( group, conflictIds ); } return node; }
NearestVersionConflictResolver implements DependencyGraphTransformer { public DependencyNode transformGraph( DependencyNode node, DependencyGraphTransformationContext context ) throws RepositoryException { List<?> sortedConflictIds = (List<?>) context.get( TransformationContextKeys.SORTED_CONFLICT_IDS ); if ( sortedConflictIds == null ) { ConflictIdSorter sorter = new ConflictIdSorter(); sorter.transformGraph( node, context ); sortedConflictIds = (List<?>) context.get( TransformationContextKeys.SORTED_CONFLICT_IDS ); } Map<?, ?> conflictIds = (Map<?, ?>) context.get( TransformationContextKeys.CONFLICT_IDS ); if ( conflictIds == null ) { throw new RepositoryException( "conflict groups have not been identified" ); } Map<DependencyNode, Integer> depths = new IdentityHashMap<DependencyNode, Integer>( conflictIds.size() ); for ( Object key : sortedConflictIds ) { ConflictGroup group = new ConflictGroup( key ); depths.clear(); selectVersion( node, null, 0, depths, group, conflictIds, node ); pruneNonSelectedVersions( group, conflictIds ); } return node; } }
NearestVersionConflictResolver implements DependencyGraphTransformer { public DependencyNode transformGraph( DependencyNode node, DependencyGraphTransformationContext context ) throws RepositoryException { List<?> sortedConflictIds = (List<?>) context.get( TransformationContextKeys.SORTED_CONFLICT_IDS ); if ( sortedConflictIds == null ) { ConflictIdSorter sorter = new ConflictIdSorter(); sorter.transformGraph( node, context ); sortedConflictIds = (List<?>) context.get( TransformationContextKeys.SORTED_CONFLICT_IDS ); } Map<?, ?> conflictIds = (Map<?, ?>) context.get( TransformationContextKeys.CONFLICT_IDS ); if ( conflictIds == null ) { throw new RepositoryException( "conflict groups have not been identified" ); } Map<DependencyNode, Integer> depths = new IdentityHashMap<DependencyNode, Integer>( conflictIds.size() ); for ( Object key : sortedConflictIds ) { ConflictGroup group = new ConflictGroup( key ); depths.clear(); selectVersion( node, null, 0, depths, group, conflictIds, node ); pruneNonSelectedVersions( group, conflictIds ); } return node; }  }
NearestVersionConflictResolver implements DependencyGraphTransformer { public DependencyNode transformGraph( DependencyNode node, DependencyGraphTransformationContext context ) throws RepositoryException { List<?> sortedConflictIds = (List<?>) context.get( TransformationContextKeys.SORTED_CONFLICT_IDS ); if ( sortedConflictIds == null ) { ConflictIdSorter sorter = new ConflictIdSorter(); sorter.transformGraph( node, context ); sortedConflictIds = (List<?>) context.get( TransformationContextKeys.SORTED_CONFLICT_IDS ); } Map<?, ?> conflictIds = (Map<?, ?>) context.get( TransformationContextKeys.CONFLICT_IDS ); if ( conflictIds == null ) { throw new RepositoryException( "conflict groups have not been identified" ); } Map<DependencyNode, Integer> depths = new IdentityHashMap<DependencyNode, Integer>( conflictIds.size() ); for ( Object key : sortedConflictIds ) { ConflictGroup group = new ConflictGroup( key ); depths.clear(); selectVersion( node, null, 0, depths, group, conflictIds, node ); pruneNonSelectedVersions( group, conflictIds ); } return node; }  DependencyNode transformGraph( DependencyNode node, DependencyGraphTransformationContext context ); }
NearestVersionConflictResolver implements DependencyGraphTransformer { public DependencyNode transformGraph( DependencyNode node, DependencyGraphTransformationContext context ) throws RepositoryException { List<?> sortedConflictIds = (List<?>) context.get( TransformationContextKeys.SORTED_CONFLICT_IDS ); if ( sortedConflictIds == null ) { ConflictIdSorter sorter = new ConflictIdSorter(); sorter.transformGraph( node, context ); sortedConflictIds = (List<?>) context.get( TransformationContextKeys.SORTED_CONFLICT_IDS ); } Map<?, ?> conflictIds = (Map<?, ?>) context.get( TransformationContextKeys.CONFLICT_IDS ); if ( conflictIds == null ) { throw new RepositoryException( "conflict groups have not been identified" ); } Map<DependencyNode, Integer> depths = new IdentityHashMap<DependencyNode, Integer>( conflictIds.size() ); for ( Object key : sortedConflictIds ) { ConflictGroup group = new ConflictGroup( key ); depths.clear(); selectVersion( node, null, 0, depths, group, conflictIds, node ); pruneNonSelectedVersions( group, conflictIds ); } return node; }  DependencyNode transformGraph( DependencyNode node, DependencyGraphTransformationContext context );  }