package org.apache.maven.archiva.dependency.graph;

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

import org.apache.maven.archiva.dependency.DependencyGraphFactory;
import org.apache.maven.archiva.model.DependencyScope;
import org.apache.maven.archiva.model.VersionedReference;

import java.util.ArrayList;
import java.util.List;

/**
 * ArchivaXmlToolsDependencyGraphTest
 * 
 * DependencyGraphTest for testing <code>org.apache.maven.archiva:archiva-xml-tools:1.0-alpha-2-SNAPSHOT</code>
 *
 * Generated by <code>archivadev:generate-dependency-tests</code> plugin
 * @version $Id$
 */
public class ArchivaXmlToolsDependencyGraphTest
   extends AbstractDependencyGraphFactoryTestCase
{
   public void testResolvedDepsToNodes()
        throws GraphTaskException
   {
      MemoryRepositoryDependencyGraphBuilder graphBuilder = 
                     new MemoryRepositoryDependencyGraphBuilder();
      MemoryRepository repository = new ArchivaXmlToolsMemoryRepository();
      graphBuilder.setMemoryRepository( repository );

      // Create the factory, and add the test resolver.
      DependencyGraphFactory factory = new DependencyGraphFactory();
      factory.setGraphBuilder( graphBuilder );
      factory.setDesiredScope( DependencyScope.TEST );

      // Get the model to resolve from
      VersionedReference rootRef = toVersionedReference( "org.apache.maven.archiva:archiva-xml-tools:1.0-alpha-2-SNAPSHOT"); 

      // Perform the resolution.
      DependencyGraph graph = factory.getGraph( rootRef );

      // Test the results.
      assertNotNull( "Graph shouldn't be null.", graph );

      String expectedRootRef = "org.apache.maven.archiva:archiva-xml-tools:1.0-alpha-2-SNAPSHOT";
      List<String> expectedNodes = new ArrayList<String>();

      // Check for all nodes, regardless of scope.
      expectedNodes.clear();
      expectedNodes.add( "commons-collections:commons-collections:3.2::jar" );
      expectedNodes.add( "commons-lang:commons-lang:2.2::jar" );
      expectedNodes.add( "dom4j:dom4j:1.6.1::jar" );
      expectedNodes.add( "jaxen:jaxen:1.1::jar" );
      expectedNodes.add( "junit:junit:3.8.1::jar" );
      expectedNodes.add( "log4j:log4j:1.2.8::jar" );
      expectedNodes.add( "org.apache.maven.archiva:archiva-common:1.0-alpha-2-SNAPSHOT::jar" );
      expectedNodes.add( "org.codehaus.plexus:plexus-classworlds:1.2-alpha-7::jar" );
      expectedNodes.add( "org.codehaus.plexus:plexus-component-api:1.0-alpha-22::jar" );
      expectedNodes.add( "org.codehaus.plexus:plexus-container-default:1.0-alpha-22::jar" );
      expectedNodes.add( "org.codehaus.plexus:plexus-utils:1.4::jar" );
      expectedNodes.add( "org.slf4j:slf4j-api:1.2::jar" );
      expectedNodes.add( "org.slf4j:slf4j-log4j12:1.2::jar" );
      expectedNodes.add( "xerces:xercesImpl:2.6.2::jar" );
      expectedNodes.add( "xml-apis:xml-apis:1.0.b2::jar" );

      assertGraph( graph, expectedRootRef, expectedNodes );
   }

}
