@Test public void testCyclicGraph() throws Exception { DependencyNode root = new DependencyGraphParser( "transformer/version-resolver/" ).parse( "cycle.txt" ); root = new SimpleConflictMarker().transformGraph( root, context ); root = new NearestVersionConflictResolver().transformGraph( root, context ); assertEquals( 2, root.getChildren().size() ); assertEquals( 1, root.getChildren().get( 0 ).getChildren().size() ); assertEquals( 0, root.getChildren().get( 0 ).getChildren().get( 0 ).getChildren().size() ); assertEquals( 0, root.getChildren().get( 1 ).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 );  }